refactor: diff-based
This commit is contained in:
parent
493bf025f0
commit
18734debff
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user