isaacscript-common 1.2.115 → 1.2.118

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, postNewRoom, postPEffectUpdateReordered, checkWaitingForItemAnimation, postPlayerFatalDamage, preBerserkDeath, playerIsAboutToDie, CustomReviveState, v
3
+ local hasSubscriptions, postRender, postPEffectUpdateReordered, checkWaitingForItemAnimation, postPlayerFatalDamage, preBerserkDeath, playerIsAboutToDie, CustomReviveState, v
4
4
  local ____exports = require("features.saveDataManager.exports")
5
5
  local saveDataManager = ____exports.saveDataManager
6
6
  local ____collectibles = require("functions.collectibles")
@@ -27,15 +27,6 @@ function postRender(self)
27
27
  local sfx = SFXManager()
28
28
  sfx:Stop(SoundEffect.SOUND_1UP)
29
29
  end
30
- function postNewRoom(self)
31
- if v.run.state == CustomReviveState.CHANGING_ROOMS then
32
- v.run.state = CustomReviveState.WAITING_FOR_ITEM_ANIMATION
33
- elseif v.run.state == CustomReviveState.WAITING_FOR_ITEM_ANIMATION then
34
- v.run.state = CustomReviveState.DISABLED
35
- v.run.revivalType = nil
36
- v.run.dyingPlayerIndex = nil
37
- end
38
- end
39
30
  function postPEffectUpdateReordered(self, player)
40
31
  checkWaitingForItemAnimation(nil, player)
41
32
  end
@@ -85,7 +76,7 @@ function playerIsAboutToDie(self, player)
85
76
  if revivalType == nil then
86
77
  return
87
78
  end
88
- v.run.state = CustomReviveState.CHANGING_ROOMS
79
+ v.run.state = CustomReviveState.WAITING_FOR_ITEM_ANIMATION
89
80
  v.run.revivalType = revivalType
90
81
  v.run.dyingPlayerIndex = getPlayerIndex(nil, player)
91
82
  player:AddCollectible(CollectibleType.COLLECTIBLE_1UP, 0, false)
@@ -95,15 +86,12 @@ end
95
86
  CustomReviveState = CustomReviveState or ({})
96
87
  CustomReviveState.DISABLED = 0
97
88
  CustomReviveState[CustomReviveState.DISABLED] = "DISABLED"
98
- CustomReviveState.CHANGING_ROOMS = 1
99
- CustomReviveState[CustomReviveState.CHANGING_ROOMS] = "CHANGING_ROOMS"
100
- CustomReviveState.WAITING_FOR_ITEM_ANIMATION = 2
89
+ CustomReviveState.WAITING_FOR_ITEM_ANIMATION = 1
101
90
  CustomReviveState[CustomReviveState.WAITING_FOR_ITEM_ANIMATION] = "WAITING_FOR_ITEM_ANIMATION"
102
91
  v = {run = {state = CustomReviveState.DISABLED, revivalType = nil, dyingPlayerIndex = nil}}
103
92
  function ____exports.customReviveCallbacksInit(self, mod)
104
93
  saveDataManager(nil, "customRevive", v, hasSubscriptions)
105
94
  mod:AddCallback(ModCallbacks.MC_POST_RENDER, postRender)
106
- mod:AddCallback(ModCallbacks.MC_POST_NEW_ROOM, postNewRoom)
107
95
  mod:AddCallbackCustom(ModCallbacksCustom.MC_POST_PEFFECT_UPDATE_REORDERED, postPEffectUpdateReordered)
108
96
  mod:AddCallbackCustom(ModCallbacksCustom.MC_POST_PLAYER_FATAL_DAMAGE, postPlayerFatalDamage)
109
97
  mod:AddCallbackCustom(ModCallbacksCustom.MC_PRE_BERSERK_DEATH, preBerserkDeath)
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Helper function to stop muting all sound effects and music.
3
+ *
4
+ * Use this function to set things back to normal after having used [[`disableAllSounds`]].
5
+ *
6
+ * @param key The name of the mod feature that is requesting the enable/disable. This is needed so
7
+ * that multiple mod features can work in tandem.
8
+ */
9
+ export declare function enableAllSound(key: string): void;
10
+ /**
11
+ * Helper function to disable all sound effects and music (by constantly musting them).
12
+ *
13
+ * Use the [[`enableAllSounds`]] helper function to set things back to normal.
14
+ *
15
+ * @param key The name of the mod feature that is requesting the enable/disable. This is needed so
16
+ * that multiple mod features can work in tandem.
17
+ */
18
+ export declare function disableAllSound(key: string): void;
@@ -0,0 +1,53 @@
1
+ --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
+ local ____lualib = require("lualib_bundle")
3
+ local Set = ____lualib.Set
4
+ local __TS__New = ____lualib.__TS__New
5
+ local ____exports = {}
6
+ local postRender, v
7
+ local ____errors = require("errors")
8
+ local getUpgradeErrorMsg = ____errors.getUpgradeErrorMsg
9
+ local ____sound = require("functions.sound")
10
+ local stopAllSoundEffects = ____sound.stopAllSoundEffects
11
+ local ____exports = require("features.saveDataManager.exports")
12
+ local saveDataManager = ____exports.saveDataManager
13
+ function postRender(self)
14
+ if v.run.disableSoundSet.size == 0 then
15
+ return
16
+ end
17
+ stopAllSoundEffects(nil)
18
+ end
19
+ local FEATURE_NAME = "sound disabler"
20
+ local initialized = false
21
+ local musicWasEnabled = false
22
+ v = {run = {disableSoundSet = __TS__New(Set)}}
23
+ function ____exports.disableSoundsInit(self, mod)
24
+ initialized = true
25
+ saveDataManager(nil, "disableInputs", v)
26
+ mod:AddCallback(ModCallbacks.MC_POST_RENDER, postRender)
27
+ end
28
+ function ____exports.enableAllSound(self, key)
29
+ if not initialized then
30
+ local msg = getUpgradeErrorMsg(nil, FEATURE_NAME)
31
+ error(msg)
32
+ end
33
+ if not v.run.disableSoundSet:has(key) then
34
+ return
35
+ end
36
+ v.run.disableSoundSet:delete(key)
37
+ if v.run.disableSoundSet.size == 0 and musicWasEnabled then
38
+ local musicManager = MusicManager()
39
+ musicManager:Enable()
40
+ end
41
+ end
42
+ function ____exports.disableAllSound(self, key)
43
+ if not initialized then
44
+ local msg = getUpgradeErrorMsg(nil, FEATURE_NAME)
45
+ error(msg)
46
+ end
47
+ if v.run.disableSoundSet.size == 0 then
48
+ local musicManager = MusicManager()
49
+ musicWasEnabled = musicManager:IsEnabled()
50
+ end
51
+ v.run.disableSoundSet:add(key)
52
+ end
53
+ return ____exports
@@ -218,7 +218,7 @@ export declare function getSubPlayerParent(subPlayer: EntitySubPlayer): EntityPl
218
218
  * This function does not validate whether or not the provided player is Tainted Magdalene; that
219
219
  * should be accomplished before invoking this function.
220
220
  */
