Added some logic to reduce redundancies in player data

This commit is contained in:
thepaperpilot 2022-02-27 18:07:21 -06:00
parent 690b963afd
commit 12438b67b3
2 changed files with 12 additions and 3 deletions

View file

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

View file

@ -48,6 +48,7 @@ export function makePersistent<T extends State>(
}
globalBus.on("addLayer", (layer: GenericLayer, saveData: Record<string, unknown>) => {
const features: { type: typeof Symbol }[] = [];
const handleObject = (obj: Record<string, unknown>, path: string[] = []): boolean => {
let foundPersistent = false;
Object.keys(obj).forEach(key => {
@ -76,7 +77,16 @@ globalBus.on("addLayer", (layer: GenericLayer, saveData: Record<string, unknown>
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<string, unknown>, [
...path,