chore: simplify tiles size state

This commit is contained in:
cha0s 2019-03-27 22:27:58 -05:00
parent f9826e16d5
commit 75458d331a

View File

@ -16,13 +16,15 @@ export class Tiles extends decorate(class {}) {
constructor() {
super();
this.data = I.List();
this._sizeState = I.List();
this._state = I.Map();
}
acceptStateChange(change) {
if (change.size) {
this.size = change.size;
if (change.width) {
this.width = change.width;
}
if (change.height) {
this.height = change.height;
}
if (change.data) {
const oldData = this.data;
@ -96,8 +98,8 @@ export class Tiles extends decorate(class {}) {
}
tick(elapsed) {
this._sizeState = this._sizeState.set(0, this.width).set(1, this.height);
this._state = this._state.set('size', this._sizeState);
this._state = this._state.set('width', this.width);
this._state = this._state.set('height', this.height);
this._state = this._state.set('data', this.data);
}