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