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); } } }