From ac598fa3a7bb95149a7498a6b2628d6c95b1c86f Mon Sep 17 00:00:00 2001 From: thepaperpilot Date: Sat, 12 Mar 2022 15:00:11 -0600 Subject: [PATCH] Added support for resources of non-persistent refs --- src/features/resources/resource.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/features/resources/resource.ts b/src/features/resources/resource.ts index 8f44c31..2946047 100644 --- a/src/features/resources/resource.ts +++ b/src/features/resources/resource.ts @@ -1,5 +1,5 @@ import Decimal, { DecimalSource, format, formatWhole } from "util/bignum"; -import { computed, ComputedRef, ref, Ref, watch } from "vue"; +import { computed, ComputedRef, isRef, ref, Ref, watch } from "vue"; import { globalBus } from "game/events"; import { State, persistent } from "game/persistence"; @@ -15,7 +15,9 @@ export function createResource( precision = 0, small = undefined ): Resource { - const resource: Partial> = persistent(defaultValue); + const resource: Partial> = isRef(defaultValue) + ? defaultValue + : persistent(defaultValue); resource.displayName = displayName; resource.precision = precision; resource.small = small;