refactor: addTickingPromise

This commit is contained in:
cha0s 2020-01-06 00:38:59 -06:00
parent 18ec713d7f
commit e6f5046b55

View File

@ -38,7 +38,6 @@ export class Vulnerable extends Trait {
constructor(entity, params, state) { constructor(entity, params, state) {
super(entity, params, state); super(entity, params, state);
this.harmTickingPromises = [];
this.harms = []; this.harms = [];
this._isInvulnerable = false; this._isInvulnerable = false;
this.locks = new Map(); this.locks = new Map();
@ -49,7 +48,6 @@ export class Vulnerable extends Trait {
destroy() { destroy() {
this.locks.clear(); this.locks.clear();
this.harmTickingPromises = [];
} }
acceptHarm(harm) { acceptHarm(harm) {
@ -61,7 +59,7 @@ export class Vulnerable extends Trait {
tickingPromise.then(() => { tickingPromise.then(() => {
context.destroy(); context.destroy();
}); });
this.harmTickingPromises.push(tickingPromise); this.entity.addTickingPromise(tickingPromise);
if (harm.from) { if (harm.from) {
harm.from.emitHarmfulParticles(this.entity); harm.from.emitHarmfulParticles(this.entity);
} }
@ -342,9 +340,6 @@ export class Vulnerable extends Trait {
} }
tick(elapsed) { tick(elapsed) {
for (let i = 0; i < this.harmTickingPromises.length; ++i) {
this.harmTickingPromises[i].tick(elapsed);
}
if (AVOCADO_SERVER) { if (AVOCADO_SERVER) {
iterateForEach(this.locks.keys(), (key) => { iterateForEach(this.locks.keys(), (key) => {
const remaining = this.locks.get(key) - elapsed; const remaining = this.locks.get(key) - elapsed;