From 8803402f43fd79b10ad88c93422e2744c41bcb1c Mon Sep 17 00:00:00 2001 From: cha0s Date: Wed, 5 Jun 2019 23:11:59 -0500 Subject: [PATCH] refactor: moveFor takes vector --- packages/entity/traits/mobile.trait.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/entity/traits/mobile.trait.js b/packages/entity/traits/mobile.trait.js index c22d063..1621997 100644 --- a/packages/entity/traits/mobile.trait.js +++ b/packages/entity/traits/mobile.trait.js @@ -29,8 +29,7 @@ export class Mobile extends decorate(Trait) { methods() { return { - moveFor: (duration) => { - const direction = this.entity.direction; + moveFor: (vector, duration) => { let resolve; const promise = new TickingPromise(_resolve => resolve = _resolve); promise.ticker = (elapsed) => { @@ -38,7 +37,7 @@ export class Mobile extends decorate(Trait) { if (duration <= 0) { return resolve(); } - this.entity.requestMovement(Vector.fromDirection(direction)); + this.entity.requestMovement(Vector.normalize(vector)); } return promise; },