isaacscript-common 1.2.154 → 1.2.157

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.
@@ -24,9 +24,24 @@
24
24
  */
25
25
  export declare function initCustomDoor(mod: Mod, effectVariant: int): void;
26
26
  /**
27
- * Helper function to spawn a custom door. Handle when a player enters the door by hooking the
28
- * custom `MC_POST_CUSTOM_DOOR_ENTER` callback.
27
+ * Helper function to spawn a custom door. This is intended to be called from the `MC_POST_NEW_ROOM`
28
+ * callback when the player enters a room that should have a custom door. (You could also call it
29
+ * from another callback if you want the door to appear e.g. after clearing all enemies.)
29
30
  *
30
- * Before using this function, you must first initialize it with the `initCustomDoor` function.
31
+ * Like other entities, the door is not persistent, so you must spawn it every time when re-entering
32
+ * the room.
33
+ *
34
+ * Handle when a player enters the door by hooking the custom `MC_POST_CUSTOM_DOOR_ENTER` callback.
35
+ *
36
+ * The custom door is an `EntityEffect`. You can manually open or close the door by modifying its
37
+ * state. (The values to use correspond to the `DoorState` enum.)
38
+ *
39
+ * This function will throw a runtime error if:
40
+ * - the door slot already has a vanilla door
41
+ * - the door slot already has a custom door
42
+ * - the tile at the door slot does not have a wall
43
+ *
44
+ * Before using this function, you must first initialize the effect/door variant with the
45
+ * `initCustomDoor` function.
31
46
  */
32
- export declare function spawnCustomDoor(effectVariant: int, doorSlot: DoorSlot): void;
47
+ export declare function spawnCustomDoor(effectVariant: int, doorSlot: DoorSlot): EntityEffect;
@@ -4,7 +4,7 @@ local Set = ____lualib.Set
4
4
  local __TS__New = ____lualib.__TS__New
5
5
  local Map = ____lualib.Map
6
6
  local ____exports = {}
7
- local hasSubscriptions, postEffectRenderCustomEntity, isPlayerPastDoorThreshold, getPositionOffset, getAnimation, POSITION_OFFSET_MULTIPLIER, v
7
+ local hasSubscriptions, postEffectUpdaterCustomEntity, doorChangedState, getAnimationForCustomDoor, postEffectRenderCustomEntity, isPlayerPastDoorThreshold, getPositionOffset, POSITION_OFFSET_MULTIPLIER, v
8
8
  local ____cachedClasses = require("cachedClasses")
9
9
  local game = ____cachedClasses.game
10
10
  local ____exports = require("features.saveDataManager.exports")
@@ -23,12 +23,55 @@ local postCustomDoorEnterHasSubscriptions = ____postCustomDoorEnter.postCustomDo
23
23
  function hasSubscriptions(self)
24
24
  return postCustomDoorEnterHasSubscriptions(nil)
25
25
  end
26
- function postEffectRenderCustomEntity(self, effect)
27
- if not hasSubscriptions(nil) then
26
+ function postEffectUpdaterCustomEntity(self, effect)
27
+ local ptrHash = GetPtrHash(effect)
28
+ local doorData = v.room.customDoors:get(ptrHash)
29
+ if doorData == nil then
28
30
  return
29
31
  end
32
+ if doorData.state == effect.State then
33
+ return
34
+ end
35
+ doorData.state = effect.State
36
+ doorChangedState(nil, effect)
37
+ end
38
+ function doorChangedState(self, effect)
39
+ local room = game:GetRoom()
40
+ local sprite = effect:GetSprite()
41
+ local animation = getAnimationForCustomDoor(nil, effect)
42
+ sprite:Play(animation, true)
43
+ local gridIndex = room:GetGridIndex(effect.Position)
44
+ local wall = room:GetGridEntity(gridIndex)
45
+ if wall ~= nil then
46
+ wall.CollisionClass = effect.State == DoorState.STATE_OPEN and GridCollisionClass.COLLISION_WALL_EXCEPT_PLAYER or GridCollisionClass.COLLISION_WALL
47
+ end
48
+ end
49
+ function getAnimationForCustomDoor(self, effect)
50
+ local freshlySpawned = effect.FrameCount == 0
51
+ repeat
52
+ local ____switch11 = effect.State
53
+ local ____cond11 = ____switch11 == DoorState.STATE_OPEN
54
+ if ____cond11 then
55
+ do
56
+ return freshlySpawned and "Opened" or "Open"
57
+ end
58
+ end
59
+ ____cond11 = ____cond11 or ____switch11 == DoorState.STATE_CLOSED
60
+ if ____cond11 then
61
+ do
62
+ return freshlySpawned and "Closed" or "Close"
63
+ end
64
+ end
65
+ do
66
+ do
67
+ return "Opened"
68
+ end
69
+ end
70
+ until true
71
+ end
72
+ function postEffectRenderCustomEntity(self, effect)
30
73
  local ptrHash = GetPtrHash(effect)
31
- local doorData = v.room.doors:get(ptrHash)
74
+ local doorData = v.room.customDoors:get(ptrHash)
32
75
  if doorData == nil then
33
76
  return
34
77
  end
@@ -46,33 +89,33 @@ function postEffectRenderCustomEntity(self, effect)
46
89
  end
47
90
  function isPlayerPastDoorThreshold(self, effect, player, direction)
48
91
  repeat
49
- local ____switch10 = direction
50
- local ____cond10 = ____switch10 == Direction.NO_DIRECTION
51
- if ____cond10 then
92
+ local ____switch19 = direction
93
+ local ____cond19 = ____switch19 == Direction.NO_DIRECTION
94
+ if ____cond19 then
52
95
  do
53
96
  return false
54
97
  end
55
98
  end
56
- ____cond10 = ____cond10 or ____switch10 == Direction.UP
57
- if ____cond10 then
99
+ ____cond19 = ____cond19 or ____switch19 == Direction.UP
100
+ if ____cond19 then
58
101
  do
59
102
  return player.Position.Y <= effect.Position.Y
60
103
  end
61
104
  end
62
- ____cond10 = ____cond10 or ____switch10 == Direction.RIGHT
63
- if ____cond10 then
105
+ ____cond19 = ____cond19 or ____switch19 == Direction.RIGHT
106
+ if ____cond19 then
64
107
  do
65
108
  return player.Position.X >= effect.Position.X
66
109
  end
67
110
  end
68
- ____cond10 = ____cond10 or ____switch10 == Direction.DOWN
69
- if ____cond10 then
111
+ ____cond19 = ____cond19 or ____switch19 == Direction.DOWN
112
+ if ____cond19 then
70
113
  do
71
114
  return player.Position.Y >= effect.Position.Y
72
115
  end
73
116
  end
74
- ____cond10 = ____cond10 or ____switch10 == Direction.LEFT
75
- if ____cond10 then
117
+ ____cond19 = ____cond19 or ____switch19 == Direction.LEFT
118
+ if ____cond19 then
76
119
  do
77
120
  return player.Position.X <= effect.Position.X
78
121
  end
@@ -89,45 +132,38 @@ function getPositionOffset(self, doorSlot)
89
132
  local vector = directionToVector(nil, direction)
90
133
  return vector * POSITION_OFFSET_MULTIPLIER
91
134
  end
92
- function getAnimation(self, effect)
93
- repeat
94
- local ____switch24 = effect.State
95
- local ____cond24 = ____switch24 == DoorState.STATE_OPEN
96
- if ____cond24 then
97
- do
98
- return "Opened"
99
- end
100
- end
101
- ____cond24 = ____cond24 or ____switch24 == DoorState.STATE_CLOSED
102
- if ____cond24 then
103
- do
104
- return "Closed"
105
- end
106
- end
107
- do
108
- do
109
- return "Opened"
110
- end
111
- end
112
- until true
113
- end
114
- POSITION_OFFSET_MULTIPLIER = 23
135
+ POSITION_OFFSET_MULTIPLIER = -23
115
136
  local initializedEffectVariants = __TS__New(Set)
116
- v = {room = {doors = __TS__New(Map)}}
137
+ v = {room = {
138
+ customDoors = __TS__New(Map),
139
+ customDoorSlots = __TS__New(Set)
140
+ }}
117
141
  function ____exports.postCustomDoorEnterCallbackInit(self)
118
142
  saveDataManager(nil, "postCustomDoorEnter", v, hasSubscriptions)
119
143
  end
120
144
  function ____exports.initCustomDoor(self, mod, effectVariant)
121
145
  initializedEffectVariants:add(effectVariant)
146
+ mod:AddCallback(ModCallbacks.MC_POST_EFFECT_UPDATE, postEffectUpdaterCustomEntity, effectVariant)
122
147
  mod:AddCallback(ModCallbacks.MC_POST_EFFECT_RENDER, postEffectRenderCustomEntity, effectVariant)
123
148
  end
124
149
  function ____exports.spawnCustomDoor(self, effectVariant, doorSlot)
125
150
  if not initializedEffectVariants:has(effectVariant) then
126
151
  error("In order to spawn custom doors, you must first initialize them with the \"initCustomDoor\" function at the beginning of your mod.")
127
152
  end
153
+ if v.room.customDoorSlots:has(doorSlot) then
154
+ error("There is already a custom door initialized on door slot: " .. tostring(doorSlot))
155
+ end
128
156
  local room = game:GetRoom()
129
157
  local roomClear = room:IsClear()
130
158
  local position = room:GetDoorSlotPosition(doorSlot)
