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