From 0c5538d626b0ddaa3d5d367b5a3db0efc3516fc3 Mon Sep 17 00:00:00 2001 From: DJ1TJOO Date: Tue, 7 Sep 2021 15:42:02 +0200 Subject: [PATCH] Fixed achievements not working after reset (May impact performance on large factories) --- src/js/game/shape_definition_manager.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/js/game/shape_definition_manager.js b/src/js/game/shape_definition_manager.js index 89203f1e..c5ee2fd3 100644 --- a/src/js/game/shape_definition_manager.js +++ b/src/js/game/shape_definition_manager.js @@ -90,6 +90,8 @@ export class ShapeDefinitionManager extends BasicSerializableObject { * @returns {[ShapeDefinition, ShapeDefinition]} */ shapeActionCutHalf(definition) { + this.root.signals.achievementCheck.dispatch(ACHIEVEMENTS.cutShape, null); + const key = "cut/" + definition.getHash(); if (this.operationCache[key]) { return /** @type {[ShapeDefinition, ShapeDefinition]} */ (this.operationCache[key]); @@ -97,8 +99,6 @@ export class ShapeDefinitionManager extends BasicSerializableObject { const rightSide = definition.cloneFilteredByQuadrants([2, 3]); const leftSide = definition.cloneFilteredByQuadrants([0, 1]); - this.root.signals.achievementCheck.dispatch(ACHIEVEMENTS.cutShape, null); - return /** @type {[ShapeDefinition, ShapeDefinition]} */ (this.operationCache[key] = [ this.registerOrReturnHandle(rightSide), this.registerOrReturnHandle(leftSide), @@ -133,6 +133,8 @@ export class ShapeDefinitionManager extends BasicSerializableObject { * @returns {ShapeDefinition} */ shapeActionRotateCW(definition) { + this.root.signals.achievementCheck.dispatch(ACHIEVEMENTS.rotateShape, null); + const key = "rotate-cw/" + definition.getHash(); if (this.operationCache[key]) { return /** @type {ShapeDefinition} */ (this.operationCache[key]); @@ -140,8 +142,6 @@ export class ShapeDefinitionManager extends BasicSerializableObject { const rotated = definition.cloneRotateCW(); - this.root.signals.achievementCheck.dispatch(ACHIEVEMENTS.rotateShape, null); - return /** @type {ShapeDefinition} */ (this.operationCache[key] = this.registerOrReturnHandle( rotated )); @@ -190,13 +190,13 @@ export class ShapeDefinitionManager extends BasicSerializableObject { * @returns {ShapeDefinition} */ shapeActionStack(lowerDefinition, upperDefinition) { + this.root.signals.achievementCheck.dispatch(ACHIEVEMENTS.stackShape, null); + const key = "stack/" + lowerDefinition.getHash() + "/" + upperDefinition.getHash(); if (this.operationCache[key]) { return /** @type {ShapeDefinition} */ (this.operationCache[key]); } - this.root.signals.achievementCheck.dispatch(ACHIEVEMENTS.stackShape, null); - const stacked = lowerDefinition.cloneAndStackWith(upperDefinition); return /** @type {ShapeDefinition} */ (this.operationCache[key] = this.registerOrReturnHandle( stacked @@ -210,13 +210,13 @@ export class ShapeDefinitionManager extends BasicSerializableObject { * @returns {ShapeDefinition} */ shapeActionPaintWith(definition, color) { + this.root.signals.achievementCheck.dispatch(ACHIEVEMENTS.paintShape, null); + const key = "paint/" + definition.getHash() + "/" + color; if (this.operationCache[key]) { return /** @type {ShapeDefinition} */ (this.operationCache[key]); } - this.root.signals.achievementCheck.dispatch(ACHIEVEMENTS.paintShape, null); - const colorized = definition.cloneAndPaintWith(color); return /** @type {ShapeDefinition} */ (this.operationCache[key] = this.registerOrReturnHandle( colorized