Fix physics
This commit is contained in:
parent
37954e2ef1
commit
f9f6825776
6 changed files with 820 additions and 529 deletions
|
|
@ -1,8 +1,5 @@
|
|||
import { CommandReceiver } from '../commands/command-receiver';
|
||||
import { Id } from '../transport/identity';
|
||||
|
||||
export abstract class GameObject extends CommandReceiver {
|
||||
constructor(public readonly id: Id) {
|
||||
super();
|
||||
}
|
||||
export abstract class GameObject {
|
||||
constructor(public readonly id: Id) {}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import { GameObject } from '../game-object';
|
|||
export class CharacterBase extends GameObject {
|
||||
constructor(
|
||||
id: Id,
|
||||
public colorIndex: number,
|
||||
public head?: Circle,
|
||||
public leftFoot?: Circle,
|
||||
public rightFoot?: Circle,
|
||||
|
|
@ -15,7 +16,7 @@ export class CharacterBase extends GameObject {
|
|||
}
|
||||
|
||||
public toArray(): Array<any> {
|
||||
const { id, head, leftFoot, rightFoot } = this as any;
|
||||
return [id, head, leftFoot, rightFoot];
|
||||
const { id, colorIndex, head, leftFoot, rightFoot } = this;
|
||||
return [id, colorIndex, head, leftFoot, rightFoot];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ export class LampBase extends GameObject {
|
|||
}
|
||||
|
||||
public toArray(): Array<any> {
|
||||
const { id, center, color, lightness } = this as any;
|
||||
const { id, center, color, lightness } = this;
|
||||
return [id, center, color, lightness];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
15
shared/src/objects/types/projectile-base.ts
Normal file
15
shared/src/objects/types/projectile-base.ts
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
import { vec2 } from 'gl-matrix';
|
||||
import { Id } from '../../transport/identity';
|
||||
import { serializable } from '../../transport/serialization/serializable';
|
||||
import { GameObject } from '../game-object';
|
||||
|
||||
@serializable
|
||||
export class ProjectileBase extends GameObject {
|
||||
constructor(id: Id, public center: vec2, public radius: number) {
|
||||
super(id);
|
||||
}
|
||||
|
||||
public toArray(): Array<any> {
|
||||
return [this.id, this.center, this.radius];
|
||||
}
|
||||
}
|
||||
15
shared/src/objects/types/stone-base.ts
Normal file
15
shared/src/objects/types/stone-base.ts
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
import { vec2 } from 'gl-matrix';
|
||||
import { Id } from '../../transport/identity';
|
||||
import { serializable } from '../../transport/serialization/serializable';
|
||||
import { GameObject } from '../game-object';
|
||||
|
||||
@serializable
|
||||
export class StoneBase extends GameObject {
|
||||
constructor(id: Id, public readonly vertices: Array<vec2>) {
|
||||
super(id);
|
||||
}
|
||||
|
||||
public toArray(): Array<any> {
|
||||
return [this.id, this.vertices];
|
||||
}
|
||||
}
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
import { vec2 } from 'gl-matrix';
|
||||
import { Id } from '../../transport/identity';
|
||||
import { serializable } from '../../transport/serialization/serializable';
|
||||
import { GameObject } from '../game-object';
|
||||
|
||||
@serializable
|
||||
export class TunnelBase extends GameObject {
|
||||
constructor(
|
||||
id: Id,
|
||||
public readonly from: vec2,
|
||||
public readonly to: vec2,
|
||||
public readonly fromRadius: number,
|
||||
public readonly toRadius: number,
|
||||
) {
|
||||
super(id);
|
||||
}
|
||||
|
||||
public toArray(): Array<any> {
|
||||
const { id, from, to, fromRadius, toRadius } = this as any;
|
||||
return [id, from, to, fromRadius, toRadius];
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue