diff options
author | Elizabeth Hunt <elizabeth.hunt@simponic.xyz> | 2023-08-26 17:55:27 -0600 |
---|---|---|
committer | Elizabeth Hunt <elizabeth.hunt@simponic.xyz> | 2023-08-26 17:55:27 -0600 |
commit | 6ce6946a4401d2ee6fa5cb747fab7d4c658a63c8 (patch) | |
tree | e60767dc5295edf379cf421e20171dc418e548b7 /engine/entities/Floor.ts | |
parent | 594921352c8d82fe5f1a6201a4d5f9fbd9b719fc (diff) | |
download | jumpstorm-6ce6946a4401d2ee6fa5cb747fab7d4c658a63c8.tar.gz jumpstorm-6ce6946a4401d2ee6fa5cb747fab7d4c658a63c8.zip |
add entity updates over network!
Diffstat (limited to 'engine/entities/Floor.ts')
-rw-r--r-- | engine/entities/Floor.ts | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/engine/entities/Floor.ts b/engine/entities/Floor.ts index 6f9b13b..b4f48e5 100644 --- a/engine/entities/Floor.ts +++ b/engine/entities/Floor.ts @@ -1,5 +1,5 @@ import { IMAGES, SPRITE_SPECS, Sprites, type SpriteSpec } from '../config'; -import { BoundingBox, Sprite } from '../components'; +import { BoundingBox, ComponentNames, Sprite } from '../components'; import { TopCollidable } from '../components/TopCollidable'; import { Entity, EntityNames } from '../entities'; @@ -8,9 +8,13 @@ export class Floor extends Entity { Sprites.FLOOR ) as SpriteSpec; + private width: number; + constructor(width: number) { super(EntityNames.Floor); + this.width = width; + this.addComponent( new Sprite( IMAGES.get((Floor.spriteSpec?.states?.get(width) as SpriteSpec).sheet), @@ -23,4 +27,22 @@ export class Floor extends Entity { this.addComponent(new TopCollidable()); } + + public serialize() { + return { + floorWidth: this.width, + boundingBox: this.getComponent<BoundingBox>(ComponentNames.BoundingBox) + }; + } + + public setFrom(args: any) { + const { boundingBox } = args; + this.addComponent( + new BoundingBox( + boundingBox.center, + boundingBox.dimension, + boundingBox.rotation + ) + ); + } } |