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 {
|
export default class ApplyControlMovement extends System {
|
||||||
|
|
||||||
static queries() {
|
|
||||||
return {
|
|
||||||
default: ['Controlled', 'Momentum', 'Speed'],
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
tick() {
|
tick() {
|
||||||
for (const [Controlled, Momentum, Speed] of this.select('default')) {
|
const {diff} = this.ecs;
|
||||||
Momentum.x = Speed.speed * (Controlled.moveRight - Controlled.moveLeft);
|
for (const id in diff) {
|
||||||
Momentum.y = Speed.speed * (Controlled.moveDown - Controlled.moveUp);
|
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