From 94e30935e46f96159e576512dd241e2239b5f0fe Mon Sep 17 00:00:00 2001 From: Deez Date: Thu, 26 Nov 2026 14:45:30 -0500 Subject: [PATCH] Upload files to "Patches" --- Patches/SpeakerPatches.cs | 49 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 Patches/SpeakerPatches.cs diff --git a/Patches/SpeakerPatches.cs b/Patches/SpeakerPatches.cs new file mode 100644 index 0000000..42d248d --- /dev/null +++ b/Patches/SpeakerPatches.cs @@ -0,0 +1,49 @@ +using GorillaCaptions.Classes; +using GorillaTag.Audio; +using HarmonyLib; +using Photon.Voice; +using Photon.Voice.Unity; + +namespace GorillaCaptions.Patches +{ + [HarmonyPatch(typeof(Speaker))] + [HarmonyPatch("StartPlaying", MethodType.Normal)] + public class OnSpeakerStart + { + static void Postfix(Speaker __instance) + { + if (__instance.gameObject.GetComponent() != null) + return; + + __instance.gameObject.AddComponent(); + } + } + + [HarmonyPatch(typeof(Speaker))] + [HarmonyPatch("StopPlaying", MethodType.Normal)] + public class OnSpeakerEnd + { + static void Postfix(Speaker __instance, bool force) + { + if (__instance.gameObject.GetComponent() == null) + return; + + SpeakerHook SpeakerHookInstance = __instance.gameObject.GetComponent(); + SpeakerHookInstance.enabled = false; + UnityEngine.Object.Destroy(SpeakerHookInstance); + } + } + + [HarmonyPatch(typeof(GTSpeaker))] + [HarmonyPatch("OnAudioFrame", MethodType.Normal)] + public class OnAudioFramePatch + { + static void Postfix(GTSpeaker __instance, FrameOut frame) + { + if (__instance.gameObject.GetComponent() == null) + return; + + __instance.gameObject.GetComponent().ProcessAudioFrame(frame.Buf); + } + } +}