UNPKG

isaacscript-common

Version:

Helper functions and features for IsaacScript mods.

41 lines (40 loc) 1.76 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getMusicForStage = getMusicForStage; exports.stopAllSoundEffects = stopAllSoundEffects; const cachedEnumValues_1 = require("../cachedEnumValues"); const cachedClasses_1 = require("../core/cachedClasses"); const stageToMusic_1 = require("../objects/stageToMusic"); const enums_1 = require("./enums"); /** * Helper function to get the corresponding music value for a stage and stage type combination. * * @param stage Optional. The stage to get the music for. If not specified, the current stage will * be used. * @param stageType Optional. The stage type to get the music for. If not specified, the current * stage type will be used. */ function getMusicForStage(stage, stageType) { const level = cachedClasses_1.game.GetLevel(); stage ??= level.GetStage(); stageType ??= level.GetStageType(); const stageTypeToMusic = stageToMusic_1.STAGE_TO_MUSIC[stage]; return stageTypeToMusic[stageType]; } /** * Helper function to manually stop every vanilla sound effect. If you also want to stop custom * sound effects in addition to vanilla ones, then pass the `SoundEffectCustom` enum for your mod. * * @param soundEffectCustom Optional. The enum that represents all of the custom sound effects for * your mod. */ function stopAllSoundEffects(soundEffectCustom) { for (const soundEffect of cachedEnumValues_1.SOUND_EFFECT_VALUES) { cachedClasses_1.sfxManager.Stop(soundEffect); } if (soundEffectCustom !== undefined) { for (const soundEffect of (0, enums_1.getEnumValues)(soundEffectCustom)) { cachedClasses_1.sfxManager.Stop(soundEffect); } } }