Simplify types

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

View file

@ -6,6 +6,7 @@ import {
settings,
CommandExecutors,
MoveActionCommand,
typeToBaseType,
} from 'shared';
import { ImmutableBoundingBox } from '../physics/bounding-boxes/immutable-bounding-box';
@ -14,6 +15,7 @@ import { CirclePhysical } from './circle-physical';
import { Physical } from '../physics/physical';
import { PhysicalContainer } from '../physics/containers/physical-container';
@typeToBaseType
export class CharacterPhysical extends CharacterBase implements Physical {
public readonly canCollide = true;
public readonly isInverted = false;
@ -34,7 +36,7 @@ export class CharacterPhysical extends CharacterBase implements Physical {
private static readonly leftFootOffset = vec2.fromValues(-20, -10);
private static readonly rightFootOffset = vec2.fromValues(20, -10);
constructor(container: PhysicalContainer) {
constructor(private readonly container: PhysicalContainer) {
super(
id(),
new CirclePhysical(vec2.clone(CharacterPhysical.headOffset), 50, null, container),
@ -159,6 +161,12 @@ export class CharacterPhysical extends CharacterBase implements Physical {
);*/
}
public destroy() {
this.container.removeObject(this.head);
this.container.removeObject(this.leftFoot);
this.container.removeObject(this.rightFoot);
}
public toJSON(): any {
const { type, id, head, leftFoot, rightFoot } = this;
return [type, id, head, leftFoot, rightFoot];