-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGameplayPatches.cs
More file actions
58 lines (50 loc) · 1.73 KB
/
GameplayPatches.cs
File metadata and controls
58 lines (50 loc) · 1.73 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
using HarmonyLib;
using System.Reflection;
namespace BSNightcore.HarmonyPatches
{
[HarmonyPatch(typeof(GameplayCoreInstaller), "InstallBindings")]
public class GameplayCoreInstallerPatch
{
private static FieldInfo _audioManagerField;
static GameplayCoreInstallerPatch()
{
_audioManagerField = typeof(GameplayCoreInstaller).GetField("_audioManager", BindingFlags.Instance | BindingFlags.NonPublic);
}
static void Postfix(GameplayCoreInstaller __instance)
{
if (!PluginConfig.Instance.ModEnabled) return;
var audioManager = _audioManagerField.GetValue(__instance) as AudioManagerSO;
if (audioManager != null)
{
audioManager.musicPitch = 1f;
}
}
}
[HarmonyPatch(typeof(SettingsApplicatorSO), "ApplyGameSettings")]
public class SettingsApplicatorPatch
{
private static FieldInfo _audioManagerField;
static SettingsApplicatorPatch()
{
_audioManagerField = typeof(SettingsApplicatorSO).GetField("_audioManager", BindingFlags.Instance | BindingFlags.NonPublic);
}
static void Postfix(SettingsApplicatorSO __instance)
{
var audioManager = _audioManagerField.GetValue(__instance) as AudioManagerSO;
if (audioManager != null)
{
AudioManagerHolder.Instance = audioManager;
}
}
}
[HarmonyPatch(typeof(AudioManagerSO), "set_musicPitch")]
public class AudioManagerPitchPatch
{
static bool Prefix(ref float value)
{
if (!PluginConfig.Instance.ModEnabled) return true;
value = 1f;
return true;
}
}
}