refactor: simplify
This commit is contained in:
parent
84affcbc64
commit
42fe27f0a3
|
@ -165,20 +165,12 @@ export default class Alive extends decorate(Trait) {
|
|||
methods() {
|
||||
return {
|
||||
|
||||
dieIfPrescribed: () => {
|
||||
if (this._deathCondition.check(this._context)) {
|
||||
this.entity.forceDeath();
|
||||
}
|
||||
},
|
||||
|
||||
forceDeath: () => {
|
||||
if (this.entity.isDying) {
|
||||
return;
|
||||
}
|
||||
this.entity.isDying = true;
|
||||
const dyingTickingPromise = this._deathActions.tickingPromise(
|
||||
this._context
|
||||
)
|
||||
const dyingTickingPromise = this._deathActions.tickingPromise(this._context);
|
||||
this.entity.addTickingPromise(dyingTickingPromise).then(() => {
|
||||
const diedPromises = this.entity.invokeHookFlat('died');
|
||||
Promise.all(diedPromises).then(() => {
|
||||
|
@ -192,7 +184,9 @@ export default class Alive extends decorate(Trait) {
|
|||
|
||||
tick(elapsed) {
|
||||
if (AVOCADO_SERVER) {
|
||||
this.entity.dieIfPrescribed();
|
||||
if (!this.entity.isDying && this._deathCondition.check(this._context)) {
|
||||
this.entity.forceDeath();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user