Skip to content

Commit 9e193d1

Browse files
yes
1 parent 319d4b9 commit 9e193d1

3 files changed

Lines changed: 48 additions & 1 deletion

File tree

WorldBoxMod.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@ private void Update()
102102
HarmonyUtils._init();
103103
Harmony.CreateAndPatchAll(typeof(LM), Others.harmony_id);
104104
Harmony.CreateAndPatchAll(typeof(ResourcesPatch), Others.harmony_id);
105-
Harmony.CreateAndPatchAll(typeof(FMODPatches), Others.harmony_id);
106105
if (!SmoothLoader.isLoading()) SmoothLoader.prepare();
107106

108107
SmoothLoader.add(() =>

services/DebugService.cs

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
using System.Reflection;
2+
using HarmonyLib;
3+
using NeoModLoader.constants;
4+
5+
namespace NeoModLoader.services;
6+
7+
public static class DebugService
8+
{
9+
static void Debugger(MethodBase __originalMethod)
10+
{
11+
LogService.LogInfo(__originalMethod.ToString());
12+
}
13+
static readonly Harmony Patcher = new Harmony(Others.harmony_id);
14+
private static readonly HarmonyMethod Hook = new(AccessTools.Method(typeof(DebugService), nameof(Debugger)));
15+
public static void AttachDebugger(Assembly assembly)
16+
{
17+
foreach (var Type in assembly.GetTypes())
18+
{
19+
foreach (var method in Type.GetMethods(
20+
BindingFlags.Public |
21+
BindingFlags.NonPublic |
22+
BindingFlags.Instance |
23+
BindingFlags.Static |
24+
BindingFlags.DeclaredOnly))
25+
{
26+
Patcher.Patch(method, Hook);
27+
}
28+
}
29+
}
30+
public static void RemoveDebugger(Assembly assembly)
31+
{
32+
foreach (var Type in assembly.GetTypes())
33+
{
34+
foreach (var method in Type.GetMethods(
35+
BindingFlags.Public |
36+
BindingFlags.NonPublic |
37+
BindingFlags.Instance |
38+
BindingFlags.Static |
39+
BindingFlags.DeclaredOnly))
40+
{
41+
Patcher.Unpatch(method, HarmonyPatchType.Prefix);
42+
}
43+
}
44+
}
45+
}

utils/Sounds/FMODHelpers.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using FMOD;
22
using FMODUnity;
33
using HarmonyLib;
4+
using NeoModLoader.constants;
45
using UnityEngine;
56

67
namespace NeoModLoader.utils.Sounds;
@@ -51,6 +52,7 @@ static void ClearAllCustomSounds()
5152
[HarmonyPatch(typeof(RuntimeManager), "Update")]
5253
static void Update()
5354
{
55+
5456
SFXGroup.setVolume(GetVolume(SoundType.Sound));
5557
MusicGroup.setVolume(GetVolume(SoundType.Music));
5658
UIGroup.setVolume(GetVolume(SoundType.UI));
@@ -69,6 +71,7 @@ public static class FMODHelper
6971

7072
internal static void InitFMOD()
7173
{
74+
Harmony.CreateAndPatchAll(typeof(FMODPatches), Others.harmony_id);
7275
ThrowIfNotOk("Failed to initialize FMOD Core System!", RuntimeManager.StudioSystem.getCoreSystem(out var coresystem));
7376
FMODSystem = coresystem;
7477
ThrowIfNotOk("Failed to create SFXGroup", FMODSystem.createChannelGroup("SFXGroup", out var Group));

0 commit comments

Comments
 (0)