isaacscript-common 1.2.117 → 1.2.120

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,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,55 @@
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, "disableSounds", 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
+ stopAllSoundEffects(nil)
42
+ end
43
+ function ____exports.disableAllSound(self, key)
44
+ if not initialized then
45
+ local msg = getUpgradeErrorMsg(nil, FEATURE_NAME)
46
+ error(msg)
47
+ end
48
+ if v.run.disableSoundSet.size == 0 then
49
+ local musicManager = MusicManager()
50
+ musicWasEnabled = musicManager:IsEnabled()
51
+ end
52
+ v.run.disableSoundSet:add(key)
53
+ stopAllSoundEffects(nil)
54
+ end
55
+ return ____exports
@@ -48,6 +48,9 @@ export declare const ensureAllCases: (obj: never) => never;
48
48
  *
49
49
  * For a more in depth explanation, see:
50
50
  * https://isaacscript.github.io/docs/gotchas#iterating-over-enums
51
+ *
52
+ * You can also use this function for vanilla enums, which can make code easier to read than using
53
+ * `pairs` or `Object.values()`.
51
54
  */
52
55
  export declare function getEnumValues<T>(transpiledEnum: T): Array<T[keyof T]>;
53
56
  /**
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.117",
3
+ "version": "1.2.120",
4
4
  "description": "Helper functions for IsaacScript mods",
5
5
  "keywords": [
6
6
  "isaac",