forked from profectus/Profectus
Fixed issue with dynamically loading layers
This commit is contained in:
parent
d09126e84c
commit
bd084e51c5
1 changed files with 14 additions and 6 deletions
|
@ -2,7 +2,7 @@ import { globalBus } from "game/events";
|
||||||
import Decimal, { DecimalSource } from "util/bignum";
|
import Decimal, { DecimalSource } from "util/bignum";
|
||||||
import { ProxyState } from "util/proxies";
|
import { ProxyState } from "util/proxies";
|
||||||
import { isArray } from "@vue/shared";
|
import { isArray } from "@vue/shared";
|
||||||
import { isRef, Ref, ref } from "vue";
|
import { isReactive, isRef, Ref, ref } from "vue";
|
||||||
import { GenericLayer } from "./layers";
|
import { GenericLayer } from "./layers";
|
||||||
|
|
||||||
export const PersistentState = Symbol("PersistentState");
|
export const PersistentState = Symbol("PersistentState");
|
||||||
|
@ -70,12 +70,20 @@ globalBus.on("addLayer", (layer: GenericLayer, saveData: Record<string, unknown>
|
||||||
// Add ref to save data
|
// Add ref to save data
|
||||||
persistentState[key] = (value as Persistent)[PersistentState];
|
persistentState[key] = (value as Persistent)[PersistentState];
|
||||||
// Load previously saved value
|
// Load previously saved value
|
||||||
if (savedValue != null) {
|
if (isReactive(persistentState)) {
|
||||||
(persistentState[key] as Ref<unknown>).value = savedValue;
|
if (savedValue != null) {
|
||||||
|
persistentState[key] = savedValue;
|
||||||
|
} else {
|
||||||
|
persistentState[key] = (value as Persistent)[DefaultValue];
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
(persistentState[key] as Ref<unknown>).value = (value as Persistent)[
|
if (savedValue != null) {
|
||||||
DefaultValue
|
(persistentState[key] as Ref<unknown>).value = savedValue;
|
||||||
];
|
} else {
|
||||||
|
(persistentState[key] as Ref<unknown>).value = (value as Persistent)[
|
||||||
|
DefaultValue
|
||||||
|
];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if (
|
} else if (
|
||||||
!(value instanceof Decimal) &&
|
!(value instanceof Decimal) &&
|
||||||
|
|
Loading…
Reference in a new issue