isaacscript-common
Version:
Helper functions and features for IsaacScript mods.
69 lines • 3.72 kB
TypeScript
import type { DoorSlotFlag } from "isaac-typescript-definitions";
import type { JSONEntity, JSONRoom } from "../interfaces/JSONRoomsFile";
/**
* Helper function to calculate what the resulting `BitFlags<DoorSlotFlag>` value would be for a
* given JSON room.
*
* (A JSON room is an XML file converted to JSON so that it can be directly imported into your mod.)
*/
export declare function getJSONRoomDoorSlotFlags(jsonRoom: JSONRoom): BitFlags<DoorSlotFlag>;
/**
* Helper function to find a specific room from an array of JSON rooms.
*
* (A JSON room is an XML file converted to JSON so that it can be directly imported into your mod.)
*
* @param jsonRooms The array of rooms to search through.
* @param variant The room variant to select. (The room variant can be thought of as the ID of the
* room.)
*/
export declare function getJSONRoomOfVariant(jsonRooms: readonly JSONRoom[], variant: int): JSONRoom | undefined;
/**
* Helper function to find all of the JSON rooms that match the sub-type provided.
*
* (A JSON room is an XML file converted to JSON so that it can be directly imported into your mod.)
*
* @param jsonRooms The array of rooms to search through.
* @param subType The sub-type to match.
*/
export declare function getJSONRoomsOfSubType(jsonRooms: readonly JSONRoom[], subType: int): readonly JSONRoom[];
/**
* Helper function to get a random JSON entity from an array of JSON entities.
*
* (A JSON entity is an entity inside of a JSON room. A JSON room is an XML file converted to JSON
* so that it can be directly imported into your mod.)
*
* Note that this function does not simply choose a random element in the provided array; it will
* properly account for each room weight using the algorithm from:
* https://stackoverflow.com/questions/1761626/weighted-random-numbers
*
* If you want an unseeded entity, you must explicitly pass `undefined` to the `seedOrRNG`
* parameter.
*
* @param jsonEntities The array of entities to randomly choose between.
* @param seedOrRNG The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
* `RNG.Next` method will be called. If `undefined` is provided, it will default to
* a random seed.
* @param verbose Optional. If specified, will write entries to the "log.txt" file that describe
* what the function is doing. Default is false.
*/
export declare function getRandomJSONEntity(jsonEntities: readonly JSONEntity[], seedOrRNG: Seed | RNG | undefined, verbose?: boolean): JSONEntity;
/**
* Helper function to get a random JSON room from an array of JSON rooms.
*
* (A JSON room is an XML file converted to JSON so that it can be directly imported into your mod.)
*
* Note that this function does not simply choose a random element in the provided array; it will
* properly account for each room weight using the algorithm from:
* https://stackoverflow.com/questions/1761626/weighted-random-numbers
*
* If you want an unseeded room, you must explicitly pass `undefined` to the `seedOrRNG` parameter.
*
* @param jsonRooms The array of rooms to randomly choose between.
* @param seedOrRNG The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
* `RNG.Next` method will be called. If `undefined` is provided, it will default to
* a random seed.
* @param verbose Optional. If specified, will write entries to the "log.txt" file that describe
* what the function is doing. Default is false.
*/
export declare function getRandomJSONRoom(jsonRooms: readonly JSONRoom[], seedOrRNG: Seed | RNG | undefined, verbose?: boolean): JSONRoom;
//# sourceMappingURL=jsonRoom.d.ts.map