Simplify types

This commit is contained in:
schmelczerandras 2020-10-06 14:08:43 +02:00
commit ba8b1a29fd
4 changed files with 52 additions and 76 deletions

View file

@ -2,8 +2,12 @@ import { CommandReceiver } from '../commands/command-receiver';
import { Id } from '../transport/identity';
export abstract class GameObject extends CommandReceiver {
public static get type(): string {
return (this as any).name;
}
public get type(): string {
return (this as any).constructor.type;
return (this as any).constructor.name;
}
constructor(public readonly id: Id) {

View file

@ -1,11 +1,8 @@
import { vec2 } from 'gl-matrix';
import { Circle } from '../../helper/circle';
import { Id } from '../../main';
import { GameObject } from '../game-object';
export abstract class CharacterBase extends GameObject {
public static readonly type = 'Character';
constructor(
id: Id,
public head: Circle,

View file

@ -3,8 +3,6 @@ import { Id } from '../../main';
import { GameObject } from '../game-object';
export abstract class LampBase extends GameObject {
public static readonly type = 'Lamp';
constructor(id: Id, public center: vec2, public color: vec3, public lightness: number) {
super(id);
}

View file

@ -1,10 +1,7 @@
import { vec2 } from 'gl-matrix';
import { GameObject, Id } from '../../main';
import { typed } from '../../transport/typed';
export abstract class TunnelBase extends GameObject {
public static readonly type = 'Tunnel';
constructor(
id: Id,
public readonly from: vec2,