Upload files to "Patches"
This commit is contained in:
1 parent
1765940692
commit
94e30935e4
1 file changed
+49
@@ -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<SpeakerHook>() != null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
__instance.gameObject.AddComponent<SpeakerHook>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[HarmonyPatch(typeof(Speaker))]
|
||||||
|
[HarmonyPatch("StopPlaying", MethodType.Normal)]
|
||||||
|
public class OnSpeakerEnd
|
||||||
|
{
|
||||||
|
static void Postfix(Speaker __instance, bool force)
|
||||||
|
{
|
||||||
|
if (__instance.gameObject.GetComponent<SpeakerHook>() == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
SpeakerHook SpeakerHookInstance = __instance.gameObject.GetComponent<SpeakerHook>();
|
||||||
|
SpeakerHookInstance.enabled = false;
|
||||||
|
UnityEngine.Object.Destroy(SpeakerHookInstance);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[HarmonyPatch(typeof(GTSpeaker))]
|
||||||
|
[HarmonyPatch("OnAudioFrame", MethodType.Normal)]
|
||||||
|
public class OnAudioFramePatch
|
||||||
|
{
|
||||||
|
static void Postfix(GTSpeaker __instance, FrameOut<float> frame)
|
||||||
|
{
|
||||||
|
if (__instance.gameObject.GetComponent<SpeakerHook>() == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
__instance.gameObject.GetComponent<SpeakerHook>().ProcessAudioFrame(frame.Buf);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in new issue
Block a user