feat: explicit directional movement tracking
This commit is contained in:
parent
1afc3609e4
commit
d250d94f3b
|
@ -14,6 +14,7 @@ class DirectionalBase extends Trait {
|
|||
static defaultParams() {
|
||||
return {
|
||||
directionCount: 1,
|
||||
trackMovement: true,
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -23,15 +24,19 @@ class DirectionalBase extends Trait {
|
|||
};
|
||||
}
|
||||
|
||||
listeners() {
|
||||
return {
|
||||
movementRequest: (vector) => {
|
||||
this.entity.direction = Vector.toDirection(
|
||||
vector,
|
||||
this.params.get('directionCount')
|
||||
);
|
||||
},
|
||||
constructor(entity, params, state) {
|
||||
super(...arguments);
|
||||
this.directionCount = this.params.get('directionCount');
|
||||
}
|
||||
|
||||
listeners() {
|
||||
const listeners = {};
|
||||
if (this.params.get('trackMovement')) {
|
||||
listeners.movementRequest = (vector) => {
|
||||
this.entity.direction = Vector.toDirection(vector, this.directionCount);
|
||||
};
|
||||
}
|
||||
return listeners;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user