isaacscript-common 1.2.153 → 1.2.156

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,21 @@
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
+ * Handle when a player enters the door by hooking the custom `MC_POST_CUSTOM_DOOR_ENTER` callback.
32
+ *
33
+ * The custom door is an `EntityEffect`. You can manually open or close the door by modifying its
34
+ * state. (The values to use correspond to the `DoorState` enum.)
35
+ *
36
+ * This function will throw a runtime error if:
37
+ * - the door slot already has a vanilla door
38
+ * - the door slot already has a custom door
39
+ * - the tile at the door slot does not have a wall
40
+ *
41
+ * Before using this function, you must first initialize the effect/door variant with the
42
+ * `initCustomDoor` function.
31
43
  */
32
- export declare function spawnCustomDoor(effectVariant: int, doorSlot: DoorSlot): void;
44
+ export declare function spawnCustomDoor(effectVariant: int, doorSlot: DoorSlot): EntityEffect;
@@ -4,14 +4,17 @@ 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, getPositionOffset, getAnimation, POSITION_OFFSET_MULTIPLIER
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")
11
11
  local saveDataManager = ____exports.saveDataManager
12
12
  local ____doors = require("functions.doors")
13
13
  local doorSlotToDirection = ____doors.doorSlotToDirection
14
- local getDoors = ____doors.getDoors
14
+ local ____player = require("functions.player")
15
+ local getClosestPlayer = ____player.getClosestPlayer
16
+ local ____utils = require("functions.utils")
17
+ local ensureAllCases = ____utils.ensureAllCases
15
18
  local ____vector = require("functions.vector")
16
19
  local directionToVector = ____vector.directionToVector
17
20
  local ____postCustomDoorEnter = require("callbacks.subscriptions.postCustomDoorEnter")
@@ -20,35 +23,43 @@ local postCustomDoorEnterHasSubscriptions = ____postCustomDoorEnter.postCustomDo
20
23
  function hasSubscriptions(self)
21
24
  return postCustomDoorEnterHasSubscriptions(nil)
22
25
  end
23
- function postEffectRenderCustomEntity(self)
24
- 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
25
30
  return
26
31
  end
27
- local doors = getDoors(nil)
28
- if #doors == 0 then
32
+ if doorData.state == effect.State then
29
33
  return
30
34
  end
31
- local door = doors[1]
32
- postCustomDoorEnterFire(nil, door)
35
+ doorData.state = effect.State
36
+ doorChangedState(nil, effect)
33
37
  end
34
- function getPositionOffset(self, doorSlot)
35
- local direction = doorSlotToDirection(nil, doorSlot)
36
- local vector = directionToVector(nil, direction)
37
- return vector * POSITION_OFFSET_MULTIPLIER
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
38
48
  end
39
- function getAnimation(self, effect)
49
+ function getAnimationForCustomDoor(self, effect)
50
+ local freshlySpawned = effect.FrameCount == 0
40
51
  repeat
41
- local ____switch15 = effect.State
42
- local ____cond15 = ____switch15 == DoorState.STATE_OPEN
43
- if ____cond15 then
52
+ local ____switch11 = effect.State
53
+ local ____cond11 = ____switch11 == DoorState.STATE_OPEN
54
+ if ____cond11 then
44
55
  do
45
- return "Opened"
56
+ return freshlySpawned and "Opened" or "Open"
46
57
  end
47
58
  end
48
- ____cond15 = ____cond15 or ____switch15 == DoorState.STATE_CLOSED
49
- if ____cond15 then
59
+ ____cond11 = ____cond11 or ____switch11 == DoorState.STATE_CLOSED
60
+ if ____cond11 then
50
61
  do
51
- return "Closed"
62
+ return freshlySpawned and "Closed" or "Close"
52
63
  end
53
64
  end
54
65
  do
@@ -58,23 +69,101 @@ function getAnimation(self, effect)
58
69
  end
59
70
  until true
60
71
  end
61
- POSITION_OFFSET_MULTIPLIER = 23
72
+ function postEffectRenderCustomEntity(self, effect)
73
+ local ptrHash = GetPtrHash(effect)
74
+ local doorData = v.room.customDoors:get(ptrHash)
75
+ if doorData == nil then
76
+ return
77
+ end
78
+ local direction = doorSlotToDirection(nil, doorData.slot)
79
+ local player = getClosestPlayer(nil, effect.Position)
80
+ if isPlayerPastDoorThreshold(nil, effect, player, direction) then
81
+ postCustomDoorEnterFire(
82
+ nil,
83
+ player,
84
+ effect.Variant,
85
+ doorData.slot,
86
+ direction
87
+ )
88
+ end
89
+ end
90
+ function isPlayerPastDoorThreshold(self, effect, player, direction)
91
+ repeat
92
+ local ____switch19 = direction
93
+ local ____cond19 = ____switch19 == Direction.NO_DIRECTION
94
+ if ____cond19 then
95
+ do
96
+ return false
97
+ end
98
+ end
99
+ ____cond19 = ____cond19 or ____switch19 == Direction.UP
100
+ if ____cond19 then
101
+ do
102
+ return player.Position.Y <= effect.Position.Y
103
+ end
104
+ end
105
+ ____cond19 = ____cond19 or ____switch19 == Direction.RIGHT
106
+ if ____cond19 then
107
+ do
108
+ return player.Position.X >= effect.Position.X
109
+ end
110
+ end
111
+ ____cond19 = ____cond19 or ____switch19 == Direction.DOWN
112
+ if ____cond19 then
113
+ do
114
+ return player.Position.Y >= effect.Position.Y
115
+ end
116
+ end
117
+ ____cond19 = ____cond19 or ____switch19 == Direction.LEFT
118
+ if ____cond19 then
119
+ do
120
+ return player.Position.X <= effect.Position.X
121
+ end
122
+ end
123
+ do
124
+ do
125
+ return ensureAllCases(nil, direction)
126
+ end
127
+ end
128
+ until true
129
+ end
130
+ function getPositionOffset(self, doorSlot)
131
+ local direction = doorSlotToDirection(nil, doorSlot)
132
+ local vector = directionToVector(nil, direction)
133
+ return vector * POSITION_OFFSET_MULTIPLIER
134
+ end
135
+ POSITION_OFFSET_MULTIPLIER = -23
62
136
  local initializedEffectVariants = __TS__New(Set)
