performance: save work on client
This commit is contained in:
parent
19eceb06a6
commit
b750ffd0ff
|
@ -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', () => {
|
||||
|
|
Loading…
Reference in New Issue
Block a user