fix: prop conflict

This commit is contained in:
cha0s 2021-02-07 00:40:24 -06:00
parent 80568bc83b
commit 458dac7f50

View File

@ -10,7 +10,7 @@ import {
const decorate = compose(
EventEmitter,
Vector.Mixin('movement', 'x', 'y', {
Vector.Mixin('controllableMovement', 'controllableMovementX', 'controllableMovementY', {
track: true,
}),
);
@ -24,7 +24,7 @@ export default () => class Controllable extends decorate(Trait) {
constructor() {
super();
this.on('movementChanged', this.updateAnimation, this);
this.on('controllableMovementChanged', this.updateAnimation, this);
}
static dependencies() {
@ -52,16 +52,16 @@ export default () => class Controllable extends decorate(Trait) {
this.entity.activeSlotIndex = (this.entity.activeSlotIndex + 9) % 10;
break;
case 'MoveUp':
this.y -= normalized;
this.controllableMovementY -= normalized;
break;
case 'MoveRight':
this.x += normalized;
this.controllableMovementX += normalized;
break;
case 'MoveDown':
this.y += normalized;
this.controllableMovementY += normalized;
break;
case 'MoveLeft':
this.x -= normalized;
this.controllableMovementX -= normalized;
break;
case 'UseItem':
if ('client' !== process.env.SIDE) {
@ -88,13 +88,13 @@ export default () => class Controllable extends decorate(Trait) {
if (this.#itemPromise && this.#itemPromise instanceof TickingPromise) {
this.#itemPromise.tick(elapsed);
}
if (this.entity.isMobile && !Vector.isZero(this.movement)) {
this.entity.requestMovement(this.movement);
if (this.entity.isMobile && !Vector.isZero(this.controllableMovement)) {
this.entity.requestMovement(this.controllableMovement);
}
}
updateAnimation() {
if (!this.entity.isMobile || Vector.isZero(this.movement)) {
if (!this.entity.isMobile || Vector.isZero(this.controllableMovement)) {
this.entity.currentAnimation = 'idle';
}
else {