isaacscript-common 1.2.147 → 1.2.150

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.
@@ -1,6 +1,6 @@
1
1
  --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
2
  local ____exports = {}
3
- local hasSubscriptions, postRender, postPEffectUpdateReordered, checkWaitingForItemAnimation, postPlayerFatalDamage, preBerserkDeath, playerIsAboutToDie, CustomReviveState, v
3
+ local hasSubscriptions, postRender, postNewRoom, postPEffectUpdateReordered, checkWaitingForItemAnimation, postPlayerFatalDamage, preBerserkDeath, playerIsAboutToDie, logStateChanged, DEBUG, CustomReviveState, v
4
4
  local ____cachedClasses = require("cachedClasses")
5
5
  local sfxManager = ____cachedClasses.sfxManager
6
6
  local ____runInNFrames = require("features.runInNFrames")
@@ -11,6 +11,8 @@ local ____collectibles = require("functions.collectibles")
11
11
  local removeCollectibleFromItemTracker = ____collectibles.removeCollectibleFromItemTracker
12
12
  local ____familiars = require("functions.familiars")
13
13
  local removeAllFamiliars = ____familiars.removeAllFamiliars
14
+ local ____log = require("functions.log")
15
+ local log = ____log.log
14
16
  local ____player = require("functions.player")
15
17
  local getPlayerFromIndex = ____player.getPlayerFromIndex
16
18
  local getPlayerIndex = ____player.getPlayerIndex
@@ -31,6 +33,13 @@ function postRender(self)
31
33
  end
32
34
  sfxManager:Stop(SoundEffect.SOUND_1UP)
33
35
  end
36
+ function postNewRoom(self)
37
+ if v.run.state ~= CustomReviveState.WAITING_FOR_ROOM_TRANSITION then
38
+ return
39
+ end
40
+ v.run.state = CustomReviveState.WAITING_FOR_ITEM_ANIMATION
41
+ logStateChanged(nil)
42
+ end
34
43
  function postPEffectUpdateReordered(self, player)
35
44
  checkWaitingForItemAnimation(nil, player)
36
45
  end
@@ -62,6 +71,7 @@ function checkWaitingForItemAnimation(self, player)
62
71
  v.run.state = CustomReviveState.DISABLED
63
72
  v.run.revivalType = nil
64
73
  v.run.dyingPlayerIndex = nil
74
+ logStateChanged(nil)
65
75
  end
66
76
  function postPlayerFatalDamage(self, player)
67
77
  if not hasSubscriptions(nil) then
@@ -80,9 +90,10 @@ function playerIsAboutToDie(self, player)
80
90
  if revivalType == nil then
81
91
  return
82
92
  end
83
- v.run.state = CustomReviveState.WAITING_FOR_ITEM_ANIMATION
93
+ v.run.state = CustomReviveState.WAITING_FOR_ROOM_TRANSITION
84
94
  v.run.revivalType = revivalType
85
95
  v.run.dyingPlayerIndex = getPlayerIndex(nil, player)
96
+ logStateChanged(nil)
86
97
  player:AddCollectible(CollectibleType.COLLECTIBLE_1UP, 0, false)
87
98
  removeAllFamiliars(nil, FamiliarVariant.ONE_UP)
88
99
  removeCollectibleFromItemTracker(nil, CollectibleType.COLLECTIBLE_1UP)
@@ -108,15 +119,24 @@ function playerIsAboutToDie(self, player)
108
119
  end
109
120
  )
110
121
  end
122
+ function logStateChanged(self)
123
+ if DEBUG then
124
+ log(((("Custom revive state changed: " .. CustomReviveState[v.run.state]) .. " (") .. tostring(v.run.state)) .. ")")
125
+ end
126
+ end
127
+ DEBUG = false
111
128
  CustomReviveState = CustomReviveState or ({})
112
129
  CustomReviveState.DISABLED = 0
113
130
  CustomReviveState[CustomReviveState.DISABLED] = "DISABLED"
114
- CustomReviveState.WAITING_FOR_ITEM_ANIMATION = 1
131
+ CustomReviveState.WAITING_FOR_ROOM_TRANSITION = 1
132
+ CustomReviveState[CustomReviveState.WAITING_FOR_ROOM_TRANSITION] = "WAITING_FOR_ROOM_TRANSITION"
133
+ CustomReviveState.WAITING_FOR_ITEM_ANIMATION = 2
115
134
  CustomReviveState[CustomReviveState.WAITING_FOR_ITEM_ANIMATION] = "WAITING_FOR_ITEM_ANIMATION"
