isaacscript-common 6.13.0 → 6.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/dist/enums/private/SerializationBrand.d.ts +1 -1
  2. package/dist/enums/private/SerializationBrand.lua +1 -1
  3. package/dist/features/customGridEntity.d.ts +2 -2
  4. package/dist/features/customGridEntity.lua +2 -2
  5. package/dist/features/extraConsoleCommands/exports.d.ts +4 -3
  6. package/dist/features/extraConsoleCommands/exports.d.ts.map +1 -1
  7. package/dist/features/extraConsoleCommands/exports.lua +4 -3
  8. package/dist/features/extraConsoleCommands/init.lua +1 -0
  9. package/dist/functions/color.d.ts +10 -0
  10. package/dist/functions/color.d.ts.map +1 -1
  11. package/dist/functions/color.lua +24 -0
  12. package/dist/functions/gridEntities.d.ts +2 -20
  13. package/dist/functions/gridEntities.d.ts.map +1 -1
  14. package/dist/functions/gridEntities.lua +2 -59
  15. package/dist/functions/kColor.d.ts +10 -0
  16. package/dist/functions/kColor.d.ts.map +1 -1
  17. package/dist/functions/kColor.lua +24 -0
  18. package/dist/functions/npcs.d.ts +2 -2
  19. package/dist/functions/npcs.lua +2 -2
  20. package/dist/functions/random.d.ts +1 -1
  21. package/dist/functions/random.lua +1 -1
  22. package/dist/functions/rockAlt.d.ts +28 -0
  23. package/dist/functions/rockAlt.d.ts.map +1 -0
  24. package/dist/functions/rockAlt.lua +140 -0
  25. package/dist/functions/vector.d.ts +11 -0
  26. package/dist/functions/vector.d.ts.map +1 -1
  27. package/dist/functions/vector.lua +23 -0
  28. package/dist/index.d.ts +1 -0
  29. package/dist/index.d.ts.map +1 -1
  30. package/dist/index.lua +8 -0
  31. package/package.json +2 -2
  32. package/src/enums/private/SerializationBrand.ts +1 -1
  33. package/src/features/customGridEntity.ts +2 -2
  34. package/src/features/extraConsoleCommands/exports.ts +4 -3
  35. package/src/features/extraConsoleCommands/init.ts +1 -0
  36. package/src/features/extraConsoleCommands/listCommands.ts +2 -2
  37. package/src/functions/color.ts +22 -0
  38. package/src/functions/gridEntities.ts +2 -54
  39. package/src/functions/kColor.ts +22 -0
  40. package/src/functions/npcs.ts +2 -2
  41. package/src/functions/random.ts +1 -1
  42. package/src/functions/rockAlt.ts +117 -0
  43. package/src/functions/vector.ts +23 -0
  44. package/src/index.ts +1 -0
@@ -2,7 +2,7 @@
2
2
  * During serialization, we write an arbitrary string key to the object with a value of an empty
3
3
  * string. This is used during deserialization to instantiate the correct type of object.
4
4
  *
5
- * Note that we do not bother branding TSTL classes because we have no way to invoke the proper
5
+ * Note that we do not bother branding TSTL classes because we have no way to run the proper
6
6
  * constructor during deserialization.
7
7
  */
