refactor: always use Trait::initialize
This commit is contained in:
parent
3b50c134d0
commit
2952e4edf4
|
@ -27,8 +27,7 @@ class AnimatedBase extends Trait {
|
|||
};
|
||||
}
|
||||
|
||||
constructor(entity, params, state) {
|
||||
super(...arguments);
|
||||
initialize() {
|
||||
this.sprite = undefined;
|
||||
this.frameCount = this.params.get('frameCount');
|
||||
this.frameRate = this.params.get('frameRate');
|
||||
|
@ -49,7 +48,7 @@ class AnimatedBase extends Trait {
|
|||
}
|
||||
|
||||
loadSpriteImageIfPossible() {
|
||||
if (!('container' in this.entity)) {
|
||||
if (!this.entity.container) {
|
||||
return;
|
||||
}
|
||||
if (!this.image) {
|
||||
|
|
|
@ -24,8 +24,7 @@ class DirectionalBase extends Trait {
|
|||
};
|
||||
}
|
||||
|
||||
constructor(entity, params, state) {
|
||||
super(...arguments);
|
||||
initialize() {
|
||||
this.directionCount = this.params.get('directionCount');
|
||||
}
|
||||
|
||||
|
|
|
@ -8,11 +8,6 @@ const decorate = compose(
|
|||
|
||||
class ExistentBase extends Trait {
|
||||
|
||||
constructor(...args) {
|
||||
super(...args);
|
||||
this._isTicking = this.params.get('isTicking');
|
||||
}
|
||||
|
||||
static defaultParams() {
|
||||
return {
|
||||
isTicking: true,
|
||||
|
@ -25,6 +20,10 @@ class ExistentBase extends Trait {
|
|||
};
|
||||
}
|
||||
|
||||
initialize() {
|
||||
this._isTicking = this.params.get('isTicking');
|
||||
}
|
||||
|
||||
get isTicking() {
|
||||
return this._isTicking;
|
||||
}
|
||||
|
|
|
@ -14,15 +14,11 @@ class GraphicalBase extends Trait {
|
|||
};
|
||||
}
|
||||
|
||||
constructor(...args) {
|
||||
super(...args);
|
||||
initialize() {
|
||||
if (hasGraphics) {
|
||||
this._container = new Container();
|
||||
}
|
||||
this.trackPosition = this.params.get('trackPosition');
|
||||
}
|
||||
|
||||
initialize() {
|
||||
if (this.shouldSynchronizePosition()) {
|
||||
this.synchronizePosition();
|
||||
}
|
||||
|
@ -33,12 +29,14 @@ class GraphicalBase extends Trait {
|
|||
}
|
||||
|
||||
shouldSynchronizePosition() {
|
||||
return hasGraphics && this.trackPosition && 'position' in this.entity;
|
||||
return hasGraphics && this.trackPosition;
|
||||
}
|
||||
|
||||
synchronizePosition() {
|
||||
if ('position' in this.entity) {
|
||||
this.entity.container.position = this.entity.position;
|
||||
}
|
||||
}
|
||||
|
||||
listeners() {
|
||||
const listeners = {};
|
||||
|
|
|
@ -17,8 +17,7 @@ class MobileBase extends Trait {
|
|||
};
|
||||
}
|
||||
|
||||
constructor(...args) {
|
||||
super(...args);
|
||||
initialize() {
|
||||
this.requestedMovement = [0, 0];
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user