refactor: moveFor takes vector
This commit is contained in:
parent
e0cdf94df5
commit
8803402f43
|
@ -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;
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue
Block a user