Simplify types
This commit is contained in:
parent
6eddb4834b
commit
ba8b1a29fd
30 changed files with 52 additions and 76 deletions
|
|
@ -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];
|
||||
|
|
|
|||
|
|
@ -1,10 +1,11 @@
|
|||
import { vec2, vec3 } from 'gl-matrix';
|
||||
import { LampBase, settings, id } from 'shared';
|
||||
import { LampBase, settings, id, typeToBaseType } from 'shared';
|
||||
|
||||
import { ImmutableBoundingBox } from '../physics/bounding-boxes/immutable-bounding-box';
|
||||
|
||||
import { Physical } from '../physics/physical';
|
||||
|
||||
@typeToBaseType
|
||||
export class LampPhysical extends LampBase implements Physical {
|
||||
public readonly canCollide = false;
|
||||
public readonly isInverted = false;
|
||||
|
|
|
|||
|
|
@ -1,9 +1,10 @@
|
|||
import { vec2 } from 'gl-matrix';
|
||||
import { clamp01, mix, TunnelBase, id } from 'shared';
|
||||
import { clamp01, mix, TunnelBase, id, typeToBaseType } from 'shared';
|
||||
|
||||
import { ImmutableBoundingBox } from '../physics/bounding-boxes/immutable-bounding-box';
|
||||
import { StaticPhysical } from '../physics/containers/static-physical-object';
|
||||
|
||||
@typeToBaseType
|
||||
export class TunnelPhysical extends TunnelBase implements StaticPhysical {
|
||||
public readonly canCollide = true;
|
||||
public readonly isInverted = true;
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import { Physical } from '../physical';
|
|||
import { BoundingBoxBase } from '../bounding-boxes/bounding-box-base';
|
||||
|
||||
export class BoundingBoxList {
|
||||
constructor(private objects: Array<Physical> = []) {}
|
||||
constructor(private objects: Array<Physical> = []) { }
|
||||
|
||||
public insert(object: Physical) {
|
||||
this.objects.push(object);
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ export class Player extends CommandReceiver {
|
|||
},
|
||||
};
|
||||
|
||||
protected defaultCommandExecutor(command: Command) {}
|
||||
protected defaultCommandExecutor(command: Command) { }
|
||||
|
||||
constructor(
|
||||
private readonly objects: PhysicalContainer,
|
||||
|
|
@ -118,6 +118,7 @@ export class Player extends CommandReceiver {
|
|||
|
||||
public destroy() {
|
||||
this.isActive = false;
|
||||
this.character.destroy();
|
||||
this.objects.removeObject(this.character);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue