isaacscript-common 3.14.0 → 3.15.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.
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Helper function to start a Challenge Room or the Boss Rush.
3
+ *
4
+ * Specifically, this is performed by spawning a sack on top of the player, waiting a game frame,
5
+ * and then removing the sack and the pickups that the sack dropped.
6
+ */
7
+ export declare function startAmbush(): void;
@@ -0,0 +1,50 @@
1
+ local ____lualib = require("lualib_bundle")
2
+ local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
3
+ local ____exports = {}
4
+ local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
5
+ local PickupVariant = ____isaac_2Dtypescript_2Ddefinitions.PickupVariant
6
+ local ____runInNFrames = require("features.runInNFrames")
7
+ local runNextGameFrame = ____runInNFrames.runNextGameFrame
8
+ local ____entity = require("functions.entity")
9
+ local removeEntities = ____entity.removeEntities
10
+ local ____entitySpecific = require("functions.entitySpecific")
11
+ local spawnPickupWithSeed = ____entitySpecific.spawnPickupWithSeed
12
+ local ____pickups = require("functions.pickups")
13
+ local getCoins = ____pickups.getCoins
14
+ --- Hard-coding this makes it easier to clean up the pickups afterwards.
15
+ local SACK_SEED_THAT_SPAWNS_TWO_COINS = 6
16
+ --- Helper function to start a Challenge Room or the Boss Rush.
17
+ --
18
+ -- Specifically, this is performed by spawning a sack on top of the player, waiting a game frame,
19
+ -- and then removing the sack and the pickups that the sack dropped.
20
+ function ____exports.startAmbush(self)
21
+ local player = Isaac.GetPlayer()
22
+ local sack = spawnPickupWithSeed(
23
+ nil,
24
+ PickupVariant.SACK,
25
+ 0,
26
+ player.Position,
27
+ SACK_SEED_THAT_SPAWNS_TWO_COINS
28
+ )
29
+ local sprite = sack:GetSprite()
30
+ sprite:Stop()
31
+ local sackPtr = EntityPtr(sack)
32
+ runNextGameFrame(
33
+ nil,
34
+ function()
35
+ local futureSack = sackPtr.Ref
36
+ if futureSack == nil then
37
+ return
38
+ end
39
+ futureSack:Remove()
40
+ local sackPtrHash = GetPtrHash(futureSack)
41
+ local coins = getCoins(nil)
42
+ local coinsFromSack = __TS__ArrayFilter(
43
+ coins,
44
+ function(____, pickup) return GetPtrHash(pickup) == sackPtrHash end
45
+ )
46
+ removeEntities(nil, coinsFromSack)
47
+ end
48
+ )
49
+ end
50
+ return ____exports
package/index.d.ts CHANGED
@@ -28,6 +28,7 @@ export { runInNGameFrames, runInNRenderFrames, runNextGameFrame, runNextRenderFr
28
28
  export * from "./features/saveDataManager/exports";
29
29
  export { hasSirenStolenFamiliar, setFamiliarNoSirenSteal, } from "./features/sirenHelpers";
30
30
  export { getTaintedLazarusSubPlayer } from "./features/taintedLazarusPlayers";
31
+ export * from "./functions/ambush";
31
32
  export * from "./functions/array";
32
33
  export * from "./functions/benchmark";
33
34
  export * from "./functions/bitwise";
package/index.lua CHANGED
@@ -223,6 +223,14 @@ do
223
223
  local getTaintedLazarusSubPlayer = ____taintedLazarusPlayers.getTaintedLazarusSubPlayer
224
224
  ____exports.getTaintedLazarusSubPlayer = getTaintedLazarusSubPlayer
225
225
  end
226
+ do
227
+ local ____export = require("functions.ambush")
228
+ for ____exportKey, ____exportValue in pairs(____export) do
229
+ if ____exportKey ~= "default" then
230
+ ____exports[____exportKey] = ____exportValue
231
+ end
232
+ end
233
+ end
226
234
  do
227
235
  local ____export = require("functions.array")
228
236
  for ____exportKey, ____exportValue in pairs(____export) do
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "3.14.0",
3
+ "version": "3.15.0",
4
4
  "description": "Helper functions and features for IsaacScript mods.",
5
5
  "keywords": [
6
6
  "isaac",