UNPKG

isaacscript-common

Version:

Helper functions and features for IsaacScript mods.

51 lines 2.48 kB
import type { CopyableIsaacAPIClassType } from "isaac-typescript-definitions"; import type { ReadonlyRecord } from "../types/ReadonlyRecord"; export type SerializedRNG = LuaMap<string, unknown> & { readonly __serializedRNGBrand: symbol; readonly __kind: CopyableIsaacAPIClassType.RNG; }; /** Helper function to copy an `RNG` Isaac API class. */ export declare function copyRNG(rng: RNG): RNG; /** * Helper function to convert a `SerializedRNG` object to a normal `RNG` object. (This is used by * the save data manager when reading data from the "save#.dat" file.) */ export declare function deserializeRNG(rng: SerializedRNG): RNG; /** * Helper function to get a random `Seed` value to be used in spawning entities and so on. Use this * instead of calling the `Random` function directly since that can return a value of 0 and crash * the game. */ export declare function getRandomSeed(): Seed; /** Helper function to check if something is an instantiated `RNG` object. */ export declare function isRNG(object: unknown): object is RNG; /** * Used to determine is the given table is a serialized `RNG` object created by the `deepCopy` * function. */ export declare function isSerializedRNG(object: unknown): object is SerializedRNG; /** * Helper function to initialize a new RNG object using Blade's recommended shift index. * * @param seed Optional. The seed to initialize it with. Default is a random seed. */ export declare function newRNG(seed?: Seed): RNG; export declare function rngEquals(rng1: RNG, rng2: RNG): boolean; /** * Helper function to convert a `RNG` object to a `SerializedRNG` object. (This is used by the save * data manager when writing data from the "save#.dat" file.) */ export declare function serializeRNG(rng: RNG): SerializedRNG; /** * Helper function to iterate over the provided object and set the seed for all of the values that * are RNG objects equal to a particular seed. */ export declare function setAllRNGToSeed(object: ReadonlyRecord<string, RNG>, seed: Seed): void; /** * Helper function to iterate over the provided object and set the seed for all of the values that * are RNG objects equal to the start seed for the current run. */ export declare function setAllRNGToStartSeed(object: ReadonlyRecord<string, RNG>): void; /** Helper function to set a seed to an RNG object using Blade's recommended shift index. */ export declare function setSeed(rng: RNG, seed: Seed): void; //# sourceMappingURL=rng.d.ts.map