1
0
mirror of https://github.com/tobspr/shapez.io.git synced 2025-12-16 03:31:52 +00:00

Fixed achievements not working after reset (May impact performance on large factories)

This commit is contained in:
DJ1TJOO 2021-09-07 15:42:02 +02:00
parent 667e411011
commit 0c5538d626

View File

@ -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