Make sure we don't double-buffer an input causing undo to become stuck

This commit is contained in:
Logan Hunt 2022-04-10 22:21:38 -06:00
parent 69b5f4448c
commit 1bdfb42c3d

View File

@ -11,6 +11,7 @@ game.system.KeyboardInput = (undoSystem) => {
const entity = entities[id]; const entity = entities[id];
if (entity.hasComponent('controllable')) { if (entity.hasComponent('controllable')) {
const controls = entity.components.controllable.controls; const controls = entity.components.controllable.controls;
if (!changedIds.has(entity.id)) {
if (controls.includes('left') && keys['ArrowLeft']) { if (controls.includes('left') && keys['ArrowLeft']) {
entity.addComponent(game.components.Momentum({ dx: -1, dy: 0 })); entity.addComponent(game.components.Momentum({ dx: -1, dy: 0 }));
} else if (controls.includes('right') && keys['ArrowRight']) { } else if (controls.includes('right') && keys['ArrowRight']) {
@ -22,6 +23,7 @@ game.system.KeyboardInput = (undoSystem) => {
} }
} }
} }
}
if (keys['z']) { if (keys['z']) {
undoSystem.undo(entities); undoSystem.undo(entities);
} }