-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFMODAudioEngine.cpp
31 lines (24 loc) · 1.23 KB
/
FMODAudioEngine.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <Geode/modify/FMODAudioEngine.hpp>
#include "Utils.hpp"
#define PREFERRED_HOOK_PRIO (-3999)
using namespace geode::prelude;
class $modify(MuteRewardsSFXFMODAEHook, FMODAudioEngine) {
static void onModify(auto& self) {
(void) self.setHookPriority("FMODAudioEngine::playEffect", PREFERRED_HOOK_PRIO);
}
struct Fields {
const std::array<std::string_view, 4> badSFX = { "achievement_01.ogg", "magicExplosion.ogg", "gold02.ogg", "secretKey.ogg" };
};
void playEffect(gd::string path, float speed, float p2, float volume) {
if (!Utils::modEnabled() || !Utils::getBool("muteRewardsSFX") || Utils::isEclipse())
return FMODAudioEngine::playEffect(path, speed, p2, volume);
// for relevant comments on the source code below this line, please see:
// https://raw.githubusercontent.com/EclipseMenu/EclipseMenu/main/src/hacks/Player/MuteLevelAudioOnDeath.cpp
// reused with permission on grounds of self-authored code
auto* pl = PlayLayer::get();
if (!pl || !pl->m_player1->m_isDead || pl->m_isPaused)
return FMODAudioEngine::playEffect(path, speed, p2, volume);
if (std::ranges::find(m_fields->badSFX, std::string_view(path)) == m_fields->badSFX.end())
return FMODAudioEngine::playEffect(path, speed, p2, volume);
}
};