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