refactor: setDirty
This commit is contained in:
parent
68d67e082d
commit
ee7608c211
|
@ -108,6 +108,11 @@ export class Trait extends decorate(class {}) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setDirty() {
|
||||||
|
this._fastDirtyCheck = true;
|
||||||
|
this.entity._fastDirtyCheck = true;
|
||||||
|
}
|
||||||
|
|
||||||
stateDifferences() {
|
stateDifferences() {
|
||||||
const differences = {};
|
const differences = {};
|
||||||
for (const key in this.state) {
|
for (const key in this.state) {
|
||||||
|
@ -154,8 +159,7 @@ export function StateProperty(key, meta = {}) {
|
||||||
`);
|
`);
|
||||||
meta.set = meta.set || new Function('value', `
|
meta.set = meta.set || new Function('value', `
|
||||||
if (value !== this.${transformedProperty}) {
|
if (value !== this.${transformedProperty}) {
|
||||||
this._fastDirtyCheck = true;
|
this.setDirty();
|
||||||
this.entity._fastDirtyCheck = true;
|
|
||||||
}
|
}
|
||||||
this.${transformedProperty} = value;
|
this.${transformedProperty} = value;
|
||||||
this.state['${key}'] = value;
|
this.state['${key}'] = value;
|
||||||
|
|
|
@ -62,8 +62,7 @@ export class Positioned extends decorate(Trait) {
|
||||||
if (AVOCADO_SERVER) {
|
if (AVOCADO_SERVER) {
|
||||||
this.state.x = newPosition[0];
|
this.state.x = newPosition[0];
|
||||||
this.state.y = newPosition[1];
|
this.state.y = newPosition[1];
|
||||||
this.entity._fastDirtyCheck = true;
|
this.setDirty();
|
||||||
this._fastDirtyCheck = true;
|
|
||||||
}
|
}
|
||||||
this.entity.emit('positionChanged', oldPosition, newPosition);
|
this.entity.emit('positionChanged', oldPosition, newPosition);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user