forked from profectus/Profectus
Fix some persistence issues
This commit is contained in:
parent
d4f0069dd5
commit
0991ef0865
3 changed files with 16 additions and 2 deletions
|
@ -160,6 +160,9 @@ export function createAchievement<T extends AchievementOptions>(
|
||||||
|
|
||||||
achievement.earned = earned;
|
achievement.earned = earned;
|
||||||
achievement.complete = function () {
|
achievement.complete = function () {
|
||||||
|
if (earned.value) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
earned.value = true;
|
earned.value = true;
|
||||||
const genericAchievement = achievement as GenericAchievement;
|
const genericAchievement = achievement as GenericAchievement;
|
||||||
genericAchievement.onComplete?.();
|
genericAchievement.onComplete?.();
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
import type { OptionsFunc, Replace } from "features/feature";
|
import type { OptionsFunc, Replace } from "features/feature";
|
||||||
import { getUniqueID } from "features/feature";
|
import { getUniqueID } from "features/feature";
|
||||||
import { globalBus } from "game/events";
|
import { globalBus } from "game/events";
|
||||||
|
import Formula from "game/formulas/formulas";
|
||||||
import type { BaseLayer } from "game/layers";
|
import type { BaseLayer } from "game/layers";
|
||||||
import type { NonPersistent, Persistent } from "game/persistence";
|
import { NonPersistent, Persistent, SkipPersistence } from "game/persistence";
|
||||||
import { DefaultValue, persistent } from "game/persistence";
|
import { DefaultValue, persistent } from "game/persistence";
|
||||||
import type { Unsubscribe } from "nanoevents";
|
import type { Unsubscribe } from "nanoevents";
|
||||||
import Decimal from "util/bignum";
|
import Decimal from "util/bignum";
|
||||||
|
@ -61,7 +62,15 @@ export function createReset<T extends ResetOptions>(
|
||||||
|
|
||||||
reset.reset = function () {
|
reset.reset = function () {
|
||||||
const handleObject = (obj: unknown) => {
|
const handleObject = (obj: unknown) => {
|
||||||
if (obj != null && typeof obj === "object") {
|
if (
|
||||||
|
obj != null &&
|
||||||
|
typeof obj === "object" &&
|
||||||
|
!(obj instanceof Decimal) &&
|
||||||
|
!(obj instanceof Formula)
|
||||||
|
) {
|
||||||
|
if (SkipPersistence in obj && obj[SkipPersistence] === true) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (DefaultValue in obj) {
|
if (DefaultValue in obj) {
|
||||||
const persistent = obj as NonPersistent;
|
const persistent = obj as NonPersistent;
|
||||||
persistent.value = persistent[DefaultValue];
|
persistent.value = persistent[DefaultValue];
|
||||||
|
|
|
@ -9,6 +9,7 @@ import type { Ref, WritableComputedRef } from "vue";
|
||||||
import { computed, isReactive, isRef, ref } from "vue";
|
import { computed, isReactive, isRef, ref } from "vue";
|
||||||
import player from "./player";
|
import player from "./player";
|
||||||
import state from "./state";
|
import state from "./state";
|
||||||
|
import Formula from "./formulas/formulas";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A symbol used in {@link Persistent} objects.
|
* A symbol used in {@link Persistent} objects.
|
||||||
|
@ -325,6 +326,7 @@ globalBus.on("addLayer", (layer: GenericLayer, saveData: Record<string, unknown>
|
||||||
}
|
}
|
||||||
} else if (
|
} else if (
|
||||||
!(value instanceof Decimal) &&
|
!(value instanceof Decimal) &&
|
||||||
|
!(value instanceof Formula) &&
|
||||||
!isRef(value) &&
|
!isRef(value) &&
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
!features.includes(value as { type: typeof Symbol })
|
!features.includes(value as { type: typeof Symbol })
|
||||||
|
|
Loading…
Reference in a new issue