refactor: isDying StateProperty

This commit is contained in:
cha0s 2019-10-10 01:27:02 -05:00
parent f6622d6919
commit 66cfd9c21a
5 changed files with 12 additions and 12 deletions

View File

@ -62,8 +62,8 @@ export class Behaved extends decorate(Trait) {
this.updateCurrentRoutine(currentRoutine); this.updateCurrentRoutine(currentRoutine);
}, },
dying: () => { isDyingChanged: (_, isDying) => {
this.entity.isBehaving = false; this.entity.isBehaving = !isDying;
}, },
}; };

View File

@ -12,6 +12,9 @@ import {DiedPacket} from '../packets/died.packet';
import {TraitUpdateAlivePacket} from '../packets/trait-update-alive.packet'; import {TraitUpdateAlivePacket} from '../packets/trait-update-alive.packet';
const decorate = compose( const decorate = compose(
StateProperty('isDying', {
track: true,
}),
StateProperty('life', { StateProperty('life', {
track: true, track: true,
}), }),
@ -140,10 +143,7 @@ export class Alive extends decorate(Trait) {
if (this._dyingTickingPromise) { if (this._dyingTickingPromise) {
return; return;
} }
this.entity.emit('dying'); this.entity.isDying = true;
this.state.isDying = true;
this.entity._fastDirtyCheck = true;
this._fastDirtyCheck = true;
this._dyingTickingPromise = this._deathActions.tickingPromise( this._dyingTickingPromise = this._deathActions.tickingPromise(
this._context this._context
) )

View File

@ -100,8 +100,8 @@ export class Spawner extends decorate(Trait) {
listeners() { listeners() {
return { return {
dying: () => { isDyingChanged: (_, isDying) => {
this.isSpawning = false; this.isSpawning = !isDying;
}, },
}; };

View File

@ -97,8 +97,8 @@ export class Physical extends decorate(Trait) {
} }
}, },
dying: () => { isDyingChanged: (_, isDying) => {
this.entity.addedToPhysics = false; this.entity.addedToPhysics = !isDying;
}, },
positionChanged: () => { positionChanged: () => {

View File

@ -250,8 +250,8 @@ export class Animated extends decorate(Trait) {
} }
}, },
dying: () => { isDyingChanged: (_, isDying) => {
this.isAnimating = false; this.isAnimating = !isDying;
}, },
visibleScaleChanged: () => { visibleScaleChanged: () => {