refactor: isDying StateProperty
This commit is contained in:
parent
f6622d6919
commit
66cfd9c21a
|
@ -62,8 +62,8 @@ export class Behaved extends decorate(Trait) {
|
|||
this.updateCurrentRoutine(currentRoutine);
|
||||
},
|
||||
|
||||
dying: () => {
|
||||
this.entity.isBehaving = false;
|
||||
isDyingChanged: (_, isDying) => {
|
||||
this.entity.isBehaving = !isDying;
|
||||
},
|
||||
|
||||
};
|
||||
|
|
|
@ -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
|
||||
)
|
||||
|
|
|
@ -100,8 +100,8 @@ export class Spawner extends decorate(Trait) {
|
|||
listeners() {
|
||||
return {
|
||||
|
||||
dying: () => {
|
||||
this.isSpawning = false;
|
||||
isDyingChanged: (_, isDying) => {
|
||||
this.isSpawning = !isDying;
|
||||
},
|
||||
|
||||
};
|
||||
|
|
|
@ -97,8 +97,8 @@ export class Physical extends decorate(Trait) {
|
|||
}
|
||||
},
|
||||
|
||||
dying: () => {
|
||||
this.entity.addedToPhysics = false;
|
||||
isDyingChanged: (_, isDying) => {
|
||||
this.entity.addedToPhysics = !isDying;
|
||||
},
|
||||
|
||||
positionChanged: () => {
|
||||
|
|
|
@ -250,8 +250,8 @@ export class Animated extends decorate(Trait) {
|
|||
}
|
||||
},
|
||||
|
||||
dying: () => {
|
||||
this.isAnimating = false;
|
||||
isDyingChanged: (_, isDying) => {
|
||||
this.isAnimating = !isDying;
|
||||
},
|
||||
|
||||
visibleScaleChanged: () => {
|
||||
|
|
Loading…
Reference in New Issue
Block a user