perf: remove extraneous check

This commit is contained in:
cha0s 2019-05-02 22:18:30 -05:00
parent 0f1bf3df59
commit ed33d9c90d

View File

@ -94,13 +94,6 @@ export class Visible extends decorate(Trait) {
this.entity.visibleScale = I.List(scale); this.entity.visibleScale = I.List(scale);
} }
shouldSynchronizePosition() {
if (!this._container) {
return false;
}
return this._container && this.trackPosition;
}
synchronizePosition() { synchronizePosition() {
if (!this.entity.is('positioned')) { if (!this.entity.is('positioned')) {
return; return;
@ -133,7 +126,7 @@ export class Visible extends decorate(Trait) {
} }
listeners() { listeners() {
const listeners = { return {
isVisibleChanged: () => { isVisibleChanged: () => {
if (!this._container) { if (!this._container) {
@ -153,6 +146,16 @@ export class Visible extends decorate(Trait) {
this.translateVisibleAabb(); this.translateVisibleAabb();
}, },
traitAdded: (type) => {
if (-1 === [
'visible',
'positioned',
].indexOf(type)) {
return;
}
this.synchronizePosition();
},
visibleScaleChanged: () => { visibleScaleChanged: () => {
const scale = this.entity.visibleScale; const scale = this.entity.visibleScale;
this._visibleScale = [scale.get(0), scale.get(1)]; this._visibleScale = [scale.get(0), scale.get(1)];
@ -163,18 +166,6 @@ export class Visible extends decorate(Trait) {
}, },
}; };
if (this.shouldSynchronizePosition()) {
listeners.traitAdded = (type) => {
if (-1 === [
'visible',
'positioned',
].indexOf(type)) {
return;
}
this.synchronizePosition();
};
}
return listeners;
} }
methods() { methods() {
@ -188,10 +179,8 @@ export class Visible extends decorate(Trait) {
} }
renderTick(elapsed) { renderTick(elapsed) {
if (this.shouldSynchronizePosition()) {
this.synchronizePosition(); this.synchronizePosition();
} }
}
translateVisibleAabb() { translateVisibleAabb() {
this.visibleAabb = Rectangle.translated( this.visibleAabb = Rectangle.translated(