27 lines
583 B
JavaScript
27 lines
583 B
JavaScript
import {System} from '@/ecs/index.js';
|
|
|
|
export default class ApplyControlMovement extends System {
|
|
|
|
static get priority() {
|
|
return {
|
|
before: 'ApplyForces',
|
|
};
|
|
}
|
|
|
|
static queries() {
|
|
return {
|
|
default: ['Controlled', 'Forces', 'Speed'],
|
|
};
|
|
}
|
|
tick() {
|
|
for (const {Controlled, Forces, Speed} of this.select('default')) {
|
|
if (!Controlled.locked) {
|
|
Forces.impulseX += Speed.speed * (Controlled.moveRight - Controlled.moveLeft);
|
|
Forces.impulseY += Speed.speed * (Controlled.moveDown - Controlled.moveUp);
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
|