chromatic-lattice/src/game/state.ts
thepaperpilot f5a25b2c2d Fix NaN detection
Also removes the proxy around player and cleaned up types
2023-02-15 20:21:26 -06:00

28 lines
969 B
TypeScript

import type { DecimalSource } from "util/bignum";
import { shallowReactive } from "vue";
import type { Persistent } from "./persistence";
/** An object of global data that is not persistent. */
export interface Transient {
/** A list of the duration, in ms, of the last 10 game ticks. Used for calculating TPS. */
lastTenTicks: number[];
/** Whether or not a NaN value has been detected and undealt with. */
hasNaN: boolean;
/** The location within the player save data object of the NaN value. */
NaNPath?: string[];
/** The ref that was being set to NaN. */
NaNPersistent?: Persistent<DecimalSource>;
}
declare global {
/** Augment the window object so the transient state can be accessed from the console. */
interface Window {
state: Transient;
}
}
/** The global transient state object. */
export default window.state = shallowReactive<Transient>({
lastTenTicks: [],
hasNaN: false,
NaNPath: []
});