refactor: simplify

This commit is contained in:
cha0s 2020-06-19 15:30:45 -05:00
parent 84affcbc64
commit 42fe27f0a3

View File

@ -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();
}
}
}