Forgot about that. Whoops

This commit is contained in:
Logan Hunt 2022-04-10 23:02:02 -06:00
parent 1bdfb42c3d
commit ec7b01918c

View File

@ -3,7 +3,6 @@ game.system.Undo = (entitiesGrid) => {
const update = (elapsedTime, entities, changedIds) => { const update = (elapsedTime, entities, changedIds) => {
if (changedIds.size) { if (changedIds.size) {
lastUndid = false;
const state = {}; const state = {};
for (let id in entities) { for (let id in entities) {
if (entities[id].hasComponent("gridPosition")) { if (entities[id].hasComponent("gridPosition")) {
@ -16,16 +15,15 @@ game.system.Undo = (entitiesGrid) => {
} }
const undo = (entities) => { const undo = (entities) => {
states.map((state) => console.log(state[65].gridPosition));
let state = states.slice(0, -1).pop(); let state = states.slice(0, -1).pop();
if (states.length > 1) {
states.pop();
}
for (let id in state) { for (let id in state) {
for (let componentName in state[id]) { for (let componentName in state[id]) {
entities[id].addComponent({name: componentName, ...state[id][componentName]}); entities[id].addComponent({name: componentName, ...state[id][componentName]});
} }
} }
if (states.length > 1) {
states.pop();
}
} }
return { update, undo }; return { update, undo };