Decompiled source of MuteButton v1.0.3

BepInEx/plugins/Dorfistain-MuteButton.dll

Decompiled 3 weeks ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using Dissonance;
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("Dorfistain-MuteButton")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Dorfistain-MuteButton")]
[assembly: AssemblyTitle("Dorfistain-MuteButton")]
[assembly: AssemblyVersion("1.0.0.0")]
[BepInPlugin("Dorfistain.MuteButton", "MuteButton", "1.0.3")]
public class MuteButtonPlugin : BaseUnityPlugin
{
	private const KeyCode ToggleKey = 109;

	private void Awake()
	{
		Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
		((BaseUnityPlugin)this).Logger.LogInfo((object)"MuteButton loaded — press M to toggle mic mute.");
	}

	private void Update()
	{
		if (!Input.GetKeyDown((KeyCode)109))
		{
			return;
		}
		TMP_InputField[] array = Object.FindObjectsByType<TMP_InputField>((FindObjectsSortMode)0);
		for (int i = 0; i < array.Length; i++)
		{
			if (array[i].isFocused)
			{
				return;
			}
		}
		VoiceManager instance = VoiceManager.instance;
		if (!((Object)(object)instance == (Object)null))
		{
			DissonanceComms singleton = DissonanceComms.GetSingleton();
			if (!((Object)(object)singleton == (Object)null))
			{
				instance.MuteLocalPlayer(!singleton.IsMuted);
			}
		}
	}
}