refactor: moveFor takes vector
This commit is contained in:
parent
e0cdf94df5
commit
8803402f43
|
@ -29,8 +29,7 @@ export class Mobile extends decorate(Trait) {
|
||||||
methods() {
|
methods() {
|
||||||
return {
|
return {
|
||||||
|
|
||||||
moveFor: (duration) => {
|
moveFor: (vector, duration) => {
|
||||||
const direction = this.entity.direction;
|
|
||||||
let resolve;
|
let resolve;
|
||||||
const promise = new TickingPromise(_resolve => resolve = _resolve);
|
const promise = new TickingPromise(_resolve => resolve = _resolve);
|
||||||
promise.ticker = (elapsed) => {
|
promise.ticker = (elapsed) => {
|
||||||
|
@ -38,7 +37,7 @@ export class Mobile extends decorate(Trait) {
|
||||||
if (duration <= 0) {
|
if (duration <= 0) {
|
||||||
return resolve();
|
return resolve();
|
||||||
}
|
}
|
||||||
this.entity.requestMovement(Vector.fromDirection(direction));
|
this.entity.requestMovement(Vector.normalize(vector));
|
||||||
}
|
}
|
||||||
return promise;
|
return promise;
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue
Block a user