performance: save work on client

This commit is contained in:
cha0s 2019-04-23 03:24:16 -05:00
parent 19eceb06a6
commit b750ffd0ff

View File

@ -26,12 +26,14 @@ class PositionedBase extends Trait {
initialize() {
this.on('_positionChanged', (oldPosition, newPosition) => {
const x = Math.floor(newPosition[0]) * 4;
const y = Math.floor(newPosition[1]) * 4;
this.state = this.state.withMutations((state) => {
state.set('x', x).set('y', y);
});
this.isDirty = true;
if (AVOCADO_SERVER) {
const x = Math.floor(newPosition[0]) * 4;
const y = Math.floor(newPosition[1]) * 4;
this.state = this.state.withMutations((state) => {
state.set('x', x).set('y', y);
});
this.isDirty = true;
}
this.entity.emit('positionChanged', oldPosition, newPosition);
});
this.on('serverPositionChanged', () => {