221
- export declare function getTaintedMagdaleneNonTemporaryMaxHearts(player: EntityPlayer): 4 | 6;
221
+ export declare function getTaintedMagdaleneNonTemporaryMaxHearts(player: EntityPlayer): number;
222
222
  /**
223
223
  * Helper function to return the active charge and the battery charge combined. This is useful
224
224
  * because you are not able to set the battery charge directly.
@@ -504,8 +504,10 @@ function ____exports.getSoulHearts(self, player)
504
504
  return soulHearts - blackHearts
505
505
  end
506
506
  function ____exports.getTaintedMagdaleneNonTemporaryMaxHearts(self, player)
507
+ local maxHearts = player:GetMaxHearts()
507
508
  local hasBirthright = player:HasCollectible(CollectibleType.COLLECTIBLE_BIRTHRIGHT)
508
- return hasBirthright and 6 or 4
509
+ local maxNonTemporaryMaxHearts = hasBirthright and 6 or 4
510
+ return math.min(maxHearts, maxNonTemporaryMaxHearts)
509
511
  end
510
512
  function ____exports.getTotalCharge(self, player, activeSlot)
511
513
  local activeCharge = player:GetActiveCharge(activeSlot)
package/dist/index.d.ts CHANGED
@@ -2,6 +2,7 @@ export { forceNewLevelCallback, forceNewRoomCallback, } from "./callbacks/reorde
2
2
  export * from "./constants";
3
3
  export { deployJSONRoom, deployRandomJSONRoom, emptyRoom, } from "./features/deployJSONRoom";
4
4
  export { disableAllInputs, disableAllInputsExceptFor, disableMovementInputs, disableShootingInputs, enableAllInputs, enableAllInputsExceptFor, } from "./features/disableInputs";
5
+ export { disableAllSound, enableAllSound } from "./features/disableSound";
5
6
  export { forgottenSwitch } from "./features/forgottenSwitch";
6
7
  export { getCollectibleItemPoolType } from "./features/getCollectibleItemPoolType";
7
8
  export * from "./features/isPonyActive";
package/dist/index.lua CHANGED
@@ -39,6 +39,13 @@ do
39
39
  ____exports.enableAllInputs = enableAllInputs
40
40
  ____exports.enableAllInputsExceptFor = enableAllInputsExceptFor
41
41
  end
42
+ do
43
+ local ____disableSound = require("features.disableSound")
44
+ local disableAllSound = ____disableSound.disableAllSound
45
+ local enableAllSound = ____disableSound.enableAllSound
46
+ ____exports.disableAllSound = disableAllSound
47
+ ____exports.enableAllSound = enableAllSound
48
+ end
42
49
  do
43
50
  local ____forgottenSwitch = require("features.forgottenSwitch")
44
51
  local forgottenSwitch = ____forgottenSwitch.forgottenSwitch
@@ -75,6 +75,8 @@ local ____deployJSONRoom = require("features.deployJSONRoom")
75
75
  local deployJSONRoomInit = ____deployJSONRoom.deployJSONRoomInit
76
76
  local ____disableInputs = require("features.disableInputs")
77
77
  local disableInputsInit = ____disableInputs.disableInputsInit
78
+ local ____disableSound = require("features.disableSound")
79
+ local disableSoundsInit = ____disableSound.disableSoundsInit
78
80
  local ____forgottenSwitch = require("features.forgottenSwitch")
79
81
  local forgottenSwitchInit = ____forgottenSwitch.forgottenSwitchInit
80
82
  local ____getCollectibleItemPoolType = require("features.getCollectibleItemPoolType")
@@ -134,6 +136,7 @@ end
134
136
  function initFeatures(self, mod)
135
137
  deployJSONRoomInit(nil, mod)
136
138
  disableInputsInit(nil, mod)
139
+ disableSoundsInit(nil, mod)
137
140
  forgottenSwitchInit(nil, mod)
138
141
  getCollectibleItemPoolTypeInit(nil, mod)
139
142
  preventCollectibleRotateInit(nil, mod)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "1.2.115",
3
+ "version": "1.2.118",
4
4
  "description": "Helper functions for IsaacScript mods",
5
5
  "keywords": [
6
6
  "isaac",
@@ -26,7 +26,7 @@
26
26
  ],
27
27
  "devDependencies": {
28
28
  "@zamiell/typescript-to-lua": "^1.4.2",
29
- "isaac-typescript-definitions": "^1.0.358",
29
+ "isaac-typescript-definitions": "^1.0.359",
30
30
  "isaacscript-lint": "^1.0.84",
31
31
  "isaacscript-tsconfig": "^1.1.8",
32
32
  "typedoc": "^0.22.13",