-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSoundmodpatches.cs
More file actions
46 lines (41 loc) · 1.41 KB
/
Soundmodpatches.cs
File metadata and controls
46 lines (41 loc) · 1.41 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
#nullable enable
using System;
using HarmonyLib;
using UnityEngine;
namespace techtech.TechTechsSoundMod;
[HarmonyPatch(typeof(SoundManager), nameof(SoundManager.PlaySound))]
public static class Patch_PlaySound
{
public static void Prefix(AudioClip? clip)
{
if (clip == null || SoundModManager.PendingInjections.Count == 0) return;
try
{
var name = clip.name?.ToString() ?? "";
if (TechTechsSoundModLocalSettings.Instance.DebugLogging.Value)
TechTechsSoundMod.Instance.Log.LogInfo($"[SoundMod][DEBUG] PlaySound '{name}'");
SoundModManager.TryInject(clip, name);
}
catch { }
}
}
[HarmonyPatch(typeof(SoundManager), nameof(SoundManager.PlaySoundImmediate))]
public static class Patch_PlaySoundImmediate
{
public static void Prefix(AudioClip? clip)
{
if (clip == null || SoundModManager.PendingInjections.Count == 0) return;
try { SoundModManager.TryInject(clip, clip.name?.ToString() ?? ""); }
catch { }
}
}
// [HarmonyPatch(typeof(SoundManager), nameof(SoundManager.PlayNamedSound))]
// public static class Patch_PlayNamedSound
// {
// public static void Prefix(AudioClip? sound)
// {
// if (sound == null || SoundModManager.PendingInjections.Count == 0) return;
// try { SoundModManager.TryInject(sound, sound.name?.ToString() ?? ""); }
// catch { }
// }
// }