refactor: item input
This commit is contained in:
parent
10267f2146
commit
0f08de7872
|
@ -1,17 +0,0 @@
|
||||||
import {System} from '@/ecs/index.js';
|
|
||||||
|
|
||||||
export default class ApplyControlMovement extends System {
|
|
||||||
|
|
||||||
tick() {
|
|
||||||
const {diff} = this.ecs;
|
|
||||||
for (const id in diff) {
|
|
||||||
if ('changeSlot' in (diff[id].Controlled ?? {})) {
|
|
||||||
if (diff[id].Controlled.changeSlot > 0) {
|
|
||||||
this.ecs.get(id).Wielder.activeSlot = diff[id].Controlled.changeSlot - 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
|
@ -81,7 +81,6 @@ export default class Engine {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const defaultSystems = [
|
const defaultSystems = [
|
||||||
'ApplyControlItem',
|
|
||||||
'ApplyControlMovement',
|
'ApplyControlMovement',
|
||||||
'ApplyMomentum',
|
'ApplyMomentum',
|
||||||
'ClampPositions',
|
'ClampPositions',
|
||||||
|
@ -185,9 +184,19 @@ export default class Engine {
|
||||||
for (const i in this.ecses) {
|
for (const i in this.ecses) {
|
||||||
this.ecses[i].setClean();
|
this.ecses[i].setClean();
|
||||||
}
|
}
|
||||||
// TODO: SANITIZE
|
for (const [{Controlled, Wielder}, payload] of this.incomingActions) {
|
||||||
for (const [{Controlled}, payload] of this.incomingActions) {
|
switch (payload.type) {
|
||||||
Controlled[payload.type] = payload.value;
|
case 'moveUp':
|
||||||
|
case 'moveRight':
|
||||||
|
case 'moveDown':
|
||||||
|
case 'moveLeft': {
|
||||||
|
Controlled[payload.type] = payload.value;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'changeSlot': {
|
||||||
|
Wielder.activeSlot = payload.value - 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
this.incomingActions = [];
|
this.incomingActions = [];
|
||||||
for (const i in this.ecses) {
|
for (const i in this.ecses) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user