From 12438b67b35415e28a46e279194ba709d1b0b10e Mon Sep 17 00:00:00 2001 From: thepaperpilot Date: Sun, 27 Feb 2022 18:07:21 -0600 Subject: [PATCH] Added some logic to reduce redundancies in player data --- src/data/mod.tsx | 3 +-- src/game/persistence.ts | 12 +++++++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/data/mod.tsx b/src/data/mod.tsx index 278624c..ad0600d 100644 --- a/src/data/mod.tsx +++ b/src/data/mod.tsx @@ -46,8 +46,7 @@ export const main = createLayer(() => { style: { filter: "blur(5px)" } - }, - { startNode: c.treeNode, endNode: c.g } + } ], onReset() { points.value = toRaw(this.resettingNode.value) === toRaw(c.treeNode) ? 0 : 10; diff --git a/src/game/persistence.ts b/src/game/persistence.ts index f8d2e80..110e238 100644 --- a/src/game/persistence.ts +++ b/src/game/persistence.ts @@ -48,6 +48,7 @@ export function makePersistent( } globalBus.on("addLayer", (layer: GenericLayer, saveData: Record) => { + const features: { type: typeof Symbol }[] = []; const handleObject = (obj: Record, path: string[] = []): boolean => { let foundPersistent = false; Object.keys(obj).forEach(key => { @@ -76,7 +77,16 @@ globalBus.on("addLayer", (layer: GenericLayer, saveData: Record DefaultValue ]; } - } else if (!(value instanceof Decimal) && !isRef(value)) { + } else if ( + !(value instanceof Decimal) && + !isRef(value) && + // eslint-disable-next-line @typescript-eslint/no-explicit-any + !features.includes(value as { type: typeof Symbol }) + ) { + if (typeof (value as { type: typeof Symbol }).type === "symbol") { + features.push(value as { type: typeof Symbol }); + } + // Continue traversing const foundPersistentInChild = handleObject(value as Record, [ ...path,