116
135
  v = {run = {state = CustomReviveState.DISABLED, revivalType = nil, dyingPlayerIndex = nil}}
117
136
  function ____exports.customReviveCallbacksInit(self, mod)
118
137
  saveDataManager(nil, "customRevive", v, hasSubscriptions)
119
138
  mod:AddCallback(ModCallbacks.MC_POST_RENDER, postRender)
139
+ mod:AddCallback(ModCallbacks.MC_POST_NEW_ROOM, postNewRoom)
120
140
  mod:AddCallbackCustom(ModCallbacksCustom.MC_POST_PEFFECT_UPDATE_REORDERED, postPEffectUpdateReordered)
121
141
  mod:AddCallbackCustom(ModCallbacksCustom.MC_POST_PLAYER_FATAL_DAMAGE, postPlayerFatalDamage)
122
142
  mod:AddCallbackCustom(ModCallbacksCustom.MC_PRE_BERSERK_DEATH, preBerserkDeath)
@@ -43,8 +43,9 @@ export declare function addRoomClearCharge(player: EntityPlayer, ignoreBigRoomDo
43
43
  export declare function addRoomClearChargeToSlot(player: EntityPlayer, activeSlot: ActiveSlot, ignoreBigRoomDoubleCharge?: boolean): void;
44
44
  /**
45
45
  * Helper function to get the combined normal charge and the battery charge for the player's active
46
- * item. Use this to avoid having to manually retrieve these two values and add them together.
46
+ * item. This is useful because you have to add these two values together when setting the active
47
+ * charge.
47
48
  */
48
- export declare function getActiveCharge(player: EntityPlayer): int;
49
+ export declare function getTotalCharge(player: EntityPlayer, activeSlot: ActiveSlot): int;
49
50
  export declare function isActiveSlotDoubleCharged(player: EntityPlayer, activeSlot: ActiveSlot): boolean;
50
51
  export declare function playChargeSoundEffect(player: EntityPlayer, activeSlot: ActiveSlot): void;
@@ -8,7 +8,6 @@ local ____collectibles = require("functions.collectibles")
8
8
  local getCollectibleMaxCharges = ____collectibles.getCollectibleMaxCharges
9
9
  local ____player = require("functions.player")
10
10
  local getPlayers = ____player.getPlayers
11
- local getTotalCharge = ____player.getTotalCharge
12
11
  function ____exports.addRoomClearCharge(self, player, ignoreBigRoomDoubleCharge)
13
12
  if ignoreBigRoomDoubleCharge == nil then
14
13
  ignoreBigRoomDoubleCharge = false
@@ -25,7 +24,7 @@ function ____exports.addRoomClearChargeToSlot(self, player, activeSlot, ignoreBi
25
24
  return
26
25
  end
27
26
  local hud = game:GetHUD()
28
- local totalCharge = getTotalCharge(nil, player, activeSlot)
27
+ local totalCharge = ____exports.getTotalCharge(nil, player, activeSlot)
29
28
  local chargesToAdd = getNumChargesToAdd(nil, player, activeSlot, ignoreBigRoomDoubleCharge)
30
29
  local modifiedChargesToAdd = getNumChargesWithAAAModifier(nil, player, activeSlot, chargesToAdd)
31
30
  local newCharge = totalCharge + modifiedChargesToAdd
@@ -61,6 +60,11 @@ function getNumChargesToAdd(self, player, activeSlot, ignoreBigRoomDoubleCharge)
61
60
  end
62
61
  return 1
63
62
  end
63
+ function ____exports.getTotalCharge(self, player, activeSlot)
64
+ local activeCharge = player:GetActiveCharge(activeSlot)
65
+ local batteryCharge = player:GetBatteryCharge(activeSlot)
66
+ return activeCharge + batteryCharge
67
+ end
64
68
  function getNumChargesWithAAAModifier(self, player, activeSlot, chargesToAdd)
65
69
  local activeItem = player:GetActiveItem(activeSlot)
66
70
  local activeCharge = player:GetActiveCharge(activeSlot)
@@ -105,11 +109,6 @@ function ____exports.addRoomClearCharges(self, ignoreBigRoomDoubleCharge)
105
109
  ____exports.addRoomClearCharge(nil, player, ignoreBigRoomDoubleCharge)
106
110
  end
107
111
  end
108
- function ____exports.getActiveCharge(self, player)
109
- local charge = player:GetActiveCharge()
110
- local batteryCharge = player:GetBatteryCharge()
111
- return charge + batteryCharge
112
- end
113
112
  function ____exports.isActiveSlotDoubleCharged(self, player, activeSlot)
114
113
  local collectibleType = player:GetActiveItem(activeSlot)
115
114
  local batteryCharge = player:GetBatteryCharge(activeSlot)
@@ -239,11 +239,6 @@ export declare function getSubPlayerParent(subPlayer: EntitySubPlayer): EntityPl
239
239
  * should be accomplished before invoking this function.
240
240
  */
241
241
  export declare function getTaintedMagdaleneNonTemporaryMaxHearts(player: EntityPlayer): int;
242
- /**
243
- * Helper function to return the active charge and the battery charge combined. This is useful
244
- * because you are not able to set the battery charge directly.
245
- */
246
- export declare function getTotalCharge(player: EntityPlayer, activeSlot: ActiveSlot): int;
247
242
  /**
248
243
  * Returns the total number of collectibles amongst all players. For example, if player 1 has 1 Sad
249
244
  * Onion and player 2 has 2 Sad Onions, then this function would return 3.
@@ -259,6 +254,7 @@ export declare function hasLostCurse(player: EntityPlayer): boolean;
259
254
  * items. (Only Tainted Forgotten can pick up items.)
260
255
  */
261
256
  export declare function hasOpenActiveItemSlot(player: EntityPlayer): boolean;
257
+ export declare function isActiveSlotEmpty(player: EntityPlayer, activeSlot: ActiveSlot): boolean;
262
258
  /**
263
259
  * Helper function for detecting when a player is Bethany or Tainted Bethany. This is useful if you
264
260
  * need to adjust UI elements to account for Bethany's soul charges or Tainted Bethany's blood
@@ -471,11 +471,6 @@ function ____exports.getTaintedMagdaleneNonTemporaryMaxHearts(self, player)
471
471
  local maxNonTemporaryMaxHearts = hasBirthright and 6 or 4
472
472
  return math.min(maxHearts, maxNonTemporaryMaxHearts)
473
473
  end
474
- function ____exports.getTotalCharge(self, player, activeSlot)
475
- local activeCharge = player:GetActiveCharge(activeSlot)
476
- local batteryCharge = player:GetBatteryCharge(activeSlot)
477
- return activeCharge + batteryCharge
478
- end
479
474
  function ____exports.getTotalPlayerCollectibles(self, collectibleType)
480
475
  local players = ____exports.getPlayers(nil)
481
476
  local numCollectiblesArray = __TS__ArrayMap(
@@ -501,6 +496,10 @@ function ____exports.hasOpenActiveItemSlot(self, player)
501
496
  end
502
497
  return activeItemPrimary == CollectibleType.COLLECTIBLE_NULL
503
498
  end
499
+ function ____exports.isActiveSlotEmpty(self, player, activeSlot)
500
+ local activeCollectibleType = player:GetActiveItem(activeSlot)
501
+ return activeCollectibleType == CollectibleType.COLLECTIBLE_NULL
502
+ end
504
503
  function ____exports.isBethany(self, player)
505
504
  local character = player:GetPlayerType()
506
505
  return character == PlayerType.PLAYER_BETHANY or character == PlayerType.PLAYER_BETHANY_B
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "1.2.147",
3
+ "version": "1.2.150",
4
4
  "description": "Helper functions for IsaacScript mods",
5
5
  "keywords": [
6
6
  "isaac",
@@ -27,7 +27,7 @@
27
27
  "devDependencies": {
28
28
  "@zamiell/typescript-to-lua": "^1.4.2",
29
29
  "isaac-typescript-definitions": "^1.0.364",
30
- "isaacscript-lint": "^1.0.88",
30
+ "isaacscript-lint": "^1.0.89",
31
31
  "isaacscript-tsconfig": "^1.1.8",
32
32
  "typedoc": "^0.22.13",
33
33
  "typescript": "4.5.5"