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