refactor: proper private variables
This commit is contained in:
parent
9a6f756014
commit
3320999693
|
@ -27,16 +27,22 @@ const decorate = compose(
|
|||
|
||||
export default (latus) => class Alive extends decorate(Trait) {
|
||||
|
||||
#context;
|
||||
|
||||
#deathActions;
|
||||
|
||||
#deathCondition;
|
||||
|
||||
constructor(...args) {
|
||||
super(...args);
|
||||
this._context = new Context(
|
||||
this.#context = new Context(
|
||||
{
|
||||
entity: [this.entity, 'entity'],
|
||||
},
|
||||
latus,
|
||||
);
|
||||
this._deathActions = new Actions(compile(this.params.deathActions, latus));
|
||||
this._deathCondition = compile(this.params.deathCondition, latus);
|
||||
this.#deathActions = new Actions(compile(this.params.deathActions, latus));
|
||||
this.#deathCondition = compile(this.params.deathCondition, latus);
|
||||
}
|
||||
|
||||
acceptPacket(packet) {
|
||||
|
@ -141,7 +147,7 @@ export default (latus) => class Alive extends decorate(Trait) {
|
|||
}
|
||||
|
||||
destroy() {
|
||||
this._context.destroy();
|
||||
this.#context.destroy();
|
||||
}
|
||||
|
||||
get life() {
|
||||
|
@ -180,7 +186,7 @@ export default (latus) => class Alive extends decorate(Trait) {
|
|||
return;
|
||||
}
|
||||
this.entity.isDying = true;
|
||||
await this.entity.addTickingPromise(this._deathActions.tickingPromise(this._context));
|
||||
await this.entity.addTickingPromise(this.#deathActions.tickingPromise(this.#context));
|
||||
await Promise.all(this.entity.invokeHookFlat('died'));
|
||||
this.entity.destroy();
|
||||
},
|
||||
|
@ -208,7 +214,7 @@ export default (latus) => class Alive extends decorate(Trait) {
|
|||
|
||||
tick() {
|
||||
if ('client' !== SIDE) {
|
||||
if (!this.entity.isDying && this._deathCondition(this._context)) {
|
||||
if (!this.entity.isDying && this.#deathCondition(this.#context)) {
|
||||
this.entity.forceDeath();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user