Skip to content

Commit

Permalink
Documentation Revision #3 (#123)
Browse files Browse the repository at this point in the history
* docs: ItemPool

* feat: Level

* docs: LevelGeneratorEntry

* docs: LootList

* Update LootListEntry.d.ts

* docs: MenuManager

* Update StatsMenu.d.ts

* docs: MultiShotParams

* Update NightmareScene.d.ts

* docs: PersistentGameData

* docs: PlayerManager

* docs: PocketItem

* docs: Point

* docs: RNG

* docs: Room

* docs: RoomConfig

* docs: RoomConfigSet and RoomConfigStage

* docs: RoomConfigHolder

* docs: RoomDescriptor

* docs: EntitiesSaveStateVector

* docs: AnimationFrame

* docs: LayerState

* docs: Sprite

* docs: Weapon

* docs: Camera

* docs: EntityFamiliar

* docs: EntityPlayer

* feat: Missing callbacks

* Update isaac.txt

---------

Co-authored-by: James <5511220+Zamiell@users.noreply.github.com>
  • Loading branch information
Syntax-Sculptor and Zamiell authored Oct 19, 2024
1 parent 4d110f4 commit f21d38f
Show file tree
Hide file tree
Showing 37 changed files with 970 additions and 94 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/**
* This enum is for REPENTOGON, an exe-hack which expands the modding API.
*
* @see https://repentogon.com/
*/
export enum GameMode {
NORMAL = 0,
GREED = 1,
}
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,24 @@ export enum ModCallbackRepentogon {
*/
PRE_PLAYER_COLLISION = 33,

/**
* A modified version of `ModCallback.POST_PICKUP_SELECTION`.
*
* You cannot filter this callback.
*
* ```ts
* function postPickupSelection(
* pickup: EntityPickup,
* variant: PickupVariant,
* subType: int,
* requestedVariant: PickupVariant,
* requestedSubType: int,
* rng: RNG,
* ): [pickupVariant: PickupVariant, subType: int, continueSelection: boolean] | undefined {}
* ```
*/
POST_PICKUP_SELECTION = 37,

/**
* A modified version of `ModCallback.PRE_PICKUP_COLLISION`. This callback now allows an interface
* to be returned to further modify the collision behavior.
Expand Down Expand Up @@ -2595,6 +2613,51 @@ export enum ModCallbackRepentogon {
*/
POST_PLAYER_REMOVE_COSTUME = 1284,

/**
* When registering this callback with the `Mod.AddCallback` method:
* - You can provide an optional third argument that will make the callback only fire if it
* matches the `BedSubType` provided.
*
* ```ts
* function preTriggerBedSleepEffect(
* player: EntityPlayer,
* bed: EntityPickup
* ): boolean | undefined {}
* ```
*/
PRE_TRIGGER_BED_SLEEP_EFFECT = 1285,

/**
* When registering this callback with the `Mod.AddCallback` method:
* - You can provide an optional third argument that will make the callback only fire if it
* matches the `BedSubType` provided.
*
* ```ts
* function postTriggerBedSleepEffect(player: EntityPlayer, bed: EntityPickup): void {}
* ```
*/
POST_TRIGGER_BED_SLEEP_EFFECT = 1286,

/**
* You cannot filter this callback.
*
* ```ts
* function prePlayerPocketItemSwap(player: EntityPlayer): boolean | undefined {}
* ```
*/
PRE_PLAYER_POCKET_ITEMS_SWAP = 1287,

/**
* When registering this callback with the `Mod.AddCallback` method:
* - You can provide an optional third argument that will make the callback only fire if it
* matches the `BedSubType` provided.
*
* ```ts
* function preBedSleep(player: EntityPlayer, bed: EntityPickup): boolean | undefined {}
* ```
*/
PRE_BED_SLEEP = 1288,

/**
* When registering this callback with the `Mod.AddCallback` method:
* - You can provide an optional third argument that will make the callback only fire if it
Expand Down Expand Up @@ -3687,4 +3750,40 @@ export enum ModCallbackRepentogon {
* ```
*/
PRE_ITEM_TEXT_DISPLAY = 1484,

/**
* When registering this callback with the `Mod.AddCallback` method:
* - You can provide an optional third argument that will make the callback only fire if it
* matches the `EntityType` provided.
*
* ```ts
* function preEntitySetColor(
* entity: Entity,
* color: Color,
* duration: int,
* priority: int,
* fadeOut: boolean,
* share: boolean
* ): Color | boolean | undefined {}
* ```
*/
PRE_ENTITY_SET_COLOR = 1486,

/**
* When registering this callback with the `Mod.AddCallback` method:
* - You can provide an optional third argument that will make the callback only fire if it
* matches the `EntityType` provided.
*
* ```ts
* function postEntitySetColor(
* entity: Entity,
* color: Color,
* duration: int,
* priority: int,
* fadeOut: boolean,
* share: boolean
* ): void {}
* ```
*/
POST_ENTITY_SET_COLOR = 1487,
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/**
* This is represented as an object instead of an enum due to limitations with TypeScript enums. (We
* want this type to be a child of the `BitFlag` type.)
*
* This enum is for REPENTOGON, an exe-hack which expands the modding API.
*
* @see https://repentogon.com/
* @enum
* @notExported
* @rename GetCollectibleFlag
*/
const GetCollectibleFlagInternal = {
/** Bans active collectibles. */
BAN_ACTIVE: 1 << 0,

/**
* Ignores attempts to morph the collectible into Magic Skin or Rosary. Does not prevent morphing
* the collectible into The Bible.
*/
IGNORE_MODIFIERS: 1 << 1,

BAN_PASSIVE: 1 << 2,

/** Bans passive collectibles. */
} as const;

type GetCollectibleFlagValue = BitFlag & {
readonly __getCollectibleFlagBrand: symbol;
};
type GetCollectibleFlagType = {
readonly [K in keyof typeof GetCollectibleFlagInternal]: GetCollectibleFlagValue;
};

export const GetCollectibleFlag =
GetCollectibleFlagInternal as GetCollectibleFlagType;
export type GetCollectibleFlag =
GetCollectibleFlagType[keyof GetCollectibleFlagType];

export const GetCollectibleFlagZero = 0 as BitFlags<GetCollectibleFlag>;
2 changes: 2 additions & 0 deletions packages/isaac-typescript-definitions-repentogon/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@ export * from "./enums/flags/ButtonActionFlag";
export * from "./enums/flags/ConceptionFamiliarFlag";
export * from "./enums/flags/DebugFlag";
export * from "./enums/flags/EntityTag";
export * from "./enums/flags/GetCollectibleFlag";
export * from "./enums/flags/GibFlag";
export * from "./enums/flags/WeaponModifierFlag";
export * from "./enums/FollowerPriority";
export * from "./enums/GameMode";
export * from "./enums/GenericPromptSelection";
export * from "./enums/GenericPromptSubmittedSelection";
export * from "./enums/GiantbookType";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,11 @@ declare interface Camera extends IsaacAPIClass {
* This method does not work if `Options.CameraStyle` is not equal to `CameraStyle.ON`.
*/
SnapToPosition: (position: Vector) => void;

/**
* Updates the camera.
*
* @param interpolated Optional. Default is false.
*/
Update: (interpolated?: boolean) => void;
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import type {
PillEffect,
TrinketType,
} from "isaac-typescript-definitions";
import type { GetCollectibleFlag } from "../../enums/flags/GetCollectibleFlag";

declare global {
interface ItemPool extends IsaacAPIClass {
Expand All @@ -21,7 +22,7 @@ declare global {
ignoreLocked: boolean,
) => boolean;

/** Returns the number of Bible collectibles added to the specified `ItemPoolType`. */
/** Returns the number of Bible collectibles added to provided `itemPool`. */
GetBibleUpgrades: (itemPool: ItemPoolType) => int;

/**
Expand Down Expand Up @@ -60,6 +61,7 @@ declare global {
GetCollectiblesFromPool: (poolType: ItemPoolType) => Array<{
decreaseBy: float;
initialWeight: float;
isUnlocked: boolean;
itemID: CollectibleType;
removeOn: float;
weight: float;
Expand All @@ -82,6 +84,27 @@ declare global {
*/
GetPillColor: (pillEffect: PillEffect) => PillColor;

/**
* Returns a random item pool that is present in the current game mode. The pool selection is
* weighted, meaning item pools with more collectibles have a higher chance of being selected.
*
* @param rng
* @param advancedSearch Optional. If true, the game will return any item pool in the game,
* including those not present in the current game mode. Furthermore,
* setting it to true will allow you to make use of the `filter` argument.
* Default is false.
* @param filter Optional. The list of filtered item pools. Default is an empty array.
* @param isWhitelist Optional. If true, the game will only select item pools from the filter.
* Otherwise, the game will not select item pools from the filter. Default is
* false.
*/
GetRandomPool: (
rng: RNG,
advancedSearch?: boolean,
filter?: ItemPoolType[],
isWhitelist?: boolean,
) => ItemPoolType;

/** Returns an array of collectibles removed from all pools. */
GetRemovedCollectibles: () => CollectibleType[];

Expand All @@ -94,6 +117,52 @@ declare global {
/** Returns whether the specified trinket is available in the trinket pool. */
HasTrinket: (trinket: TrinketType) => boolean;

/**
* Returns the raw result of `ItemPool.GetCollectible` without applying the filtering used in
* `ItemPool.GetCollectible`. Returns undefined if the provided `itemPool` has no collectibles
* remaining.
*
* **Differences with `ItemPool.GetCollectible`**
*
* - The game does not select glitched items, even if a player has TMTRAINER.
* - The game does not randomize the pool if a player has Chaos.
* - The game does not attempt to return a collectible from `ItemPoolType.TREASURE` or
* `CollectibleType.BREAKFAST` if it fails to pick a random collectible.
* - The game does not attempt to morph the collectible into `CollectibleType.BIBLE`,
* `CollectibleType.MAGIC_SKIN`, or `CollectibleType.ROSARY`.
* - The game does not trigger `ModCallbackRepentogon.PRE_GET_COLLECTIBLE` and
* `ModCallbackRepentogon.POST_GET_COLLECTIBLE`.
*
* @param itemPool
* @param decrease Optional. Default is false.
* @param rng Optional. Default is a new RNG object seeded with `Random()`.
* @param flags Optional. Default is `GetCollectibleFlagZero`.
*/
PickCollectible: (
itemPool: ItemPoolType,
decrease?: boolean,
rng?: RNG,
flags?: GetCollectibleFlag | BitFlags<GetCollectibleFlag>,
) =>
| {
itemID: CollectibleType;
initialWeight: float;
weight: float;
decreaseBy: float;
removeOn: float;
isUnlocked: boolean;
}
| undefined;

/**
* Makes the provided collectible available again in every item pool. Its `initialWeight` is
* also restored.
*/
ResetCollectible: (collectible: CollectibleType) => void;

/** Sets the currently selected `ItemPoolType`. */
SetLastPool: (pool: ItemPoolType) => void;

/** Resets the specified `PillColor` back to its unidentified state. */
UnidentifyPill: (pill: PillColor) => void;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/**
* This class is for REPENTOGON, an exe-hack which expands the modding API.
*
* @see https://repentogon.com/
*/
declare interface LRoomAreaDesc {
/** Returns the position of the upper half's bottom right corner. */
GetHighBottomRight: () => Vector;

/** Returns the position of the upper half's bottom right corner. */
GetHighTopLeft: () => Vector;

/** Returns the position of the bottom half's bottom right corner. */
GetLowBottomRight: () => Vector;

/** Returns the position of the lower half's top left corner. */
GetLowTopLeft: () => Vector;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/**
* This class is for REPENTOGON, an exe-hack which expands the modding API.
*
* @see https://repentogon.com/
*/
declare interface LRoomTileDesc {
/** Returns the grid coordinates of the upper half's bottom right corner. */
GetHighBottomRight: () => [int, int];

/** Returns the grid coordinates of the upper half's top left corner. */
GetHighTopLeft: () => [int, int];

/** Returns the grid coordinates of the lower half's bottom right corner. */
GetLowBottomRight: () => [int, int];

/** Returns the grid coordinates of the lower half's top left corner. */
GetLowTopLeft: () => [int, int];

/** Returns the grid coordinates of a random tile. */
GetRandomTile: (seed: Seed) => [int, int];
}
Loading

0 comments on commit f21d38f

Please sign in to comment.