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);
},
dying: () => {
this.entity.isBehaving = false;
isDyingChanged: (_, isDying) => {
this.entity.isBehaving = !isDying;
},
};

View File

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

View File

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

View File

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

View File

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