63
- local v = {room = {doors = __TS__New(Map)}}
137
+ v = {room = {
138
+ customDoors = __TS__New(Map),
139
+ customDoorSlots = __TS__New(Set)
140
+ }}
64
141
  function ____exports.postCustomDoorEnterCallbackInit(self)
65
142
  saveDataManager(nil, "postCustomDoorEnter", v, hasSubscriptions)
66
143
  end
67
144
  function ____exports.initCustomDoor(self, mod, effectVariant)
68
145
  initializedEffectVariants:add(effectVariant)
146
+ mod:AddCallback(ModCallbacks.MC_POST_EFFECT_UPDATE, postEffectUpdaterCustomEntity, effectVariant)
69
147
  mod:AddCallback(ModCallbacks.MC_POST_EFFECT_RENDER, postEffectRenderCustomEntity, effectVariant)
70
148
  end
71
149
  function ____exports.spawnCustomDoor(self, effectVariant, doorSlot)
72
150
  if not initializedEffectVariants:has(effectVariant) then
73
151
  error("In order to spawn custom doors, you must first initialize them with the \"initCustomDoor\" function at the beginning of your mod.")
74
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
75
156
  local room = game:GetRoom()
76
157
  local roomClear = room:IsClear()
77
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
78
167
  local effect = Isaac.Spawn(
79
168
  EntityType.ENTITY_EFFECT,
80
169
  effectVariant,
@@ -90,15 +179,12 @@ function ____exports.spawnCustomDoor(self, effectVariant, doorSlot)
90
179
  effect.RenderZOffset = -10000
91
180
  effect.PositionOffset = getPositionOffset(nil, doorSlot)
92
181
  local sprite = effect:GetSprite()
93
- local animation = getAnimation(nil, effect)
94
- sprite:Play(animation, true)
95
182
  sprite.Rotation = doorSlot * 90 - 90
96
- if effect.State == DoorState.STATE_OPEN then
97
- local gridIndex = room:GetGridIndex(position)
98
- local wall = room:GetGridEntity(gridIndex)
99
- if wall ~= nil then
100
- wall.CollisionClass = GridCollisionClass.COLLISION_WALL_EXCEPT_PLAYER
101
- end
102
- 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
103
189
  end
104
190
  return ____exports
@@ -1,2 +1,2 @@
1
1
  /// <reference types="isaac-typescript-definitions" />
2
- export declare type PostCustomDoorEnterCallbackType = (door: GridEntityDoor) => void;
2
+ export declare type PostCustomDoorEnterCallbackType = (player: EntityPlayer, effectVariant: int, doorSlot: DoorSlot, direction: Direction) => void;
@@ -6,18 +6,24 @@ local subscriptions = {}
6
6
  function ____exports.postCustomDoorEnterHasSubscriptions(self)
7
7
  return #subscriptions > 0
8
8
  end
9
- function ____exports.postCustomDoorEnterRegister(self, callback, doorVariant)
10
- __TS__ArrayPush(subscriptions, {callback, doorVariant})
9
+ function ____exports.postCustomDoorEnterRegister(self, callback, effectVariant)
10
+ __TS__ArrayPush(subscriptions, {callback, effectVariant})
11
11
  end
12
- function ____exports.postCustomDoorEnterFire(self, door)
12
+ function ____exports.postCustomDoorEnterFire(self, player, effectVariant, doorSlot, direction)
13
13
  for ____, ____value in ipairs(subscriptions) do
14
14
  local callback = ____value[1]
15
- local doorVariant = ____value[2]
15
+ local callbackEffectVariant = ____value[2]
16
16
  do
17
- if doorVariant ~= nil and doorVariant ~= door:GetVariant() then
17
+ if callbackEffectVariant ~= nil and callbackEffectVariant ~= effectVariant then
18
18
  goto __continue5
19
19
  end
20
- callback(nil, door)
20
+ callback(
21
+ nil,
22
+ player,
23
+ effectVariant,
24
+ doorSlot,
25
+ direction
26
+ )
21
27
  end
22
28
  ::__continue5::
23
29
  end
@@ -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)
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
  };
@@ -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.153",
3
+ "version": "1.2.156",
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"