8
8
  export declare enum SerializationBrand {
@@ -2,7 +2,7 @@ local ____exports = {}
2
2
  --- During serialization, we write an arbitrary string key to the object with a value of an empty
3
3
  -- string. This is used during deserialization to instantiate the correct type of object.
4
4
  --
5
- -- Note that we do not bother branding TSTL classes because we have no way to invoke the proper
5
+ -- Note that we do not bother branding TSTL classes because we have no way to run the proper
6
6
  -- constructor during deserialization.
7
7
  ____exports.SerializationBrand = {}
8
8
  ____exports.SerializationBrand.DEFAULT_MAP = "__TSTL_DEFAULT_MAP"
@@ -37,8 +37,8 @@ export declare function spawnCustomGridEntity(gridEntityTypeCustom: GridEntityTy
37
37
  * Default is true. This is generally a good idea because if the room is not
38
38
  * updated, you will be unable to spawn another grid entity on the same tile until
39
39
  * a frame has passed. However, doing this is expensive, since it involves a call
40
- * to `Isaac.GetRoomEntities`, so set it to false if you need to invoke this
41
- * function multiple times.
40
+ * to `Isaac.GetRoomEntities`, so set it to false if you need to run this function
41
+ * multiple times.
42
42
  * @returns The grid entity that was removed. Returns undefined if no grid entity was found at the
43
43
  * given location or if the given grid entity was not a custom grid entity.
44
44
  */
@@ -164,8 +164,8 @@ end
164
164
  -- Default is true. This is generally a good idea because if the room is not
165
165
  -- updated, you will be unable to spawn another grid entity on the same tile until
166
166
  -- a frame has passed. However, doing this is expensive, since it involves a call
167
- -- to `Isaac.GetRoomEntities`, so set it to false if you need to invoke this
168
- -- function multiple times.
167
+ -- to `Isaac.GetRoomEntities`, so set it to false if you need to run this function
168
+ -- multiple times.
169
169
  -- @returns The grid entity that was removed. Returns undefined if no grid entity was found at the
170
170
  -- given location or if the given grid entity was not a custom grid entity.
171
171
  function ____exports.removeCustomGrid(self, gridIndexOrPositionOrGridEntity, updateRoom)
@@ -10,9 +10,10 @@ export declare function enableExtraConsoleCommands(mod: ModUpgraded): void;
10
10
  *
11
11
  * The standard library comes with many existing console commands that are useful for debugging, but
12
12
  * you can also add your own commands that are useful for your particular mod. It's easier to add
13
- * commands to the existing command system than to add logic manually to the ExecuteCmd callback.
13
+ * commands to the existing command system than to add your own logic manually to the `EXECUTE_CMD`
14
+ * callback.
14
15
  *
15
- * Before using this function, you must first invoke `enableExtraConsoleCommands`.
16
+ * Before using this function, you must first run the `enableExtraConsoleCommands` function.
16
17
  */
17
18
  export declare function addConsoleCommand(commandName: string, commandFunction: (params: string) => void): void;
18
19
  /**
@@ -21,7 +22,7 @@ export declare function addConsoleCommand(commandName: string, commandFunction:
21
22
  * The standard library comes with many existing console commands that are useful for debugging. If
22
23
  * you want to disable one of them, use this function.
23
24
  *
24
- * Before using this function, you must first invoke `enableExtraConsoleCommands`.
25
+ * Before using this function, you must first run the `enableExtraConsoleCommands` function.
25
26
  */
26
27
  export declare function removeConsoleCommand(commandName: string): void;
27
28
  //# sourceMappingURL=exports.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"exports.d.ts","sourceRoot":"","sources":["../../../src/features/extraConsoleCommands/exports.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAQxD;;;;GAIG;AACH,wBAAgB,0BAA0B,CAAC,GAAG,EAAE,WAAW,GAAG,IAAI,CAMjE;AAED;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAC/B,WAAW,EAAE,MAAM,EACnB,eAAe,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,GACxC,IAAI,CAoBN;AAED;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAc9D"}
1
+ {"version":3,"file":"exports.d.ts","sourceRoot":"","sources":["../../../src/features/extraConsoleCommands/exports.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAQxD;;;;GAIG;AACH,wBAAgB,0BAA0B,CAAC,GAAG,EAAE,WAAW,GAAG,IAAI,CAMjE;AAED;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAC/B,WAAW,EAAE,MAAM,EACnB,eAAe,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,GACxC,IAAI,CAoBN;AAED;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAc9D"}
@@ -21,9 +21,10 @@ end
21
21
  --
22
22
  -- The standard library comes with many existing console commands that are useful for debugging, but
23
23
  -- you can also add your own commands that are useful for your particular mod. It's easier to add
24
- -- commands to the existing command system than to add logic manually to the ExecuteCmd callback.
24
+ -- commands to the existing command system than to add your own logic manually to the `EXECUTE_CMD`
25
+ -- callback.
25
26
  --
26
- -- Before using this function, you must first invoke `enableExtraConsoleCommands`.
27
+ -- Before using this function, you must first run the `enableExtraConsoleCommands` function.
27
28
  function ____exports.addConsoleCommand(self, commandName, commandFunction)
28
29
  if not isExtraConsoleCommandsInitialized(nil) then
29
30
  error("The \"extraConsoleCommands\" feature is not initialized. Before adding extra console commands, you must first enable the feature by invoking the \"enableExtraConsoleCommands\" function.")
@@ -41,7 +42,7 @@ end
41
42
  -- The standard library comes with many existing console commands that are useful for debugging. If
42
43
  -- you want to disable one of them, use this function.
43
44
  --
44
- -- Before using this function, you must first invoke `enableExtraConsoleCommands`.
45
+ -- Before using this function, you must first run the `enableExtraConsoleCommands` function.
45
46
  function ____exports.removeConsoleCommand(self, commandName)
46
47
  if not isExtraConsoleCommandsInitialized(nil) then
47
48
  error("The \"extraConsoleCommands\" feature is not initialized. Before removing console commands, you must first enable the feature by invoking the \"enableExtraConsoleCommands\" function.")
@@ -164,6 +164,7 @@ function initMap(self)
164
164
  extraConsoleCommandsFunctionMap:set("tearDisplay", commandsDisplay.tearDisplay)
165
165
  extraConsoleCommandsFunctionMap:set("tears", commands.tears)
166
166
  extraConsoleCommandsFunctionMap:set("tearsDisplay", commandsDisplay.tearsDisplay)
167
+ extraConsoleCommandsFunctionMap:set("tests", commands.tests)
167
168
  extraConsoleCommandsFunctionMap:set("tntDisplay", commandsDisplay.tntDisplay)
168
169
  extraConsoleCommandsFunctionMap:set("tntsDisplay", commandsDisplay.tntsDisplay)
169
170
  extraConsoleCommandsFunctionMap:set("trapdoor", commands.trapdoorCommand)
@@ -1,5 +1,7 @@
1
1
  /// <reference types="typescript-to-lua/language-extensions" />
2
2
  /// <reference types="isaac-typescript-definitions" />
3
+ /// <reference types="isaac-typescript-definitions" />
4
+ /// <reference types="isaac-typescript-definitions" />
3
5
  import { SerializationType } from "../enums/SerializationType";
4
6
  declare type SerializedColor = LuaMap<string, unknown> & {
5
7
  readonly __serializedColorBrand: symbol;
@@ -19,6 +21,14 @@ export declare function colorEquals(color1: Color, color2: Color): boolean;
19
21
  */
20
22
  export declare function copyColor<C extends Color | SerializedColor, S extends SerializationType>(color: C, serializationType: S): CopyColorReturn[S];
21
23
  export declare function copyColor<C extends Color | SerializedColor>(color: C): CopyColorReturn[SerializationType.NONE];
24
+ /**
25
+ * Helper function to get a random color.
26
+ *
27
+ * @param seedOrRNG Optional. The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
28
+ * `RNG.Next` method will be called. Default is `getRandomSeed()`.
29
+ * @param alpha Optional. The alpha value to use. Default is 1.
30
+ */
31
+ export declare function getRandomColor(seedOrRNG?: Seed | RNG, alpha?: number): Color;
22
32
  /** Helper function to check if something is an instantiated Color object. */
23
33
  export declare function isColor(object: unknown): object is Color;
24
34
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"color.d.ts","sourceRoot":"","sources":["../../src/functions/color.ts"],"names":[],"mappings":";;AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAK/D,aAAK,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG;IAC/C,QAAQ,CAAC,sBAAsB,EAAE,MAAM,CAAC;CACzC,CAAC;AAEF,UAAU,eAAe;IACvB,CAAC,iBAAiB,CAAC,IAAI,CAAC,EAAE,KAAK,CAAC;IAChC,CAAC,iBAAiB,CAAC,SAAS,CAAC,EAAE,eAAe,CAAC;IAC/C,CAAC,iBAAiB,CAAC,WAAW,CAAC,EAAE,KAAK,CAAC;CACxC;AAKD,wBAAgB,WAAW,CAAC,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,GAAG,OAAO,CAEjE;AAED;;;;;;GAMG;AACH,wBAAgB,SAAS,CACvB,CAAC,SAAS,KAAK,GAAG,eAAe,EACjC,CAAC,SAAS,iBAAiB,EAC3B,KAAK,EAAE,CAAC,EAAE,iBAAiB,EAAE,CAAC,GAAG,eAAe,CAAC,CAAC,CAAC,CAAC;AACtD,wBAAgB,SAAS,CAAC,CAAC,SAAS,KAAK,GAAG,eAAe,EACzD,KAAK,EAAE,CAAC,GACP,eAAe,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;AAuE3C,6EAA6E;AAC7E,wBAAgB,OAAO,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,IAAI,KAAK,CAExD;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,IAAI,eAAe,CAM5E"}
1
+ {"version":3,"file":"color.d.ts","sourceRoot":"","sources":["../../src/functions/color.ts"],"names":[],"mappings":";;;;AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAO/D,aAAK,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG;IAC/C,QAAQ,CAAC,sBAAsB,EAAE,MAAM,CAAC;CACzC,CAAC;AAEF,UAAU,eAAe;IACvB,CAAC,iBAAiB,CAAC,IAAI,CAAC,EAAE,KAAK,CAAC;IAChC,CAAC,iBAAiB,CAAC,SAAS,CAAC,EAAE,eAAe,CAAC;IAC/C,CAAC,iBAAiB,CAAC,WAAW,CAAC,EAAE,KAAK,CAAC;CACxC;AAKD,wBAAgB,WAAW,CAAC,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,GAAG,OAAO,CAEjE;AAED;;;;;;GAMG;AACH,wBAAgB,SAAS,CACvB,CAAC,SAAS,KAAK,GAAG,eAAe,EACjC,CAAC,SAAS,iBAAiB,EAC3B,KAAK,EAAE,CAAC,EAAE,iBAAiB,EAAE,CAAC,GAAG,eAAe,CAAC,CAAC,CAAC,CAAC;AACtD,wBAAgB,SAAS,CAAC,CAAC,SAAS,KAAK,GAAG,eAAe,EACzD,KAAK,EAAE,CAAC,GACP,eAAe,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;AAuE3C;;;;;;GAMG;AACH,wBAAgB,cAAc,CAC5B,SAAS,GAAE,IAAI,GAAG,GAAqB,EACvC,KAAK,SAAI,GACR,KAAK,CAQP;AAED,6EAA6E;AAC7E,wBAAgB,OAAO,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,IAAI,KAAK,CAExD;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,IAAI,eAAe,CAM5E"}
@@ -7,6 +7,12 @@ local SerializationType = ____SerializationType.SerializationType
7
7
  local ____isaacAPIClass = require("functions.isaacAPIClass")
8
8
  local isaacAPIClassEquals = ____isaacAPIClass.isaacAPIClassEquals
9
9
  local isIsaacAPIClassOfType = ____isaacAPIClass.isIsaacAPIClassOfType
10
+ local ____random = require("functions.random")
11
+ local getRandom = ____random.getRandom
12
+ local ____rng = require("functions.rng")
13
+ local getRandomSeed = ____rng.getRandomSeed
14
+ local isRNG = ____rng.isRNG
15
+ local newRNG = ____rng.newRNG
10
16
  local ____table = require("functions.table")
11
17
  local copyValuesToTable = ____table.copyValuesToTable
12
18
  local getNumbersFromTable = ____table.getNumbersFromTable
@@ -104,6 +110,24 @@ function ____exports.copyColor(self, color, serializationType)
104
110
  end
105
111
  until true
106
112
  end
113
+ --- Helper function to get a random color.
114
+ --
115
+ -- @param seedOrRNG Optional. The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
116
+ -- `RNG.Next` method will be called. Default is `getRandomSeed()`.
117
+ -- @param alpha Optional. The alpha value to use. Default is 1.
118
+ function ____exports.getRandomColor(self, seedOrRNG, alpha)
119
+ if seedOrRNG == nil then
120
+ seedOrRNG = getRandomSeed(nil)
121
+ end
122
+ if alpha == nil then
123
+ alpha = 1
124
+ end
125
+ local rng = isRNG(nil, seedOrRNG) and seedOrRNG or newRNG(nil, seedOrRNG)
126
+ local r = getRandom(nil, rng)
127
+ local g = getRandom(nil, rng)
128
+ local b = getRandom(nil, rng)
129
+ return Color(r, g, b, alpha)
130
+ end
107
131
  --- Used to determine is the given table is a serialized `Color` object created by the save data
108
132
  -- manager and/or the `deepCopy` function.
109
133
  function ____exports.isSerializedColor(self, object)
@@ -175,7 +175,7 @@ export declare function removeAllMatchingGridEntities(...gridEntityType: GridEnt
175
175
  * generally a good idea because if the room is not updated, you will be unable to
176
176
  * spawn another grid entity on the same tile until a frame has passed. However,
177
177
  * doing this is expensive, since it involves a call to `Isaac.GetRoomEntities`,
178
- * so set this to false if you need to invoke this function multiple times.
178
+ * so set this to false if you need to run this function multiple times.
179
179
  * @param cap Optional. If specified, will only remove the given amount of entities.
180
180
  * @returns An array of the entities that were removed.
181
181
  */
@@ -189,7 +189,7 @@ export declare function removeGridEntities<T extends AnyGridEntity>(gridEntities
189
189
  * generally a good idea because if the room is not updated, you will be unable to
190
190
  * spawn another grid entity on the same tile until a frame has passed. However,
191
191
  * doing this is expensive, since it involves a call to `Isaac.GetRoomEntities`,
192
- * so set this to false if you need to invoke this function multiple times.
192
+ * so set this to false if you need to run this function multiple times.
193
193
  */
194
194
  export declare function removeGridEntity(gridEntityOrGridIndex: GridEntity | int, updateRoom: boolean): void;
195
195
  /**
@@ -225,24 +225,6 @@ export declare function spawnGridEntity(gridEntityType: GridEntityType, gridInde
225
225
  * - allows you to specify the grid index or the position
226
226
  */
227
227
  export declare function spawnGridEntityWithVariant(gridEntityType: GridEntityType, variant: int, gridIndexOrPosition: int | Vector): GridEntity | undefined;
228
- /**
229
- * Helper function for emulating what happens when a vanilla `GridEntityType.ROCK_ALT` grid entity
230
- * breaks.
231
- *
232
- * Note that most of the time, this function will do nothing, similar to how most of the time, when
233
- * an individual urn is destroyed, nothing will spawn.
234
- *
235
- * The logic in this function is based on the rewards listed on the wiki:
236
- * https://bindingofisaacrebirth.fandom.com/wiki/Rocks
237
- *
238
- * @param rockAltType The type of reward to spawn. For example, `RockAltType.URN` will have a chance
239
- * at spawning coins and spiders.
240
- * @param _seedOrRNG Optional. The `Seed` or `RNG` object to use. If an `RNG` object is provided,
241
- * the `RNG.Next` method will be called. Default is `getRandomSeed()`. Normally,
242
- * you should pass the `InitSeed` of the grid entity that was broken.
243
- * @returns Whether or not this function spawned something.
244
- */
245
- export declare function spawnRockAltReward(rockAltType: RockAltType, _seedOrRNG?: Seed | RNG): boolean;
246
228
  /**
247
229
  * Helper function to spawn a Void Portal. This is more complicated than simply spawning a trapdoor
248
230
  * with the appropriate variant, as the game does not give it the correct sprite automatically.
@@ -1 +1 @@
1
- {"version":3,"file":"gridEntities.d.ts","sourceRoot":"","sources":["../../src/functions/gridEntities.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EAEjB,cAAc,EACd,iBAAiB,EAGjB,eAAe,EAChB,MAAM,8BAA8B,CAAC;AAGtC,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAQnD,OAAO,EAAE,aAAa,EAAE,MAAM,wB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ACH,wBAAgB,kBAAkB,CAAC,CAAC,SAAS,aAAa,EACxD,YAAY,EAAE,CAAC,EAAE,EACjB,UAAU,EAAE,OAAO,EACnB,GAAG,CAAC,EAAE,GAAG,GACR,CAAC,EAAE,CAoBL;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAC9B,qBAAqB,EAAE,UAAU,GAAG,GAAG,EACvC,UAAU,EAAE,OAAO,GAClB,IAAI,CAWN;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,UAAU,EAAE,UAAU,GAAG,IAAI,CAGnE;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,gBAAgB,EAAE,GAAG,GAAG,IAAI,CA4B1D;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAC7B,cAAc,EAAE,cAAc,EAC9B,mBAAmB,EAAE,GAAG,GAAG,MAAM,GAChC,UAAU,GAAG,SAAS,CAExB;AAED;;;;;;;GAOG;AACH,wBAAgB,0BAA0B,CACxC,cAAc,EAAE,cAAc,EAC9B,OAAO,EAAE,GAAG,EACZ,mBAAmB,EAAE,GAAG,GAAG,MAAM,GAChC,UAAU,GAAG,SAAS,CAgCxB;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,SAAS,EAAE,GAAG,GAAG,UAAU,GAAG,SAAS,CAkBtE"}
@@ -15,8 +15,6 @@ local ____cachedClasses = require("cachedClasses")
15
15
  local game = ____cachedClasses.game
16
16
  local ____constants = require("constants")
17
17
  local DISTANCE_OF_GRID_TILE = ____constants.DISTANCE_OF_GRID_TILE
18
- local ____RockAltType = require("enums.RockAltType")
19
- local RockAltType = ____RockAltType.RockAltType
20
18
  local ____gridEntityTypeToBrokenStateMap = require("maps.gridEntityTypeToBrokenStateMap")
21
19
  local GRID_ENTITY_TYPE_TO_BROKEN_STATE_MAP = ____gridEntityTypeToBrokenStateMap.GRID_ENTITY_TYPE_TO_BROKEN_STATE_MAP
22
20
  local ____gridEntityXMLMap = require("maps.gridEntityXMLMap")
@@ -28,8 +26,6 @@ local ____backdropTypeToRockAltType = require("objects.backdropTypeToRockAltType
28
26
  local BACKDROP_TYPE_TO_ROCK_ALT_TYPE = ____backdropTypeToRockAltType.BACKDROP_TYPE_TO_ROCK_ALT_TYPE
29
27
  local ____math = require("functions.math")
30
28
  local isCircleIntersectingRectangle = ____math.isCircleIntersectingRectangle
31
- local ____rng = require("functions.rng")
32
- local getRandomSeed = ____rng.getRandomSeed
33
29
  local ____rooms = require("functions.rooms")
34
30
  local roomUpdateSafe = ____rooms.roomUpdateSafe
35
31
  local ____sprites = require("functions.sprites")
@@ -123,7 +119,7 @@ end
123
119
  -- generally a good idea because if the room is not updated, you will be unable to
124
120
  -- spawn another grid entity on the same tile until a frame has passed. However,
125
121
  -- doing this is expensive, since it involves a call to `Isaac.GetRoomEntities`,
126
- -- so set this to false if you need to invoke this function multiple times.
122
+ -- so set this to false if you need to run this function multiple times.
127
123
  function ____exports.removeGridEntity(self, gridEntityOrGridIndex, updateRoom)
128
124
  local room = game:GetRoom()
129
125
  local gridIndex = isNumber(nil, gridEntityOrGridIndex) and gridEntityOrGridIndex or gridEntityOrGridIndex:GetGridIndex()
@@ -420,7 +416,7 @@ end
420
416
  -- generally a good idea because if the room is not updated, you will be unable to
421
417
  -- spawn another grid entity on the same tile until a frame has passed. However,
422
418
  -- doing this is expensive, since it involves a call to `Isaac.GetRoomEntities`,
423
- -- so set this to false if you need to invoke this function multiple times.
419
+ -- so set this to false if you need to run this function multiple times.
424
420
  -- @param cap Optional. If specified, will only remove the given amount of entities.
425
421
  -- @returns An array of the entities that were removed.
426
422
  function ____exports.removeGridEntities(self, gridEntities, updateRoom, cap)
@@ -473,59 +469,6 @@ end
473
469
  function ____exports.spawnGridEntity(self, gridEntityType, gridIndexOrPosition)
474
470
  return ____exports.spawnGridEntityWithVariant(nil, gridEntityType, 0, gridIndexOrPosition)
475
471
  end
476
- --- Helper function for emulating what happens when a vanilla `GridEntityType.ROCK_ALT` grid entity
477
- -- breaks.
478
- --
479
- -- Note that most of the time, this function will do nothing, similar to how most of the time, when
480
- -- an individual urn is destroyed, nothing will spawn.
481
- --
482
- -- The logic in this function is based on the rewards listed on the wiki:
483
- -- https://bindingofisaacrebirth.fandom.com/wiki/Rocks
484
- --
485
- -- @param rockAltType The type of reward to spawn. For example, `RockAltType.URN` will have a chance
486
- -- at spawning coins and spiders.
487
- -- @param _seedOrRNG Optional. The `Seed` or `RNG` object to use. If an `RNG` object is provided,
488
- -- the `RNG.Next` method will be called. Default is `getRandomSeed()`. Normally,
489
- -- you should pass the `InitSeed` of the grid entity that was broken.
490
- -- @returns Whether or not this function spawned something.
491
- function ____exports.spawnRockAltReward(self, rockAltType, _seedOrRNG)
492
- if _seedOrRNG == nil then
493
- _seedOrRNG = getRandomSeed(nil)
494
- end
495
- repeat
496
- local ____switch66 = rockAltType
497
- local ____cond66 = ____switch66 == RockAltType.URN
498
- if ____cond66 then
499
- do
500
- return false
501
- end
502
- end
503
- ____cond66 = ____cond66 or ____switch66 == RockAltType.MUSHROOM
504
- if ____cond66 then
505
- do
506
- return false
507
- end
508
- end
509
- ____cond66 = ____cond66 or ____switch66 == RockAltType.SKULL
510
- if ____cond66 then
511
- do
512
- return false
513
- end
514
- end
515
- ____cond66 = ____cond66 or ____switch66 == RockAltType.POLYP
516
- if ____cond66 then
517
- do
518
- return false
519
- end
520
- end
521
- ____cond66 = ____cond66 or ____switch66 == RockAltType.BUCKET
522
- if ____cond66 then
523
- do
524
- return false
525
- end
526
- end
527
- until true
528
- end
529
472
  --- Helper function to spawn a Void Portal. This is more complicated than simply spawning a trapdoor
530
473
  -- with the appropriate variant, as the game does not give it the correct sprite automatically.
531
474
  function ____exports.spawnVoidPortal(self, gridIndex)
@@ -1,5 +1,7 @@
1
1
  /// <reference types="typescript-to-lua/language-extensions" />
2
2
  /// <reference types="isaac-typescript-definitions" />
3
+ /// <reference types="isaac-typescript-definitions" />
4
+ /// <reference types="isaac-typescript-definitions" />
3
5
  import { SerializationType } from "../enums/SerializationType";
4
6
  declare type SerializedKColor = LuaMap<string, unknown> & {
5
7
  readonly __serializedKColorBrand: symbol;
@@ -18,6 +20,14 @@ interface CopyKColorReturn {
18
20
  */
19
21
  export declare function copyKColor<K extends KColor | SerializedKColor, S extends SerializationType>(kColor: K, serializationType: S): CopyKColorReturn[S];
20
22
  export declare function copyKColor<K extends KColor | SerializedKColor>(kColor: K): CopyKColorReturn[SerializationType.NONE];
23
+ /**
24
+ * Helper function to get a random color.
25
+ *
26
+ * @param seedOrRNG Optional. The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
27
+ * `RNG.Next` method will be called. Default is `getRandomSeed()`.
28
+ * @param alpha Optional. The alpha value to use. Default is 1.
29
+ */
30
+ export declare function getRandomKColor(seedOrRNG?: Seed | RNG, alpha?: number): KColor;
21
31
  /** Helper function to check if something is an instantiated KColor object. */
22
32
  export declare function isKColor(object: unknown): object is KColor;
23
33
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"kColor.d.ts","sourceRoot":"","sources":["../../src/functions/kColor.ts"],"names":[],"mappings":";;AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAK/D,aAAK,gBAAgB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG;IAChD,QAAQ,CAAC,uBAAuB,EAAE,MAAM,CAAC;CAC1C,CAAC;AAEF,UAAU,gBAAgB;IACxB,CAAC,iBAAiB,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACjC,CAAC,iBAAiB,CAAC,SAAS,CAAC,EAAE,gBAAgB,CAAC;IAChD,CAAC,iBAAiB,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;CACzC;AAKD;;;;;;GAMG;AACH,wBAAgB,UAAU,CACxB,CAAC,SAAS,MAAM,GAAG,gBAAgB,EACnC,CAAC,SAAS,iBAAiB,EAC3B,MAAM,EAAE,CAAC,EAAE,iBAAiB,EAAE,CAAC,GAAG,gBAAgB,CAAC,CAAC,CAA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wBAAgB,eAAe,CAC7B,SAAS,GAAE,IAAI,GAAG,GAAqB,EACvC,KAAK,SAAI,GACR,MAAM,CAQR;AAED,8EAA8E;AAC9E,wBAAgB,QAAQ,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,IAAI,MAAM,CAE1D;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,OAAO,GACd,MAAM,IAAI,gBAAgB,CAQ5B;AAED,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAEtE"}
@@ -7,6 +7,12 @@ local SerializationType = ____SerializationType.SerializationType
7
7
  local ____isaacAPIClass = require("functions.isaacAPIClass")
8
8
  local isaacAPIClassEquals = ____isaacAPIClass.isaacAPIClassEquals
9
9
  local isIsaacAPIClassOfType = ____isaacAPIClass.isIsaacAPIClassOfType
10
+ local ____random = require("functions.random")
11
+ local getRandom = ____random.getRandom
12
+ local ____rng = require("functions.rng")
13
+ local getRandomSeed = ____rng.getRandomSeed
14
+ local isRNG = ____rng.isRNG
15
+ local newRNG = ____rng.newRNG
10
16
  local ____table = require("functions.table")
11
17
  local copyValuesToTable = ____table.copyValuesToTable
12
18
  local getNumbersFromTable = ____table.getNumbersFromTable
@@ -80,6 +86,24 @@ function ____exports.copyKColor(self, kColor, serializationType)
80
86
  end
81
87
  until true
82
88
  end
89
+ --- Helper function to get a random color.
90
+ --
91
+ -- @param seedOrRNG Optional. The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
92
+ -- `RNG.Next` method will be called. Default is `getRandomSeed()`.
93
+ -- @param alpha Optional. The alpha value to use. Default is 1.
94
+ function ____exports.getRandomKColor(self, seedOrRNG, alpha)
95
+ if seedOrRNG == nil then
96
+ seedOrRNG = getRandomSeed(nil)
97
+ end
98
+ if alpha == nil then
99
+ alpha = 1
100
+ end
101
+ local rng = isRNG(nil, seedOrRNG) and seedOrRNG or newRNG(nil, seedOrRNG)
102
+ local r = getRandom(nil, rng)
103
+ local g = getRandom(nil, rng)
104
+ local b = getRandom(nil, rng)
105
+ return KColor(r, g, b, alpha)
106
+ end
83
107
  --- Used to determine is the given table is a serialized `KColor` object created by the save data
84
108
  -- manager and/or the `deepCopy` function.
85
109
  function ____exports.isSerializedKColor(self, object)
@@ -48,8 +48,8 @@ export declare function isDyingEggyWithNoSpidersLeft(npc: EntityNPC): boolean;
48
48
  export declare function isRaglingDeathPatch(npc: EntityNPC): boolean;
49
49
  /**
50
50
  * The base game `EntityNPC.FireProjectiles` method does not return anything, which is a problem in
51
- * situations where you need to work with the fired projectiles. This function invokes that method,
52
- * and then returns the projectiles that were spawned.
51
+ * situations where you need to work with the fired projectiles. This function runs that method, and
52
+ * then returns the projectiles that were spawned.
53
53
  *
54
54
  * @param npc The EntityNPC firing projectiles.
55
55
  * @param position The starting position of the projectiles.
@@ -143,8 +143,8 @@ function ____exports.getAliveNPCs(self, entityType, variant, subType, ignoreFrie
143
143
  )
144
144
  end
145
145
  --- The base game `EntityNPC.FireProjectiles` method does not return anything, which is a problem in
146
- -- situations where you need to work with the fired projectiles. This function invokes that method,
147
- -- and then returns the projectiles that were spawned.
146
+ -- situations where you need to work with the fired projectiles. This function runs that method, and
147
+ -- then returns the projectiles that were spawned.
148
148
  --
149
149
  -- @param npc The EntityNPC firing projectiles.
150
150
  -- @param position The starting position of the projectiles.
@@ -27,7 +27,7 @@ export declare function getRandomFloat(min: int, max: int, seedOrRNG?: Seed | RN
27
27
  /**
28
28
  * This returns a random integer between min and max. It is inclusive on both ends.
29
29
  *
30
- * Note that this function will invoke the `Next` method on the `RNG` object before returning the
30
+ * Note that this function will run the `Next` method on the `RNG` object before returning the
31
31
  * random number.
32
32
  *
33
33
  * For example:
@@ -44,7 +44,7 @@ function ____exports.getRandomFloat(self, min, max, seedOrRNG)
44
44
  end
45
45
  --- This returns a random integer between min and max. It is inclusive on both ends.
46
46
  --
47
- -- Note that this function will invoke the `Next` method on the `RNG` object before returning the
47
+ -- Note that this function will run the `Next` method on the `RNG` object before returning the
48
48
  -- random number.
49
49
  --
50
50
  -- For example:
@@ -0,0 +1,28 @@
1
+ /// <reference types="isaac-typescript-definitions" />
2
+ /// <reference types="isaac-typescript-definitions" />
3
+ /// <reference types="isaac-typescript-definitions" />
4
+ import { RockAltType } from "../enums/RockAltType";
5
+ /**
6
+ * Helper function for emulating what happens when a vanilla `GridEntityType.ROCK_ALT` grid entity
7
+ * breaks.
8
+ *
9
+ * Note that most of the time, this function will do nothing, similar to how most of the time, when
10
+ * an individual urn is destroyed, nothing will spawn.
11
+ *
12
+ * For the purposes of spawning collectibles, this function assumes that the player has not seen the
13
+ * collectible yet in the current run. In vanilla, it is only possible to get a e.g. Quarter if the
14
+ * collectible still exists in the Treasure Room pool.
15
+ *
16
+ * The logic in this function is based on the rewards listed on the wiki:
17
+ * https://bindingofisaacrebirth.fandom.com/wiki/Rocks
18
+ *
19
+ * @param position The place to spawn the reward.
20
+ * @param rockAltType The type of reward to spawn. For example, `RockAltType.URN` will have a chance
21
+ * at spawning coins and spiders.
22
+ * @param seedOrRNG Optional. The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
23
+ * `RNG.Next` method will be called. Default is `getRandomSeed()`. Normally, you
24
+ * should pass the `InitSeed` of the grid entity that was broken.
25
+ * @returns Whether or not this function spawned something.
26
+ */
27
+ export declare function spawnRockAltReward(position: Vector, rockAltType: RockAltType, seedOrRNG?: Seed | RNG): boolean;
28
+ //# sourceMappingURL=rockAlt.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rockAlt.d.ts","sourceRoot":"","sources":["../../src/functions/rockAlt.ts"],"names":[],"mappings":";;;AAMA,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAQnD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,WAAW,EACxB,SAAS,GAAE,IAAI,GAAG,GAAqB,GACtC,OAAO,CA4ET"}
@@ -0,0 +1,140 @@
1
+ local ____exports = {}
2
+ local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
3
+ local CoinSubType = ____isaac_2Dtypescript_2Ddefinitions.CoinSubType
4
+ local CollectibleType = ____isaac_2Dtypescript_2Ddefinitions.CollectibleType
5
+ local TrinketType = ____isaac_2Dtypescript_2Ddefinitions.TrinketType
6
+ local ____constants = require("constants")
7
+ local DISTANCE_OF_GRID_TILE = ____constants.DISTANCE_OF_GRID_TILE
8
+ local ____RockAltType = require("enums.RockAltType")
9
+ local RockAltType = ____RockAltType.RockAltType
10
+ local ____pickupsSpecific = require("functions.pickupsSpecific")
11
+ local spawnCoinWithSeed = ____pickupsSpecific.spawnCoinWithSeed
12
+ local spawnTrinketWithSeed = ____pickupsSpecific.spawnTrinketWithSeed
13
+ local ____random = require("functions.random")
14
+ local getRandom = ____random.getRandom
15
+ local ____rng = require("functions.rng")
16
+ local getRandomSeed = ____rng.getRandomSeed
17
+ local isRNG = ____rng.isRNG
18
+ local newRNG = ____rng.newRNG
19
+ local ____spawnCollectible = require("functions.spawnCollectible")
20
+ local spawnCollectible = ____spawnCollectible.spawnCollectible
21
+ local ____utils = require("functions.utils")
22
+ local ____repeat = ____utils["repeat"]
23
+ local ____vector = require("functions.vector")
24
+ local getRandomVector = ____vector.getRandomVector
25
+ --- Helper function for emulating what happens when a vanilla `GridEntityType.ROCK_ALT` grid entity
26
+ -- breaks.
27
+ --
28
+ -- Note that most of the time, this function will do nothing, similar to how most of the time, when
29
+ -- an individual urn is destroyed, nothing will spawn.
30
+ --
31
+ -- For the purposes of spawning collectibles, this function assumes that the player has not seen the
32
+ -- collectible yet in the current run. In vanilla, it is only possible to get a e.g. Quarter if the
33
+ -- collectible still exists in the Treasure Room pool.
34
+ --
35
+ -- The logic in this function is based on the rewards listed on the wiki:
36
+ -- https://bindingofisaacrebirth.fandom.com/wiki/Rocks
37
+ --
38
+ -- @param position The place to spawn the reward.
39
+ -- @param rockAltType The type of reward to spawn. For example, `RockAltType.URN` will have a chance
40
+ -- at spawning coins and spiders.
41
+ -- @param seedOrRNG Optional. The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
42
+ -- `RNG.Next` method will be called. Default is `getRandomSeed()`. Normally, you
43
+ -- should pass the `InitSeed` of the grid entity that was broken.
44
+ -- @returns Whether or not this function spawned something.
45
+ function ____exports.spawnRockAltReward(self, position, rockAltType, seedOrRNG)
46
+ if seedOrRNG == nil then
47
+ seedOrRNG = getRandomSeed(nil)
48
+ end
49
+ local rng = isRNG(nil, seedOrRNG) and seedOrRNG or newRNG(nil, seedOrRNG)
50
+ local chance = getRandom(nil, rng)
51
+ repeat
52
+ local ____switch3 = rockAltType
53
+ local ____cond3 = ____switch3 == RockAltType.URN
54
+ if ____cond3 then
55
+ do
56
+ local totalChance = 0
57
+ totalChance = totalChance + 0.68
58
+ if chance < totalChance then
59
+ return false
60
+ end
61
+ totalChance = totalChance + 0.0944
62
+ if chance < totalChance then
63
+ local numCoinsChance = getRandom(nil, rng)
64
+ local numCoins = numCoinsChance < 0.5 and 1 or 2
65
+ ____repeat(
66
+ nil,
67
+ numCoins,
68
+ function()
69
+ local velocity = getRandomVector(nil, rng)
70
+ spawnCoinWithSeed(
71
+ nil,
72
+ CoinSubType.NULL,
73
+ position,
74
+ rng,
75
+ velocity
76
+ )
77
+ end
78
+ )
79
+ return true
80
+ end
81
+ totalChance = totalChance + 0.025
82
+ if chance < totalChance then
83
+ spawnTrinketWithSeed(nil, TrinketType.SWALLOWED_PENNY, position, rng)
84
+ end
85
+ totalChance = totalChance + 0.005
86
+ if chance < totalChance then
87
+ spawnCollectible(nil, CollectibleType.QUARTER, position, rng)
88
+ end
89
+ totalChance = totalChance + 0.1948
90
+ if chance < totalChance then
91
+ local numSpidersChance = getRandom(nil, rng)
92
+ local numSpiders = numSpidersChance < 0.5 and 1 or 2
93
+ ____repeat(
94
+ nil,
95
+ numSpiders,
96
+ function()
97
+ local randomVector = getRandomVector(nil, rng)
98
+ local length = DISTANCE_OF_GRID_TILE * 3
99
+ local offset = randomVector * length
100
+ local targetPos = position + offset
101
+ EntityNPC.ThrowSpider(
102
+ position,
103
+ nil,
104
+ targetPos,
105
+ false,
106
+ 0
107
+ )
108
+ end
109
+ )
110
+ end
111
+ return false
112
+ end
113
+ end
114
+ ____cond3 = ____cond3 or ____switch3 == RockAltType.MUSHROOM
115
+ if ____cond3 then
116
+ do
117
+ return false
118
+ end
119
+ end
120
+ ____cond3 = ____cond3 or ____switch3 == RockAltType.SKULL
121
+ if ____cond3 then
122
+ do
123
+ return false
124
+ end
125
+ end
126
+ ____cond3 = ____cond3 or ____switch3 == RockAltType.POLYP
127
+ if ____cond3 then
128
+ do
129
+ return false
130
+ end
131
+ end
132
+ ____cond3 = ____cond3 or ____switch3 == RockAltType.BUCKET
133
+ if ____cond3 then
134
+ do
135
+ return false
136
+ end
137
+ end
138
+ until true
139
+ end
140
+ return ____exports
@@ -18,6 +18,17 @@ interface CopyVectorReturn {
18
18
  */
19
19
  export declare function copyVector<V extends Vector | SerializedVector, S extends SerializationType>(vector: V, serializationType: S): CopyVectorReturn[S];
20
20
  export declare function copyVector<V extends Vector | SerializedVector>(vector: V): CopyVectorReturn[SerializationType.NONE];
21
+ /**
22
+ * Helper function to get a random vector between (-1, -1) and (1, 1).
23
+ *
24
+ * To get random vectors with a bigger length, multiply this with a number.
25
+ *
26
+ * Use this over the `RandomVector` function when you need the vector to be seeded.
27
+ *
28
+ * @param seedOrRNG Optional. The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
29
+ * `RNG.Next` method will be called. Default is `getRandomSeed()`.
30
+ */
31
+ export declare function getRandomVector(seedOrRNG?: Seed | RNG): Vector;
21
32
  /**
22
33
  * Used to determine is the given table is a serialized `Vector` object created by the save data
23
34
  * manager and/or the `deepCopy` function.
@@ -1 +1 @@
1
- {"version":3,"file":"vector.d.ts","sourceRoot":"","sources":["../../src/functions/vector.ts"],"names":[],"mappings":";AAAA,OAAO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3D;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,UAAQ,GAAG,MAAM,CAIpE"}
@@ -9,6 +9,12 @@ local angleToDirection = ____direction.angleToDirection
9
9
  local ____isaacAPIClass = require("functions.isaacAPIClass")
10
10
  local isaacAPIClassEquals = ____isaacAPIClass.isaacAPIClassEquals
11
11
  local isIsaacAPIClassOfType = ____isaacAPIClass.isIsaacAPIClassOfType
12
+ local ____random = require("functions.random")
13
+ local getRandomFloat = ____random.getRandomFloat
14
+ local ____rng = require("functions.rng")
15
+ local getRandomSeed = ____rng.getRandomSeed
16
+ local isRNG = ____rng.isRNG
17
+ local newRNG = ____rng.newRNG
12
18
  local ____table = require("functions.table")
13
19
  local copyValuesToTable = ____table.copyValuesToTable
14
20
  local getNumbersFromTable = ____table.getNumbersFromTable
@@ -76,6 +82,23 @@ function ____exports.copyVector(self, vector, serializationType)
76
82
  end
77
83
  until true
78
84
  end
85
+ --- Helper function to get a random vector between (-1, -1) and (1, 1).
86
+ --
87
+ -- To get random vectors with a bigger length, multiply this with a number.
88
+ --
89
+ -- Use this over the `RandomVector` function when you need the vector to be seeded.
90
+ --
91
+ -- @param seedOrRNG Optional. The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
92
+ -- `RNG.Next` method will be called. Default is `getRandomSeed()`.
93
+ function ____exports.getRandomVector(self, seedOrRNG)
94
+ if seedOrRNG == nil then
95
+ seedOrRNG = getRandomSeed(nil)
96
+ end
97
+ local rng = isRNG(nil, seedOrRNG) and seedOrRNG or newRNG(nil, seedOrRNG)
98
+ local x = getRandomFloat(nil, -1, 1, rng)
99
+ local y = getRandomFloat(nil, -1, 1, rng)
100
+ return Vector(x, y)
101
+ end
79
102
  --- Used to determine is the given table is a serialized `Vector` object created by the save data
80
103
  -- manager and/or the `deepCopy` function.
81
104
  function ____exports.isSerializedVector(self, object)
package/dist/index.d.ts CHANGED
@@ -101,6 +101,7 @@ export * from "./functions/pressurePlate";
101
101
  export * from "./functions/random";
102
102
  export * from "./functions/revive";
103
103
  export * from "./functions/rng";
104
+ export * from "./functions/rockAlt";
104
105
  export * from "./functions/roomData";
105
106
  export * from "./functions/roomGrid";
106
107
  export * from "./functions/rooms";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,OAAO,EACL,cAAc,EACd,eAAe,GAChB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACL,qBAAqB,EACrB,oBAAoB,EACpB,0BAA0B,GAC3B,MAAM,gCAAgC,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,aAAa,CAAC;AAC5B,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,wBAAwB,CAAC;AACvC,cAAc,2BAA2B,CAAC;AAC1C,OAAO,EACL,sBAAsB,EACtB,iCAAiC,GAClC,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AACnE,OAAO,EAAE,0BAA0B,EAAE,MAAM,oCAAoC,CAAC;AAChF,OAAO,EACL,gBAAgB,EAChB,qBAAqB,IAAI,eAAe,GACzC,MAAM,6BAA6B,CAAC;AACrC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,mCAAmC,CAAC;AAClD,cAAc,iCAAiC,CAAC;AAChD,OAAO,EACL,cAAc,EACd,oBAAoB,EACpB,SAAS,GACV,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC7E,OAAO,EACL,gBAAgB,EAChB,yBAAyB,EACzB,qBAAqB,EACrB,qBAAqB,EACrB,eAAe,EACf,wBAAwB,GACzB,MAAM,0BAA0B,CAAC;AAClC,cAAc,yCAAyC,CAAC;AACxD,OAAO,EAAE,Y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C,cAAc,0BAA0B,CAAC;AACzC,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,cAAc,CAAC"}
package/dist/index.lua CHANGED
@@ -806,6 +806,14 @@ do
806
806
  end
807
807
  end
808
808
  end
809
+ do
810
+ local ____export = require("functions.rockAlt")
811
+ for ____exportKey, ____exportValue in pairs(____export) do
812
+ if ____exportKey ~= "default" then
813
+ ____exports[____exportKey] = ____exportValue
814
+ end
815
+ end
816
+ end
809
817
  do
810
818
  local ____export = require("functions.roomData")
811
819
  for ____exportKey, ____exportValue in pairs(____export) do
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "6.13.0",
3
+ "version": "6.14.0",
4
4
  "description": "Helper functions and features for IsaacScript mods.",
5
5
  "keywords": [
6
6
  "isaac",
@@ -22,6 +22,6 @@
22
22
  "main": "dist/index",
23
23
  "types": "dist/index.d.ts",
24
24
  "dependencies": {
25
- "isaac-typescript-definitions": "^3.0.34"
25
+ "isaac-typescript-definitions": "^3.0.35"
26
26
  }
27
27
  }
@@ -2,7 +2,7 @@
2
2
  * During serialization, we write an arbitrary string key to the object with a value of an empty
3
3
  * string. This is used during deserialization to instantiate the correct type of object.
4
4
  *
5
- * Note that we do not bother branding TSTL classes because we have no way to invoke the proper
5
+ * Note that we do not bother branding TSTL classes because we have no way to run the proper
6
6
  * constructor during deserialization.
7
7
  */
8
8
  export enum SerializationBrand {
@@ -228,8 +228,8 @@ export function spawnCustomGridEntity(
228
228
  * Default is true. This is generally a good idea because if the room is not
229
229
  * updated, you will be unable to spawn another grid entity on the same tile until
230
230
  * a frame has passed. However, doing this is expensive, since it involves a call
231
- * to `Isaac.GetRoomEntities`, so set it to false if you need to invoke this
232
- * function multiple times.
231
+ * to `Isaac.GetRoomEntities`, so set it to false if you need to run this function
232
+ * multiple times.
233
233
  * @returns The grid entity that was removed. Returns undefined if no grid entity was found at the
234
234
  * given location or if the given grid entity was not a custom grid entity.
235
235
  */
@@ -24,9 +24,10 @@ export function enableExtraConsoleCommands(mod: ModUpgraded): void {
24
24
  *
25
25
  * The standard library comes with many existing console commands that are useful for debugging, but
26
26
  * you can also add your own commands that are useful for your particular mod. It's easier to add
27
- * commands to the existing command system than to add logic manually to the ExecuteCmd callback.
27
+ * commands to the existing command system than to add your own logic manually to the `EXECUTE_CMD`
28
+ * callback.
28
29
  *
29
- * Before using this function, you must first invoke `enableExtraConsoleCommands`.
30
+ * Before using this function, you must first run the `enableExtraConsoleCommands` function.
30
31
  */
31
32
  export function addConsoleCommand(
32
33
  commandName: string,
@@ -59,7 +60,7 @@ export function addConsoleCommand(
59
60
  * The standard library comes with many existing console commands that are useful for debugging. If
60
61
  * you want to disable one of them, use this function.
61
62
  *
62
- * Before using this function, you must first invoke `enableExtraConsoleCommands`.
63
+ * Before using this function, you must first run the `enableExtraConsoleCommands` function.
63
64
  */
64
65
  export function removeConsoleCommand(commandName: string): void {
65
66
  if (!isExtraConsoleCommandsInitialized()) {
@@ -267,6 +267,7 @@ function initMap() {
267
267
  "tearsDisplay",
268
268
  commandsDisplay.tearsDisplay,
269
269
  );
270
+ extraConsoleCommandsFunctionMap.set("tests", commands.tests);
270
271
  extraConsoleCommandsFunctionMap.set("tntDisplay", commandsDisplay.tntDisplay);
271
272
  extraConsoleCommandsFunctionMap.set(
272
273
  "tntsDisplay",
@@ -15,8 +15,8 @@
15
15
  * `enableExtraConsoleCommands`. (See the "Extra Console Commands (Init)" page for more details.)
16
16
  *
17
17
  * Each command has a corresponding function of the same name, but these functions are not actually
18
- * exported for end-user consumption (in order to cut down on namespace conflicts and because the
19
- * names of the functions are not very descriptive).
18
+ * exported for end-user consumption. (This is to cut down on namespace conflicts and because the
19
+ * names of the functions are not very descriptive.)
20
20
  *
21
21
  * @module
22
22
  */
@@ -1,6 +1,8 @@
1
1
  import { SerializationBrand } from "../enums/private/SerializationBrand";
2
2
  import { SerializationType } from "../enums/SerializationType";
3
3
  import { isaacAPIClassEquals, isIsaacAPIClassOfType } from "./isaacAPIClass";
4
+ import { getRandom } from "./random";
5
+ import { getRandomSeed, isRNG, newRNG } from "./rng";
4
6
  import { copyValuesToTable, getNumbersFromTable, tableHasKeys } from "./table";
5
7
  import { isTable } from "./types";
6
8
 
@@ -105,6 +107,26 @@ export function copyColor(
105
107
  }
106
108
  }
107
109
 
110
+ /**
111
+ * Helper function to get a random color.
112
+ *
113
+ * @param seedOrRNG Optional. The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
114
+ * `RNG.Next` method will be called. Default is `getRandomSeed()`.
115
+ * @param alpha Optional. The alpha value to use. Default is 1.
116
+ */
117
+ export function getRandomColor(
118
+ seedOrRNG: Seed | RNG = getRandomSeed(),
119
+ alpha = 1,
120
+ ): Color {
121
+ const rng = isRNG(seedOrRNG) ? seedOrRNG : newRNG(seedOrRNG);
122
+
123
+ const r = getRandom(rng);
124
+ const g = getRandom(rng);
125
+ const b = getRandom(rng);
126
+
127
+ return Color(r, g, b, alpha);
128
+ }
129
+
108
130
  /** Helper function to check if something is an instantiated Color object. */
109
131
  export function isColor(object: unknown): object is Color {
110
132
  return isIsaacAPIClassOfType(object, OBJECT_NAME);
@@ -19,7 +19,6 @@ import {
19
19
  import { BACKDROP_TYPE_TO_ROCK_ALT_TYPE } from "../objects/backdropTypeToRockAltType";
20
20
  import { AnyGridEntity } from "../types/AnyGridEntity";
21
21
  import { isCircleIntersectingRectangle } from "./math";
22
- import { getRandomSeed } from "./rng";
23
22
  import { roomUpdateSafe } from "./rooms";
24
23
  import { clearSprite } from "./sprites";
25
24
  import { isNumber } from "./types";
@@ -488,7 +487,7 @@ export function removeAllMatchingGridEntities(
488
487
  * generally a good idea because if the room is not updated, you will be unable to
489
488
  * spawn another grid entity on the same tile until a frame has passed. However,
490
489
  * doing this is expensive, since it involves a call to `Isaac.GetRoomEntities`,
491
- * so set this to false if you need to invoke this function multiple times.
490
+ * so set this to false if you need to run this function multiple times.
492
491
  * @param cap Optional. If specified, will only remove the given amount of entities.
493
492
  * @returns An array of the entities that were removed.
494
493
  */
@@ -527,7 +526,7 @@ export function removeGridEntities<T extends AnyGridEntity>(
527
526
  * generally a good idea because if the room is not updated, you will be unable to
528
527
  * spawn another grid entity on the same tile until a frame has passed. However,
529
528
  * doing this is expensive, since it involves a call to `Isaac.GetRoomEntities`,
530
- * so set this to false if you need to invoke this function multiple times.
529
+ * so set this to false if you need to run this function multiple times.
531
530
  */
532
531
  export function removeGridEntity(
533
532
  gridEntityOrGridIndex: GridEntity | int,
@@ -654,57 +653,6 @@ export function spawnGridEntityWithVariant(
654
653
  return gridEntity;
655
654
  }
656
655
 
657
- /**
658
- * Helper function for emulating what happens when a vanilla `GridEntityType.ROCK_ALT` grid entity
659
- * breaks.
660
- *
661
- * Note that most of the time, this function will do nothing, similar to how most of the time, when
662
- * an individual urn is destroyed, nothing will spawn.
663
- *
664
- * The logic in this function is based on the rewards listed on the wiki:
665
- * https://bindingofisaacrebirth.fandom.com/wiki/Rocks
666
- *
667
- * @param rockAltType The type of reward to spawn. For example, `RockAltType.URN` will have a chance
668
- * at spawning coins and spiders.
669
- * @param _seedOrRNG Optional. The `Seed` or `RNG` object to use. If an `RNG` object is provided,
670
- * the `RNG.Next` method will be called. Default is `getRandomSeed()`. Normally,
671
- * you should pass the `InitSeed` of the grid entity that was broken.
672
- * @returns Whether or not this function spawned something.
673
- */
674
- export function spawnRockAltReward(
675
- rockAltType: RockAltType,
676
- _seedOrRNG: Seed | RNG = getRandomSeed(),
677
- ): boolean {
678
- /// const chance = getRandom(seedOrRNG);
679
-
680
- switch (rockAltType) {
681
- case RockAltType.URN: {
682
- // TODO
683
- return false;
684
- }
685
-
686
- case RockAltType.MUSHROOM: {
687
- // TODO
688
- return false;
689
- }
690
-
691
- case RockAltType.SKULL: {
692
- // TODO
693
- return false;
694
- }
695
-
696
- case RockAltType.POLYP: {
697
- // TODO
698
- return false;
699
- }
700
-
701
- case RockAltType.BUCKET: {
702
- // TODO
703
- return false;
704
- }
705
- }
706
- }
707
-
708
656
  /**
709
657
  * Helper function to spawn a Void Portal. This is more complicated than simply spawning a trapdoor
710
658
  * with the appropriate variant, as the game does not give it the correct sprite automatically.
@@ -1,6 +1,8 @@
1
1
  import { SerializationBrand } from "../enums/private/SerializationBrand";
2
2
  import { SerializationType } from "../enums/SerializationType";
3
3
  import { isaacAPIClassEquals, isIsaacAPIClassOfType } from "./isaacAPIClass";
4
+ import { getRandom } from "./random";
5
+ import { getRandomSeed, isRNG, newRNG } from "./rng";
4
6
  import { copyValuesToTable, getNumbersFromTable, tableHasKeys } from "./table";
5
7
  import { isTable } from "./types";
6
8
 
@@ -98,6 +100,26 @@ export function copyKColor(
98
100
  }
99
101
  }
100
102
 
103
+ /**
104
+ * Helper function to get a random color.
105
+ *
106
+ * @param seedOrRNG Optional. The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
107
+ * `RNG.Next` method will be called. Default is `getRandomSeed()`.
108
+ * @param alpha Optional. The alpha value to use. Default is 1.
109
+ */
110
+ export function getRandomKColor(
111
+ seedOrRNG: Seed | RNG = getRandomSeed(),
112
+ alpha = 1,
113
+ ): KColor {
114
+ const rng = isRNG(seedOrRNG) ? seedOrRNG : newRNG(seedOrRNG);
115
+
116
+ const r = getRandom(rng);
117
+ const g = getRandom(rng);
118
+ const b = getRandom(rng);
119
+
120
+ return KColor(r, g, b, alpha);
121
+ }
122
+
101
123
  /** Helper function to check if something is an instantiated KColor object. */
102
124
  export function isKColor(object: unknown): object is KColor {
103
125
  return isIsaacAPIClassOfType(object, OBJECT_NAME);
@@ -152,8 +152,8 @@ export function isRaglingDeathPatch(npc: EntityNPC): boolean {
152
152
 
153
153
  /**
154
154
  * The base game `EntityNPC.FireProjectiles` method does not return anything, which is a problem in
155
- * situations where you need to work with the fired projectiles. This function invokes that method,
156
- * and then returns the projectiles that were spawned.
155
+ * situations where you need to work with the fired projectiles. This function runs that method, and
156
+ * then returns the projectiles that were spawned.
157
157
  *
158
158
  * @param npc The EntityNPC firing projectiles.
159
159
  * @param position The starting position of the projectiles.
@@ -45,7 +45,7 @@ export function getRandomFloat(
45
45
  /**
46
46
  * This returns a random integer between min and max. It is inclusive on both ends.
47
47
  *
48
- * Note that this function will invoke the `Next` method on the `RNG` object before returning the
48
+ * Note that this function will run the `Next` method on the `RNG` object before returning the
49
49
  * random number.
50
50
  *
51
51
  * For example:
@@ -0,0 +1,117 @@
1
+ import {
2
+ CoinSubType,
3
+ CollectibleType,
4
+ TrinketType,
5
+ } from "isaac-typescript-definitions";
6
+ import { DISTANCE_OF_GRID_TILE } from "../constants";
7
+ import { RockAltType } from "../enums/RockAltType";
8
+ import { spawnCoinWithSeed, spawnTrinketWithSeed } from "./pickupsSpecific";
9
+ import { getRandom } from "./random";
10
+ import { getRandomSeed, isRNG, newRNG } from "./rng";
11
+ import { spawnCollectible } from "./spawnCollectible";
12
+ import { repeat } from "./utils";
13
+ import { getRandomVector } from "./vector";
14
+
15
+ /**
16
+ * Helper function for emulating what happens when a vanilla `GridEntityType.ROCK_ALT` grid entity
17
+ * breaks.
18
+ *
19
+ * Note that most of the time, this function will do nothing, similar to how most of the time, when
20
+ * an individual urn is destroyed, nothing will spawn.
21
+ *
22
+ * For the purposes of spawning collectibles, this function assumes that the player has not seen the
23
+ * collectible yet in the current run. In vanilla, it is only possible to get a e.g. Quarter if the
24
+ * collectible still exists in the Treasure Room pool.
25
+ *
26
+ * The logic in this function is based on the rewards listed on the wiki:
27
+ * https://bindingofisaacrebirth.fandom.com/wiki/Rocks
28
+ *
29
+ * @param position The place to spawn the reward.
30
+ * @param rockAltType The type of reward to spawn. For example, `RockAltType.URN` will have a chance
31
+ * at spawning coins and spiders.
32
+ * @param seedOrRNG Optional. The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
33
+ * `RNG.Next` method will be called. Default is `getRandomSeed()`. Normally, you
34
+ * should pass the `InitSeed` of the grid entity that was broken.
35
+ * @returns Whether or not this function spawned something.
36
+ */
37
+ export function spawnRockAltReward(
38
+ position: Vector,
39
+ rockAltType: RockAltType,
40
+ seedOrRNG: Seed | RNG = getRandomSeed(),
41
+ ): boolean {
42
+ const rng = isRNG(seedOrRNG) ? seedOrRNG : newRNG(seedOrRNG);
43
+ const chance = getRandom(rng);
44
+
45
+ switch (rockAltType) {
46
+ case RockAltType.URN: {
47
+ let totalChance = 0;
48
+
49
+ // Nothing. (68.00%)
50
+ totalChance += 0.68;
51
+ if (chance < totalChance) {
52
+ return false;
53
+ }
54
+
55
+ // One or two random coins. (9.44%)
56
+ totalChance += 0.0944;
57
+ if (chance < totalChance) {
58
+ const numCoinsChance = getRandom(rng);
59
+ const numCoins = numCoinsChance < 0.5 ? 1 : 2;
60
+ repeat(numCoins, () => {
61
+ const velocity = getRandomVector(rng);
62
+ spawnCoinWithSeed(CoinSubType.NULL, position, rng, velocity);
63
+ });
64
+ return true;
65
+ }
66
+
67
+ // Swallowed Penny. (2.50%)
68
+ totalChance += 0.025;
69
+ if (chance < totalChance) {
70
+ spawnTrinketWithSeed(TrinketType.SWALLOWED_PENNY, position, rng);
71
+ }
72
+
73
+ // A Quarter. (0.50%)
74
+ totalChance += 0.005;
75
+ if (chance < totalChance) {
76
+ spawnCollectible(CollectibleType.QUARTER, position, rng);
77
+ }
78
+
79
+ // One or two spiders. (19.48%)
80
+ totalChance += 0.1948;
81
+ if (chance < totalChance) {
82
+ const numSpidersChance = getRandom(rng);
83
+ const numSpiders = numSpidersChance < 0.5 ? 1 : 2;
84
+ repeat(numSpiders, () => {
85
+ const randomVector = getRandomVector(rng);
86
+ const length = DISTANCE_OF_GRID_TILE * 3;
87
+ const offset = randomVector.mul(length);
88
+ const targetPos = position.add(offset);
89
+ EntityNPC.ThrowSpider(position, undefined, targetPos, false, 0);
90
+ });
91
+ }
92
+
93
+ // TODO
94
+ return false;
95
+ }
96
+
97
+ case RockAltType.MUSHROOM: {
98
+ // TODO
99
+ return false;
100
+ }
101
+
102
+ case RockAltType.SKULL: {
103
+ // TODO
104
+ return false;
105
+ }
106
+
107
+ case RockAltType.POLYP: {
108
+ // TODO
109
+ return false;
110
+ }
111
+
112
+ case RockAltType.BUCKET: {
113
+ // TODO
114
+ return false;
115
+ }
116
+ }
117
+ }
@@ -3,6 +3,8 @@ import { SerializationBrand } from "../enums/private/SerializationBrand";
3
3
  import { SerializationType } from "../enums/SerializationType";
4
4
  import { angleToDirection } from "./direction";
5
5
  import { isaacAPIClassEquals, isIsaacAPIClassOfType } from "./isaacAPIClass";
6
+ import { getRandomFloat } from "./random";
7
+ import { getRandomSeed, isRNG, newRNG } from "./rng";
6
8
  import { copyValuesToTable, getNumbersFromTable, tableHasKeys } from "./table";
7
9
  import { isTable } from "./types";
8
10
 
@@ -90,6 +92,27 @@ export function copyVector(
90
92
  }
91
93
  }
92
94
 
95
+ /**
96
+ * Helper function to get a random vector between (-1, -1) and (1, 1).
97
+ *
98
+ * To get random vectors with a bigger length, multiply this with a number.
99
+ *
100
+ * Use this over the `RandomVector` function when you need the vector to be seeded.
101
+ *
102
+ * @param seedOrRNG Optional. The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
103
+ * `RNG.Next` method will be called. Default is `getRandomSeed()`.
104
+ */
105
+ export function getRandomVector(
106
+ seedOrRNG: Seed | RNG = getRandomSeed(),
107
+ ): Vector {
108
+ const rng = isRNG(seedOrRNG) ? seedOrRNG : newRNG(seedOrRNG);
109
+
110
+ const x = getRandomFloat(-1, 1, rng);
111
+ const y = getRandomFloat(-1, 1, rng);
112
+
113
+ return Vector(x, y);
114
+ }
115
+
93
116
  /**
94
117
  * Used to determine is the given table is a serialized `Vector` object created by the save data
95
118
  * manager and/or the `deepCopy` function.
package/src/index.ts CHANGED
@@ -144,6 +144,7 @@ export * from "./functions/pressurePlate";
144
144
  export * from "./functions/random";
145
145
  export * from "./functions/revive";
146
146
  export * from "./functions/rng";
147
+ export * from "./functions/rockAlt";
147
148
  export * from "./functions/roomData";
148
149
  export * from "./functions/roomGrid";
149
150
  export * from "./functions/rooms";