refactor: moveFor takes vector

This commit is contained in:
cha0s 2019-06-05 23:11:59 -05:00
parent e0cdf94df5
commit 8803402f43

View File

@ -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;
},