Solve serialization
This commit is contained in:
parent
ba8b1a29fd
commit
8e44dd3733
45 changed files with 242 additions and 201 deletions
|
|
@ -6,7 +6,7 @@ import {
|
|||
settings,
|
||||
CommandExecutors,
|
||||
MoveActionCommand,
|
||||
typeToBaseType,
|
||||
serializable,
|
||||
} from 'shared';
|
||||
|
||||
import { ImmutableBoundingBox } from '../physics/bounding-boxes/immutable-bounding-box';
|
||||
|
|
@ -15,7 +15,7 @@ import { CirclePhysical } from './circle-physical';
|
|||
import { Physical } from '../physics/physical';
|
||||
import { PhysicalContainer } from '../physics/containers/physical-container';
|
||||
|
||||
@typeToBaseType
|
||||
@serializable(CharacterBase)
|
||||
export class CharacterPhysical extends CharacterBase implements Physical {
|
||||
public readonly canCollide = true;
|
||||
public readonly isInverted = false;
|
||||
|
|
@ -166,9 +166,4 @@ export class CharacterPhysical extends CharacterBase implements Physical {
|
|||
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];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import {
|
|||
clamp,
|
||||
CommandExecutors,
|
||||
GameObject,
|
||||
serializable,
|
||||
settings,
|
||||
StepCommand,
|
||||
} from 'shared';
|
||||
|
|
@ -14,6 +15,7 @@ import { BoundingBoxBase } from '../physics/bounding-boxes/bounding-box-base';
|
|||
import { moveCircle } from '../physics/move-circle';
|
||||
import { PhysicalContainer } from '../physics/containers/physical-container';
|
||||
|
||||
@serializable(Circle)
|
||||
export class CirclePhysical implements Circle, Physical {
|
||||
readonly isInverted = false;
|
||||
readonly canCollide = true;
|
||||
|
|
@ -154,8 +156,8 @@ export class CirclePhysical implements Circle, Physical {
|
|||
return wasHit;
|
||||
}
|
||||
|
||||
public toJSON(): any {
|
||||
public toArray(): Array<any> {
|
||||
const { center, radius } = this;
|
||||
return { center, radius };
|
||||
return [center, radius];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
import { vec2, vec3 } from 'gl-matrix';
|
||||
import { LampBase, settings, id, typeToBaseType } from 'shared';
|
||||
import { LampBase, settings, id, serializable } from 'shared';
|
||||
|
||||
import { ImmutableBoundingBox } from '../physics/bounding-boxes/immutable-bounding-box';
|
||||
|
||||
import { Physical } from '../physics/physical';
|
||||
|
||||
@typeToBaseType
|
||||
@serializable(LampBase)
|
||||
export class LampPhysical extends LampBase implements Physical {
|
||||
public readonly canCollide = false;
|
||||
public readonly isInverted = false;
|
||||
|
|
@ -38,9 +38,4 @@ export class LampPhysical extends LampBase implements Physical {
|
|||
public distance(_: vec2): number {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public toJSON(): any {
|
||||
const { type, id, center, color, lightness } = this;
|
||||
return [type, id, center, color, lightness];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
import { vec2 } from 'gl-matrix';
|
||||
import { clamp01, mix, TunnelBase, id, typeToBaseType } from 'shared';
|
||||
import { clamp01, mix, TunnelBase, id, serializable } from 'shared';
|
||||
|
||||
import { ImmutableBoundingBox } from '../physics/bounding-boxes/immutable-bounding-box';
|
||||
import { StaticPhysical } from '../physics/containers/static-physical-object';
|
||||
|
||||
@typeToBaseType
|
||||
@serializable(TunnelBase)
|
||||
export class TunnelPhysical extends TunnelBase implements StaticPhysical {
|
||||
public readonly canCollide = true;
|
||||
public readonly isInverted = true;
|
||||
|
|
@ -45,9 +45,4 @@ export class TunnelPhysical extends TunnelBase implements StaticPhysical {
|
|||
public get gameObject(): TunnelPhysical {
|
||||
return this;
|
||||
}
|
||||
|
||||
public toJSON(): any {
|
||||
const { type, id, from, to, fromRadius, toRadius } = this;
|
||||
return [type, id, from, to, fromRadius, toRadius];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue