From 42fe27f0a351330cf765a9d267e498bc6f4794e9 Mon Sep 17 00:00:00 2001 From: cha0s Date: Fri, 19 Jun 2020 15:30:45 -0500 Subject: [PATCH] refactor: simplify --- packages/entity/traits/alive.trait.js | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/packages/entity/traits/alive.trait.js b/packages/entity/traits/alive.trait.js index f8f2f04..afea412 100644 --- a/packages/entity/traits/alive.trait.js +++ b/packages/entity/traits/alive.trait.js @@ -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(); + } } }