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