Decompiled source of MuteButton v1.0.0

BepInEx/plugins/Dorfistain-MuteButton.dll

Decompiled 7 hours ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
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.0")]
public class MuteButtonPlugin : BaseUnityPlugin
{
	private const KeyCode ToggleKey = 109;

	private bool _muted;

	private bool _subscribed;

	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 OnDestroy()
	{
		if (_subscribed && (Object)(object)VoiceManager.instance != (Object)null)
		{
			VoiceManager.instance.OnLocalPlayerMute -= OnMuteChanged;
		}
	}

	private void Update()
	{
		if (!_subscribed && (Object)(object)VoiceManager.instance != (Object)null)
		{
			VoiceManager.instance.OnLocalPlayerMute += OnMuteChanged;
			_subscribed = true;
		}
		if (Input.GetKeyDown((KeyCode)109) && (Object)(object)VoiceManager.instance != (Object)null)
		{
			VoiceManager.instance.MuteLocalPlayer(!_muted);
		}
	}

	private void OnMuteChanged(bool muted)
	{
		_muted = muted;
	}
}