using System;
using System.Collections.Generic;
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 TMPro;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("MuteToggle")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.1.4.0")]
[assembly: AssemblyInformationalVersion("0.1.4")]
[assembly: AssemblyProduct("MuteToggle")]
[assembly: AssemblyTitle("MuteToggle")]
[assembly: AssemblyVersion("0.1.4.0")]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
}
namespace MuteToggle
{
[BepInPlugin("soundedsquash.togglemute", "Toggle Mute", "0.1.4.0")]
public class MuteToggleBase : BaseUnityPlugin
{
private const string PluginGuid = "soundedsquash.togglemute";
private const string PluginName = "Toggle Mute";
private const string PluginVersion = "0.1.4.0";
private readonly Harmony _harmony = new Harmony("soundedsquash.togglemute");
private static readonly ManualLogSource ManualLogSource = Logger.CreateLogSource("soundedsquash.togglemute");
public void Awake()
{
Settings.Initialize(((BaseUnityPlugin)this).Config, ManualLogSource);
_harmony.PatchAll();
ManualLogSource.LogInfo((object)"Toggle Mute loaded");
}
}
public static class Settings
{
public static ConfigEntry<bool> IsToggleMuteModEnabled { get; private set; }
public static ConfigEntry<bool> StartUnmuted { get; private set; }
public static ManualLogSource Logger { get; private set; }
public static bool MuteToggleState { get; internal set; }
public static GameObject? MutedIndicator { get; internal set; }
internal static void Initialize(ConfigFile config, ManualLogSource logger)
{
Logger = logger;
IsToggleMuteModEnabled = config.Bind<bool>("General", "Enabled", true, "Enable this mod. This overrides push to talk setting.");
StartUnmuted = config.Bind<bool>("General", "StartUnmuted", true, "Start the game with an unmuted mic.");
MuteToggleState = StartUnmuted.Value;
}
public static void HideMutedIndicator(bool hide)
{
GameObject? mutedIndicator = MutedIndicator;
if (mutedIndicator != null)
{
mutedIndicator.gameObject.SetActive(!hide);
}
}
}
}
namespace MuteToggle.Patches
{
[HarmonyPatch(typeof(AudioManager))]
public static class AudioManagerPatches
{
[HarmonyPatch("UpdatePushToTalk")]
[HarmonyPrefix]
private static bool AudioManagerUpdatePushToTalkPrefix(ref bool ___pushToTalk)
{
if (!Settings.IsToggleMuteModEnabled.Value)
{
return true;
}
___pushToTalk = false;
return false;
}
}
[HarmonyPatch(typeof(HUDCanvas))]
public static class HUDCanvasPatches
{
[HarmonyPatch("Awake")]
[HarmonyPostfix]
private static void HUDCanvasAwakePostfix()
{
//IL_009d: Unknown result type (might be due to invalid IL or missing references)
//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
if (Settings.IsToggleMuteModEnabled.Value && GameManager.instance.gameMode != 0 && !((Object)(object)RunManager.instance.levelCurrent == (Object)(object)RunManager.instance.levelMainMenu) && !((Object)(object)RunManager.instance.levelCurrent == (Object)(object)RunManager.instance.levelLobbyMenu))
{
GameObject val = GameObject.Find("EnergyMax");
if (!((Object)(object)val == (Object)null))
{
GameObject obj = Object.Instantiate<GameObject>(val, val.transform.parent.parent, true);
((Object)obj).name = "MutedText";
obj.transform.position = new Vector3(16f, 27f, 0f);
TextMeshProUGUI component = obj.GetComponent<TextMeshProUGUI>();
((TMP_Text)component).text = "MUTED";
((TMP_Text)component).color = Color.red;
Settings.MutedIndicator = obj;
Settings.HideMutedIndicator(Settings.MuteToggleState);
}
}
}
}
[HarmonyPatch(typeof(InputManager))]
public static class InputManagerPatches
{
[HarmonyPatch("InitializeInputs")]
[HarmonyPostfix]
private static void InputManagerInitializeInputsPostfix(ref Dictionary<InputKey, bool> ___inputToggle)
{
Settings.Logger.LogDebug((object)"Patching InitializeInputs.");
if (Settings.IsToggleMuteModEnabled.Value)
{
___inputToggle.Add((InputKey)25, value: true);
Settings.Logger.LogDebug((object)"Input toggle added for Push To Talk.");
}
}
}
[HarmonyPatch(typeof(PlayerVoiceChat))]
public static class PlayerVoiceChatPatches
{
[HarmonyPatch("Update")]
[HarmonyPostfix]
private static void PlayerVoiceChatUpdatePostfix(ref Recorder ___recorder, bool ___microphoneEnabled)
{
if (Settings.IsToggleMuteModEnabled.Value && ___microphoneEnabled)
{
if (SemiFunc.InputDown((InputKey)25))
{
Settings.MuteToggleState = !Settings.MuteToggleState;
Settings.HideMutedIndicator(Settings.MuteToggleState);
}
___recorder.TransmitEnabled = Settings.MuteToggleState;
}
}
}
}