159
+ local gridEntity = room:GetGridEntityFromPos(position)
160
+ if gridEntity == nil then
161
+ error(("Failed to initialize a custom door at slot " .. tostring(doorSlot)) .. " because the wall on that tile does not exist.")
162
+ end
163
+ local gridEntityType = gridEntity:GetType()
164
+ if gridEntityType ~= GridEntityType.GRID_WALL then
165
+ error((("Failed to initialize a custom door at slot " .. tostring(doorSlot)) .. " because there is another grid entity on that tile with a type of: ") .. tostring(gridEntityType))
166
+ end
131
167
  local effect = Isaac.Spawn(
132
168
  EntityType.ENTITY_EFFECT,
133
169
  effectVariant,
@@ -143,15 +179,12 @@ function ____exports.spawnCustomDoor(self, effectVariant, doorSlot)
143
179
  effect.RenderZOffset = -10000
144
180
  effect.PositionOffset = getPositionOffset(nil, doorSlot)
145
181
  local sprite = effect:GetSprite()
146
- local animation = getAnimation(nil, effect)
147
- sprite:Play(animation, true)
148
182
  sprite.Rotation = doorSlot * 90 - 90
149
- if effect.State == DoorState.STATE_OPEN then
150
- local gridIndex = room:GetGridIndex(position)
151
- local wall = room:GetGridEntity(gridIndex)
152
- if wall ~= nil then
153
- wall.CollisionClass = GridCollisionClass.COLLISION_WALL_EXCEPT_PLAYER
154
- end
155
- end
183
+ local ptrHash = GetPtrHash(effect)
184
+ local doorData = {slot = doorSlot, state = effect.State}
185
+ v.room.customDoors:set(ptrHash, doorData)
186
+ v.room.customDoorSlots:add(doorSlot)
187
+ doorChangedState(nil, effect)
188
+ return effect
156
189
  end
157
190
  return ____exports
@@ -14,7 +14,7 @@ function ____exports.postCustomDoorEnterFire(self, player, effectVariant, doorSl
14
14
  local callback = ____value[1]
15
15
  local callbackEffectVariant = ____value[2]
16
16
  do
17
- if effectVariant ~= callbackEffectVariant then
17
+ if callbackEffectVariant ~= nil and callbackEffectVariant ~= effectVariant then
18
18
  goto __continue5
19
19
  end
20
20
  callback(
@@ -264,7 +264,9 @@ export declare function sacrifice(): void;
264
264
  /** Warps to the first Secret Room on the floor. */
265
265
  export declare function secret(): void;
266
266
  /** Logs all of the current run's seed effects to the "log.txt" file. */
267
- export declare function seeds(): void;
267
+ export declare function seedsCommand(): void;
268
+ /** Changes to a seeded run, using the seed of the current run. */
269
+ export declare function seedStick(): void;
268
270
  /**
269
271
  * Sets a charge to the player's specified active item. You must provide the active slot number and
270
272
  * the number of charges to set.
@@ -755,10 +755,15 @@ end
755
755
  function ____exports.secret(self)
756
756
  warpToRoomType(nil, RoomType.ROOM_SECRET)
757
757
  end
758
- function ____exports.seeds(self)
758
+ function ____exports.seedsCommand(self)
759
759
  logAllSeedEffects()
760
760
  printConsole(nil, "Logged the seed effects to the \"log.txt\" file.")
761
761
  end
762
+ function ____exports.seedStick(self)
763
+ local seeds = game:GetSeeds()
764
+ local startSeedString = seeds:GetStartSeedString()
765
+ Isaac.ExecuteCommand("seed " .. startSeedString)
766
+ end
762
767
  function ____exports.setCharges(self, params)
763
768
  if params == "" then
764
769
  printConsole(nil, "You must specify a slot number and a charge amount. (Use 0 for the primary slot, 1 for the Schoolbag slot, 2 for the pocket item slot, and 3 for the Dice Bag slot.)")
@@ -173,7 +173,8 @@ commandFunctionsMap:set("rottenhearts", commands.rottenHearts)
173
173
  commandFunctionsMap:set("s", commands.s)
174
174
  commandFunctionsMap:set("sacrifice", commands.sacrifice)
175
175
  commandFunctionsMap:set("secret", commands.secret)
176
- commandFunctionsMap:set("seeds", commands.seeds)
176
+ commandFunctionsMap:set("seeds", commands.seedsCommand)
177
+ commandFunctionsMap:set("seedstick", commands.seedStick)
177
178
  commandFunctionsMap:set("setcharges", commands.setCharges)
178
179
  commandFunctionsMap:set("setposition", commands.setPosition)
179
180
  commandFunctionsMap:set("sh", commands.sh)
@@ -80,17 +80,13 @@ function ____exports.getPlayerIndex(self, player, differentiateForgottenAndSoul)
80
80
  if differentiateForgottenAndSoul == nil then
81
81
  differentiateForgottenAndSoul = false
82
82
  end
83
- local character = player:GetPlayerType()
84
- local isSubPlayer = player:IsSubPlayer() and character ~= PlayerType.PLAYER_LAZARUS2_B
85
- local ____isSubPlayer_0
83
+ local playerToUse = player
84
+ local isSubPlayer = player:IsSubPlayer()
86
85
  if isSubPlayer then
87
- ____isSubPlayer_0 = ____exports.getSubPlayerParent(nil, player)
88
- else
89
- ____isSubPlayer_0 = player
90
- end
91
- local playerToUse = ____isSubPlayer_0
92
- if playerToUse == nil then
93
- error("Failed to get the sub-player parent when determining the index for the player with InitSeed: " .. tostring(player.InitSeed))
86
+ local playerParent = ____exports.getSubPlayerParent(nil, player)
87
+ if playerParent ~= nil then
88
+ playerToUse = playerParent
89
+ end
94
90
  end
95
91
  local collectibleType = getPlayerIndexCollectibleType(nil, player, differentiateForgottenAndSoul)
96
92
  local collectibleRNG = playerToUse:GetCollectibleRNG(collectibleType)
@@ -100,15 +96,15 @@ end
100
96
  function getPlayerIndexCollectibleType(self, player, differentiateForgottenAndSoul)
101
97
  local character = player:GetPlayerType()
102
98
  repeat
103
- local ____switch71 = character
104
- local ____cond71 = ____switch71 == PlayerType.PLAYER_THESOUL
105
- if ____cond71 then
99
+ local ____switch72 = character
100
+ local ____cond72 = ____switch72 == PlayerType.PLAYER_THESOUL
101
+ if ____cond72 then
106
102
  do
107
103
  return differentiateForgottenAndSoul and CollectibleType.COLLECTIBLE_SPOON_BENDER or DEFAULT_COLLECTIBLE_TYPE
108
104
  end
109
105
  end
110
- ____cond71 = ____cond71 or ____switch71 == PlayerType.PLAYER_LAZARUS2_B
111
- if ____cond71 then
106
+ ____cond72 = ____cond72 or ____switch72 == PlayerType.PLAYER_LAZARUS2_B
107
+ if ____cond72 then
112
108
  do
113
109
  return CollectibleType.COLLECTIBLE_INNER_EYE
114
110
  end
@@ -525,13 +521,13 @@ function ____exports.canTakeFreeDevilDeals(self, player)
525
521
  end
526
522
  function ____exports.isTainted(self, player)
527
523
  local character = player:GetPlayerType()
528
- local ____isVanillaCharacter_result_1
524
+ local ____isVanillaCharacter_result_0
529
525
  if ____exports.isVanillaCharacter(nil, player) then
530
- ____isVanillaCharacter_result_1 = character >= PlayerType.PLAYER_ISAAC_B
526
+ ____isVanillaCharacter_result_0 = character >= PlayerType.PLAYER_ISAAC_B
531
527
  else
532
- ____isVanillaCharacter_result_1 = isTaintedModded(nil, player)
528
+ ____isVanillaCharacter_result_0 = isTaintedModded(nil, player)
533
529
  end
534
- return ____isVanillaCharacter_result_1
530
+ return ____isVanillaCharacter_result_0
535
531
  end
536
532
  function ____exports.isTaintedLazarus(self, player)
537
533
  local character = player:GetPlayerType()
@@ -575,9 +571,9 @@ function ____exports.setActiveItem(self, player, collectibleType, activeSlot, ch
575
571
  itemPool:RemoveCollectible(collectibleType)
576
572
  end
577
573
  repeat
578
- local ____switch125 = activeSlot
579
- local ____cond125 = ____switch125 == ActiveSlot.SLOT_PRIMARY
580
- if ____cond125 then
574
+ local ____switch126 = activeSlot
575
+ local ____cond126 = ____switch126 == ActiveSlot.SLOT_PRIMARY
576
+ if ____cond126 then
581
577
  do
582
578
  if primaryCollectibleType ~= CollectibleType.COLLECTIBLE_NULL then
583
579
  player:RemoveCollectible(primaryCollectibleType)
@@ -586,8 +582,8 @@ function ____exports.setActiveItem(self, player, collectibleType, activeSlot, ch
586
582
  break
587
583
  end
588
584
  end
589
- ____cond125 = ____cond125 or ____switch125 == ActiveSlot.SLOT_SECONDARY
590
- if ____cond125 then
585
+ ____cond126 = ____cond126 or ____switch126 == ActiveSlot.SLOT_SECONDARY
586
+ if ____cond126 then
591
587
  do
592
588
  if primaryCollectibleType ~= CollectibleType.COLLECTIBLE_NULL then
593
589
  player:RemoveCollectible(primaryCollectibleType)
@@ -602,16 +598,16 @@ function ____exports.setActiveItem(self, player, collectibleType, activeSlot, ch
602
598
  break
603
599
  end
604
600
  end
605
- ____cond125 = ____cond125 or ____switch125 == ActiveSlot.SLOT_POCKET
606
- if ____cond125 then
601
+ ____cond126 = ____cond126 or ____switch126 == ActiveSlot.SLOT_POCKET
602
+ if ____cond126 then
607
603
  do
608
604
  player:SetPocketActiveItem(collectibleType, activeSlot, keepInPools)
609
605
  player:SetActiveCharge(charge, activeSlot)
610
606
  break
611
607
  end
612
608
  end
613
- ____cond125 = ____cond125 or ____switch125 == ActiveSlot.SLOT_POCKET2
614
- if ____cond125 then
609
+ ____cond126 = ____cond126 or ____switch126 == ActiveSlot.SLOT_POCKET2
610
+ if ____cond126 then
615
611
  do
616
612
  player:SetPocketActiveItem(collectibleType, activeSlot, keepInPools)
617
613
  break
package/dist/index.d.ts CHANGED
@@ -74,8 +74,8 @@ export * from "./maps/cardMap";
74
74
  export * from "./maps/characterMap";
75
75
  export * from "./maps/pillEffectMap";
76
76
  export * from "./maps/roomTypeMap";
77
+ export * from "./types/AddCallbackParametersCustom";
77
78
  export * from "./types/AnyEntity";
78
- export * from "./types/CallbackParametersCustom";
79
79
  export * from "./types/CardType";
80
80
  export * from "./types/DefaultMap";
81
81
  export * from "./types/HealthType";
@@ -1,4 +1,5 @@
1
+ import { AddCallbackParametersCustom } from "../types/AddCallbackParametersCustom";
1
2
  import { ModCallbacksCustom } from "../types/ModCallbacksCustom";
2
3
  export declare const CALLBACK_REGISTER_FUNCTIONS: {
3
- readonly [key in ModCallbacksCustom]: Function;
4
+ readonly [key in ModCallbacksCustom]: (...args: AddCallbackParametersCustom[key]) => void;
4
5
  };
@@ -3,8 +3,8 @@ local ____exports = {}
3
3
  ____exports.DIRECTION_TO_VECTOR = {
4
4
  [Direction.NO_DIRECTION] = Vector.Zero,
5
5
  [Direction.LEFT] = Vector(-1, 0),
6
- [Direction.UP] = Vector(0, 1),
6
+ [Direction.UP] = Vector(0, -1),
7
7
  [Direction.RIGHT] = Vector(1, 0),
8
- [Direction.DOWN] = Vector(0, -1)
8
+ [Direction.DOWN] = Vector(0, 1)
9
9
  }
10
10
  return ____exports
@@ -0,0 +1,239 @@
1
+ /// <reference types="isaac-typescript-definitions" />
2
+ import { PostBombInitLateCallbackType } from "../callbacks/subscriptions/postBombInitLate";
3
+ import { PostBoneSwingCallbackType } from "../callbacks/subscriptions/postBoneSwing";
4
+ import { PostCursedTeleportCallbackType } from "../callbacks/subscriptions/postCursedTeleport";
5
+ import { PostCustomDoorEnterCallbackType } from "../callbacks/subscriptions/postCustomDoorEnter";
6
+ import { PostCustomReviveCallbackType } from "../callbacks/subscriptions/postCustomRevive";
7
+ import { PostEffectInitLateCallbackType } from "../callbacks/subscriptions/postEffectInitLate";
8
+ import { PostEsauJrCallbackType } from "../callbacks/subscriptions/postEsauJr";
9
+ import { PostFamiliarInitLateCallbackType } from "../callbacks/subscriptions/postFamiliarInitLate";
10
+ import { PostFirstEsauJrCallbackType } from "../callbacks/subscriptions/postFirstEsauJr";
11
+ import { PostFirstFlipCallbackType } from "../callbacks/subscriptions/postFirstFlip";
12
+ import { PostFlipCallbackType } from "../callbacks/subscriptions/postFlip";
13
+ import { PostGameStartedReorderedCallbackType } from "../callbacks/subscriptions/postGameStartedReordered";
14
+ import { PostGridEntityBrokenCallbackType } from "../callbacks/subscriptions/postGridEntityBroken";
15
+ import { PostGridEntityCollisionCallbackType } from "../callbacks/subscriptions/postGridEntityCollision";
16
+ import { PostGridEntityInitCallbackType } from "../callbacks/subscriptions/postGridEntityInit";
17
+ import { PostGridEntityRemoveCallbackType } from "../callbacks/subscriptions/postGridEntityRemove";
18
+ import { PostGridEntityStateChangeCallbackType } from "../callbacks/subscriptions/postGridEntityStateChange";
19
+ import { PostGridEntityUpdateCallbackType } from "../callbacks/subscriptions/postGridEntityUpdate";
20
+ import { PostItemPickupCallbackType } from "../callbacks/subscriptions/postItemPickup";
21
+ import { PostKnifeInitLateCallbackType } from "../callbacks/subscriptions/postKnifeInitLate";
22
+ import { PostLaserInitLateCallbackType } from "../callbacks/subscriptions/postLaserInitLate";
23
+ import { PostNewLevelReorderedCallbackType } from "../callbacks/subscriptions/postNewLevelReordered";
24
+ import { PostNewRoomEarlyCallbackType } from "../callbacks/subscriptions/postNewRoomEarly";
25
+ import { PostNewRoomReorderedCallbackType } from "../callbacks/subscriptions/postNewRoomReordered";
26
+ import { PostNPCInitLateCallbackType } from "../callbacks/subscriptions/postNPCInitLate";
27
+ import { PostPEffectUpdateReorderedCallbackType } from "../callbacks/subscriptions/postPEffectUpdateReordered";
28
+ import { PostPickupCollectCallbackType } from "../callbacks/subscriptions/postPickupCollect";
29
+ import { PostPickupInitLateCallbackType } from "../callbacks/subscriptions/postPickupInitLate";
30
+ import { PostPlayerChangeHealthCallbackType } from "../callbacks/subscriptions/postPlayerChangeHealth";
31
+ import { PostPlayerChangeTypeCallbackType } from "../callbacks/subscriptions/postPlayerChangeType";
32
+ import { PostPlayerFatalDamageCallbackType } from "../callbacks/subscriptions/postPlayerFatalDamage";
33
+ import { PostPlayerInitLateCallbackType } from "../callbacks/subscriptions/postPlayerInitLate";
34
+ import { PostPlayerInitReorderedCallbackType } from "../callbacks/subscriptions/postPlayerInitReordered";
35
+ import { PostPlayerRenderReorderedCallbackType } from "../callbacks/subscriptions/postPlayerRenderReordered";
36
+ import { PostPlayerUpdateReorderedCallbackType } from "../callbacks/subscriptions/postPlayerUpdateReordered";
37
+ import { PostProjectileInitLateCallbackType } from "../callbacks/subscriptions/postProjectileInitLate";
38
+ import { PostPurchaseCallbackType } from "../callbacks/subscriptions/postPurchase";
39
+ import { PostSacrificeCallbackType } from "../callbacks/subscriptions/postSacrifice";
40
+ import { PostSlotAnimationChangedCallbackType } from "../callbacks/subscriptions/postSlotAnimationChanged";
41
+ import { PostSlotDestroyedCallbackType } from "../callbacks/subscriptions/postSlotDestroyed";
42
+ import { PostSlotInitCallbackType } from "../callbacks/subscriptions/postSlotInit";
43
+ import { PostSlotRenderCallbackType } from "../callbacks/subscriptions/postSlotRender";
44
+ import { PostSlotUpdateCallbackType } from "../callbacks/subscriptions/postSlotUpdate";
45
+ import { PostTearInitLateCallbackType } from "../callbacks/subscriptions/postTearInitLate";
46
+ import { PostTearInitVeryLateCallbackType } from "../callbacks/subscriptions/postTearInitVeryLate";
47
+ import { PostTransformationCallbackType } from "../callbacks/subscriptions/postTransformation";
48
+ import { PostTrinketBreakCallbackType } from "../callbacks/subscriptions/postTrinketBreak";
49
+ import { PreBerserkDeathCallbackType } from "../callbacks/subscriptions/preBerserkDeath";
50
+ import { PreCustomReviveCallbackType } from "../callbacks/subscriptions/preCustomRevive";
51
+ import { PreItemPickupCallbackType } from "../callbacks/subscriptions/preItemPickup";
52
+ import { PreNewLevelCallbackType } from "../callbacks/subscriptions/preNewLevel";
53
+ import { ModCallbacksCustom } from "./ModCallbacksCustom";
54
+ export interface AddCallbackParametersCustom {
55
+ [ModCallbacksCustom.MC_POST_GAME_STARTED_REORDERED]: [
56
+ callback: PostGameStartedReorderedCallbackType
57
+ ];
58
+ [ModCallbacksCustom.MC_POST_NEW_LEVEL_REORDERED]: [
59
+ callback: PostNewLevelReorderedCallbackType
60
+ ];
61
+ [ModCallbacksCustom.MC_POST_NEW_ROOM_REORDERED]: [
62
+ callback: PostNewRoomReorderedCallbackType
63
+ ];
64
+ [ModCallbacksCustom.MC_POST_PLAYER_INIT_REORDERED]: [
65
+ callback: PostPlayerInitReorderedCallbackType,
66
+ playerVariant?: PlayerVariant
67
+ ];
68
+ [ModCallbacksCustom.MC_POST_PEFFECT_UPDATE_REORDERED]: [
69
+ callback: PostPEffectUpdateReorderedCallbackType,
70
+ character?: PlayerType | int
71
+ ];
72
+ [ModCallbacksCustom.MC_POST_PLAYER_UPDATE_REORDERED]: [
73
+ callback: PostPlayerUpdateReorderedCallbackType,
74
+ playerVariant?: PlayerVariant
75
+ ];
76
+ [ModCallbacksCustom.MC_POST_PLAYER_RENDER_REORDERED]: [
77
+ callback: PostPlayerRenderReorderedCallbackType,
78
+ playerVariant?: PlayerVariant
79
+ ];
80
+ [ModCallbacksCustom.MC_POST_NEW_ROOM_EARLY]: [
81
+ callback: PostNewRoomEarlyCallbackType
82
+ ];
83
+ [ModCallbacksCustom.MC_PRE_NEW_LEVEL]: [callback: PreNewLevelCallbackType];
84
+ [ModCallbacksCustom.MC_POST_PLAYER_INIT_LATE]: [
85
+ callback: PostPlayerInitLateCallbackType,
86
+ playerVariant?: PlayerVariant
87
+ ];
88
+ [ModCallbacksCustom.MC_POST_TEAR_INIT_LATE]: [
89
+ callback: PostTearInitLateCallbackType,
90
+ tearVariant?: TearVariant | int
91
+ ];
92
+ [ModCallbacksCustom.MC_POST_TEAR_INIT_VERY_LATE]: [
93
+ callback: PostTearInitVeryLateCallbackType,
94
+ tearVariant?: TearVariant | int
95
+ ];
96
+ [ModCallbacksCustom.MC_POST_FAMILIAR_INIT_LATE]: [
97
+ callback: PostFamiliarInitLateCallbackType,
98
+ familiarVariant?: FamiliarVariant | int
99
+ ];
100
+ [ModCallbacksCustom.MC_POST_BOMB_INIT_LATE]: [
101
+ callback: PostBombInitLateCallbackType,
102
+ bombVariant?: BombVariant | int
103
+ ];
104
+ [ModCallbacksCustom.MC_POST_PICKUP_INIT_LATE]: [
105
+ callback: PostPickupInitLateCallbackType,
106
+ pickupVariant?: PickupVariant | int
107
+ ];
108
+ [ModCallbacksCustom.MC_POST_LASER_INIT_LATE]: [
109
+ callback: PostLaserInitLateCallbackType,
110
+ laserVariant?: LaserVariant | int
111
+ ];
112
+ [ModCallbacksCustom.MC_POST_KNIFE_INIT_LATE]: [
113
+ callback: PostKnifeInitLateCallbackType,
114
+ knifeVariant?: KnifeVariant | int
115
+ ];
116
+ [ModCallbacksCustom.MC_POST_PROJECTILE_INIT_LATE]: [
117
+ callback: PostProjectileInitLateCallbackType,
118
+ projectileVariant?: ProjectileVariant | int
119
+ ];
120
+ [ModCallbacksCustom.MC_POST_NPC_INIT_LATE]: [
121
+ callback: PostNPCInitLateCallbackType,
122
+ entityType?: EntityType | int
123
+ ];
124
+ [ModCallbacksCustom.MC_POST_EFFECT_INIT_LATE]: [
125
+ callback: PostEffectInitLateCallbackType,
126
+ effectVariant?: EffectVariant
127
+ ];
128
+ [ModCallbacksCustom.MC_POST_PICKUP_COLLECT]: [
129
+ callback: PostPickupCollectCallbackType,
130
+ pickupVariant?: PickupVariant | int
131
+ ];
132
+ [ModCallbacksCustom.MC_PRE_ITEM_PICKUP]: [
133
+ callback: PreItemPickupCallbackType,
134
+ itemType?: ItemType,
135
+ itemID?: CollectibleType | TrinketType | int
136
+ ];
137
+ [ModCallbacksCustom.MC_POST_ITEM_PICKUP]: [
138
+ callback: PostItemPickupCallbackType,
139
+ itemType?: ItemType,
140
+ itemID?: CollectibleType | TrinketType | int
141
+ ];
142
+ [ModCallbacksCustom.MC_POST_PLAYER_CHANGE_TYPE]: [
143
+ callback: PostPlayerChangeTypeCallbackType
144
+ ];
145
+ [ModCallbacksCustom.MC_POST_PLAYER_CHANGE_HEALTH]: [
146
+ callback: PostPlayerChangeHealthCallbackType,
147
+ playerVariant?: PlayerVariant
148
+ ];
149
+ [ModCallbacksCustom.MC_POST_PLAYER_FATAL_DAMAGE]: [
150
+ callback: PostPlayerFatalDamageCallbackType,
151
+ playerVariant?: PlayerVariant
152
+ ];
153
+ [ModCallbacksCustom.MC_PRE_BERSERK_DEATH]: [
154
+ callback: PreBerserkDeathCallbackType,
155
+ playerVariant?: PlayerVariant
156
+ ];
157
+ [ModCallbacksCustom.MC_PRE_CUSTOM_REVIVE]: [
158
+ callback: PreCustomReviveCallbackType
159
+ ];
160
+ [ModCallbacksCustom.MC_POST_CUSTOM_REVIVE]: [
161
+ callback: PostCustomReviveCallbackType,
162
+ revivalType?: int
163
+ ];
164
+ [ModCallbacksCustom.MC_POST_FLIP]: [callback: PostFlipCallbackType];
165
+ [ModCallbacksCustom.MC_POST_FIRST_FLIP]: [
166
+ callback: PostFirstFlipCallbackType
167
+ ];
168
+ [ModCallbacksCustom.MC_POST_ESAU_JR]: [callback: PostEsauJrCallbackType];
169
+ [ModCallbacksCustom.MC_POST_FIRST_ESAU_JR]: [
170
+ callback: PostFirstEsauJrCallbackType
171
+ ];
172
+ [ModCallbacksCustom.MC_POST_TRANSFORMATION]: [
173
+ callback: PostTransformationCallbackType
174
+ ];
175
+ [ModCallbacksCustom.MC_POST_PURCHASE]: [
176
+ callback: PostPurchaseCallbackType,
177
+ pickupVariant?: PickupVariant | int,
178
+ pickupSubType?: int
179
+ ];
180
+ [ModCallbacksCustom.MC_POST_SACRIFICE]: [callback: PostSacrificeCallbackType];
181
+ [ModCallbacksCustom.MC_POST_CURSED_TELEPORT]: [
182
+ callback: PostCursedTeleportCallbackType
183
+ ];
184
+ [ModCallbacksCustom.MC_POST_TRINKET_BREAK]: [
185
+ callback: PostTrinketBreakCallbackType,
186
+ trinketType?: TrinketType | int
187
+ ];
188
+ [ModCallbacksCustom.MC_POST_SLOT_INIT]: [
189
+ callback: PostSlotInitCallbackType,
190
+ slotVariant?: SlotVariant
191
+ ];
192
+ [ModCallbacksCustom.MC_POST_SLOT_UPDATE]: [
193
+ callback: PostSlotUpdateCallbackType,
194
+ slotVariant?: SlotVariant
195
+ ];
196
+ [ModCallbacksCustom.MC_POST_SLOT_RENDER]: [
197
+ callback: PostSlotRenderCallbackType,
198
+ slotVariant?: SlotVariant
199
+ ];
200
+ [ModCallbacksCustom.MC_POST_SLOT_ANIMATION_CHANGED]: [
201
+ callback: PostSlotAnimationChangedCallbackType,
202
+ slotVariant?: SlotVariant
203
+ ];
204
+ [ModCallbacksCustom.MC_POST_SLOT_DESTROYED]: [
205
+ callback: PostSlotDestroyedCallbackType,
206
+ slotVariant?: SlotVariant
207
+ ];
208
+ [ModCallbacksCustom.MC_POST_GRID_ENTITY_INIT]: [
209
+ callback: PostGridEntityInitCallbackType,
210
+ gridEntityType?: GridEntityType
211
+ ];
212
+ [ModCallbacksCustom.MC_POST_GRID_ENTITY_UPDATE]: [
213
+ callback: PostGridEntityUpdateCallbackType,
214
+ gridEntityType?: GridEntityType
215
+ ];
216
+ [ModCallbacksCustom.MC_POST_GRID_ENTITY_REMOVE]: [
217
+ callback: PostGridEntityRemoveCallbackType,
218
+ gridEntityType?: GridEntityType
219
+ ];
220
+ [ModCallbacksCustom.MC_POST_GRID_ENTITY_STATE_CHANGE]: [
221
+ callback: PostGridEntityStateChangeCallbackType,
222
+ gridEntityType?: GridEntityType
223
+ ];
224
+ [ModCallbacksCustom.MC_POST_GRID_ENTITY_BROKEN]: [
225
+ callback: PostGridEntityBrokenCallbackType,
226
+ gridEntityType?: GridEntityType
227
+ ];
228
+ [ModCallbacksCustom.MC_POST_GRID_ENTITY_COLLISION]: [
229
+ callback: PostGridEntityCollisionCallbackType,
230
+ gridEntityType?: GridEntityType
231
+ ];
232
+ [ModCallbacksCustom.MC_POST_BONE_SWING]: [
233
+ callback: PostBoneSwingCallbackType
234
+ ];
235
+ [ModCallbacksCustom.MC_POST_CUSTOM_DOOR_ENTER]: [
236
+ callback: PostCustomDoorEnterCallbackType,
237
+ effectVariant?: int
238
+ ];
239
+ }
@@ -0,0 +1,5 @@
1
+ --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
+ local ____exports = {}
3
+ local ____ModCallbacksCustom = require("types.ModCallbacksCustom")
4
+ local ModCallbacksCustom = ____ModCallbacksCustom.ModCallbacksCustom
5
+ return ____exports
@@ -233,6 +233,7 @@ export interface CallbackParametersCustom {
233
233
  callback: PostBoneSwingCallbackType
234
234
  ];
235
235
  [ModCallbacksCustom.MC_POST_CUSTOM_DOOR_ENTER]: [
236
- callback: PostCustomDoorEnterCallbackType
236
+ callback: PostCustomDoorEnterCallbackType,
237
+ effectVariant?: int
237
238
  ];
238
239
  }
@@ -1,5 +1,6 @@
1
1
  /// <reference types="isaac-typescript-definitions" />
2
- import { CallbackParametersCustom } from "./CallbackParametersCustom";
2
+ import { AddCallbackParametersCustom } from "./AddCallbackParametersCustom";
3
+ import { ModCallbacksCustom } from "./ModCallbacksCustom";
3
4
  /** `isaacscript-common` allows for custom callbacks, so it provides an upgraded Mod object. */
4
5
  export declare class ModUpgraded implements Mod {
5
6
  Name: string;
@@ -8,11 +9,11 @@ export declare class ModUpgraded implements Mod {
8
9
  /** End-users can optionally enable verbose-mode, which helps troubleshoot crashes. */
9
10
  Verbose: boolean;
10
11
  constructor(mod: Mod, verbose: boolean);
11
- AddCallback<T extends keyof CallbackParameters>(callbackID: T, ...args: CallbackParameters[T]): void;
12
+ AddCallback<T extends ModCallbacks>(modCallbacks: T, ...args: AddCallbackParameters[T]): void;
12
13
  HasData(): boolean;
13
14
  LoadData(): string;
14
15
  RemoveCallback(callbackID: ModCallbacks, callback: () => void): void;
15
16
  RemoveData(): void;
16
17
  SaveData(data: string): void;
17
- AddCallbackCustom<T extends keyof CallbackParametersCustom>(callbackID: T, ...args: CallbackParametersCustom[T]): void;
18
+ AddCallbackCustom<T extends ModCallbacksCustom>(modCallbacksCustom: T, ...args: AddCallbackParametersCustom[T]): void;
18
19
  }
@@ -27,12 +27,12 @@ function ModUpgraded.prototype.____constructor(self, mod, verbose)
27
27
  self.Mod = mod
28
28
  self.Verbose = verbose
29
29
  end
30
- function ModUpgraded.prototype.AddCallback(self, callbackID, ...)
30
+ function ModUpgraded.prototype.AddCallback(self, modCallbacks, ...)
31
31
  local args = {...}
32
32
  if self.Verbose then
33
33
  local callback = args[1]
34
34
  local optionalArg = args[2]
35
- local callbackName = getCallbackName(nil, callbackID)
35
+ local callbackName = getCallbackName(nil, modCallbacks)
36
36
  local debugMsg = getDebugPrependString(nil, callbackName)
37
37
  local function callbackWithLogger(____, ...)
38
38
  Isaac.DebugString(debugMsg .. " - START")
@@ -40,10 +40,10 @@ function ModUpgraded.prototype.AddCallback(self, callbackID, ...)
40
40
  Isaac.DebugString((debugMsg .. " - END - ") .. tostring(value))
41
41
  return value
42
42
  end
43
- self.Mod:AddCallback(callbackID, callbackWithLogger, optionalArg)
43
+ self.Mod:AddCallback(modCallbacks, callbackWithLogger, optionalArg)
44
44
  else
45
45
  self.Mod:AddCallback(
46
- callbackID,
46
+ modCallbacks,
47
47
  __TS__Spread(args)
48
48
  )
49
49
  end
@@ -63,10 +63,10 @@ end
63
63
  function ModUpgraded.prototype.SaveData(self, data)
64
64
  self.Mod:SaveData(data)
65
65
  end
66
- function ModUpgraded.prototype.AddCallbackCustom(self, callbackID, ...)
67
- local callbackRegisterFunction = CALLBACK_REGISTER_FUNCTIONS[callbackID]
66
+ function ModUpgraded.prototype.AddCallbackCustom(self, modCallbacksCustom, ...)
67
+ local callbackRegisterFunction = CALLBACK_REGISTER_FUNCTIONS[modCallbacksCustom]
68
68
  if callbackRegisterFunction == nil then
69
- error("Failed to find a callback registration function for custom callback: " .. tostring(callbackID))
69
+ error("Failed to find a callback registration function for custom callback: " .. tostring(modCallbacksCustom))
70
70
  end
71
71
  callbackRegisterFunction(nil, ...)
72
72
  end
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "1.2.154",
3
+ "version": "1.2.157",
4
4
  "description": "Helper functions for IsaacScript mods",
5
5
  "keywords": [
6
6
  "isaac",
@@ -26,8 +26,8 @@
26
26
  ],
27
27
  "devDependencies": {
28
28
  "@zamiell/typescript-to-lua": "^1.4.2",
29
- "isaac-typescript-definitions": "^1.0.366",
30
- "isaacscript-lint": "^1.0.89",
29
+ "isaac-typescript-definitions": "^1.0.369",
30
+ "isaacscript-lint": "^1.0.90",
31
31
  "isaacscript-tsconfig": "^1.1.8",
32
32
  "typedoc": "^0.22.13",
33
33
  "typescript": "4.5.5"