using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Voice.Unity;
using UnityEngine;
using UnityEngine.InputSystem;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("DarkwaterPushToTalk")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+8ddd88f6a363889854bc798b10c5e89835d2c7e1")]
[assembly: AssemblyProduct("DarkwaterPushToTalk")]
[assembly: AssemblyTitle("DarkwaterPushToTalk")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace DarkwaterPushToTalk
{
[BepInPlugin("eu.puszkapotato.darkwater.pushToTalk", "Darkwater Push To Talk", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
internal static ManualLogSource Log;
internal static InputAction pttAction;
private void Awake()
{
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Expected O, but got Unknown
ConfigEntry<string> val = ((BaseUnityPlugin)this).Config.Bind<string>("1. General", "PushToTalkKey", "<Keyboard>/v", "The button to press for push-to-talk. Examples: <Keyboard>/v, <Mouse>/forwardButton");
pttAction = new InputAction((string)null, (InputActionType)0, val.Value, (string)null, (string)null, (string)null);
pttAction.Enable();
Log = ((BaseUnityPlugin)this).Logger;
Log.LogInfo((object)"Darkwater Push To Talk Plugin Loaded");
Log.LogInfo((object)("Push to talk key is set to: " + val.Value));
Harmony.CreateAndPatchAll(typeof(PushToTalkPatch), (string)null);
}
}
[HarmonyPatch]
internal class PushToTalkPatch
{
private static bool wasTransmitting;
[HarmonyPatch(typeof(C_Controller_Player), "Start")]
[HarmonyPostfix]
public static void DisableVoiceOnStart(C_Controller_Player __instance)
{
if (!((Object)(object)__instance.source_VoiceSpeaker == (Object)null))
{
Recorder recorderInUse = __instance.source_VoiceSpeaker.RecorderInUse;
if ((Object)(object)recorderInUse != (Object)null)
{
recorderInUse.TransmitEnabled = false;
}
}
}
[HarmonyPatch(typeof(C_Controller_Player), "Update")]
[HarmonyPostfix]
public static void CheckForPttKey(C_Controller_Player __instance)
{
if ((Object)(object)__instance.source_VoiceSpeaker == (Object)null)
{
return;
}
Recorder recorderInUse = __instance.source_VoiceSpeaker.RecorderInUse;
if ((Object)(object)recorderInUse != (Object)null)
{
bool flag = Plugin.pttAction.IsPressed();
if (flag != recorderInUse.TransmitEnabled)
{
recorderInUse.TransmitEnabled = flag;
}
if (flag && !wasTransmitting)
{
Plugin.Log.LogInfo((object)"Voice transmission enabled");
}
wasTransmitting = flag;
}
}
}
}