From 90a5bed2a8f77a5037e65b5105dec00460d56fda Mon Sep 17 00:00:00 2001 From: cha0s Date: Tue, 26 Mar 2019 17:04:44 -0500 Subject: [PATCH] feat: layer state --- packages/topdown/layer.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/packages/topdown/layer.js b/packages/topdown/layer.js index c7ba1da..2b7194b 100644 --- a/packages/topdown/layer.js +++ b/packages/topdown/layer.js @@ -1,3 +1,6 @@ +import * as I from 'immutable'; + +import {EntityList} from '@avocado/entity'; import {Tiles} from '@avocado/topdown'; export class Layer { @@ -5,7 +8,8 @@ export class Layer { constructor() { this.tiles = undefined; this.tilesetUri = undefined; - this.entityList = undefined; + this.entityList = new EntityList(); + this._state = I.Map(); } fromJSON(json) { @@ -18,4 +22,15 @@ export class Layer { return this; } + get state() { + return this._state; + } + + tick(elapsed) { + if (this.entityList) { + this.entityList.tick(elapsed); + this._state = this._state.set('entityList', this.entityList.state); + } + } + } \ No newline at end of file