refactor: diff-based

This commit is contained in:
cha0s 2024-06-21 02:33:47 -05:00
parent 493bf025f0
commit 18734debff

View File

@ -2,16 +2,14 @@ import {System} from '@/ecs/index.js';
export default class ApplyControlMovement extends System {
static queries() {
return {
default: ['Controlled', 'Momentum', 'Speed'],
};
}
tick() {
for (const [Controlled, Momentum, Speed] of this.select('default')) {
Momentum.x = Speed.speed * (Controlled.moveRight - Controlled.moveLeft);
Momentum.y = Speed.speed * (Controlled.moveDown - Controlled.moveUp);
const {diff} = this.ecs;
for (const id in diff) {
if (diff[id].Controlled) {
const {Controlled, Momentum, Speed} = this.ecs.get(id);
Momentum.x = Speed.speed * (Controlled.moveRight - Controlled.moveLeft);
Momentum.y = Speed.speed * (Controlled.moveDown - Controlled.moveUp);
}
}
}