Decompiled source of MicToggle v1.5.12547

Mods/MicToggle.dll

Decompiled 2 months ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using Il2CppPhoton.Voice.Unity;
using Il2CppRUMBLE.Managers;
using Il2CppRUMBLE.Serialization;
using Il2CppRUMBLE.Utilities;
using Il2CppTMPro;
using MelonLoader;
using MicToggle;
using RumbleModdingAPI;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: MelonInfo(typeof(Class1), "MicToggle", "1.5.12547", "Davilonchi", null)]
[assembly: MelonColor(255, 67, 216, 250)]
[assembly: MelonAuthorColor(255, 67, 216, 250)]
[assembly: MelonGame("Buckethead Entertainment", "RUMBLE")]
[assembly: AssemblyTitle("MicToggle")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Davilonchi")]
[assembly: AssemblyProduct("MicToggle")]
[assembly: AssemblyCopyright("Copyright © HP 2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("6a118ceb-1d93-426f-9d50-1de04a42c5e9")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace MicToggle;

public static class BuildInfo
{
	public const string ModName = "MicToggle";

	public const string ModVersion = "1.5.12547";

	public const string Description = "Toggles your mic when secondary is pressed on the left controller";

	public const string Author = "Davilonchi";

	public const string Company = "";
}
public class Class1 : MelonMod
{
	private GameObject status;

	private TextMeshPro statusRef;

	private Recorder recorder;

	private bool toggle;

	private bool init;

	private bool isholding;

	private bool is_setup = true;

	private string currentScene = "Loader";

	private float audio;

	public override void OnLateInitializeMelon()
	{
		Calls.onMapInitialized += openningidk;
	}

	public override void OnSceneWasLoaded(int buildIndex, string sceneName)
	{
		//IL_001f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0025: Expected O, but got Unknown
		if (sceneName == "Gym" && is_setup)
		{
			VoiceConfiguration val = new VoiceConfiguration(Singleton<AudioManager>.instance.voiceConfig);
			val.MicMode = (MicrophoneMode)1;
			Singleton<AudioManager>.instance.ApplyVoiceConfiguration(val);
			is_setup = false;
		}
		if (sceneName != "Loader")
		{
			audio = Singleton<AudioManager>.Instance.voiceConfig.OpenMicrophoneTreshold;
		}
		init = false;
		currentScene = sceneName;
	}

	public void openningidk()
	{
		//IL_0088: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
		init = true;
		try
		{
			status = Create.NewText();
			((Object)status).name = "Mic Status";
			Log(((Object)((Component)Players.GetLocalHealthbarGameObject().transform.GetChild(1).GetChild(0)).gameObject).name);
			status.transform.parent = Players.GetLocalHealthbarGameObject().transform.GetChild(1).GetChild(0);
			status.transform.localRotation = Quaternion.Euler(54.5529f, 253.431f, 358.4814f);
			status.transform.localPosition = new Vector3(-0.9834f, 0.0073f, -0.235f);
			statusRef = status.GetComponent<TextMeshPro>();
			((TMP_Text)statusRef).fontSize = 0.5f;
			((TMP_Text)statusRef).text = "Mic Status: Off";
			toggle = false;
		}
		catch (Exception ex)
		{
			MelonLogger.Error((object)ex);
		}
	}

	private void Log(string msg)
	{
		MelonLogger.Msg(msg);
	}

	public void testToggle()
	{
		//IL_0028: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Expected O, but got Unknown
		if (!isholding)
		{
			isholding = true;
			toggle = !toggle;
			VoiceConfiguration val = new VoiceConfiguration(Singleton<AudioManager>.instance.voiceConfig);
			if (toggle)
			{
				((TMP_Text)statusRef).text = "Mic Status: On";
				audio = 0.0353f;
			}
			else
			{
				((TMP_Text)statusRef).text = "Mic Status: Off";
				audio = 10f;
			}
			val.OpenMicrophoneTreshold = audio;
			Singleton<AudioManager>.instance.ApplyVoiceConfiguration(val);
		}
	}

	public override void OnUpdate()
	{
		//IL_005c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0062: Expected O, but got Unknown
		if (!init)
		{
			return;
		}
		if ((double)LeftController.GetSecondary() > 0.9 && (double)LeftController.GetPrimary() > 0.9)
		{
			if (!isholding)
			{
				isholding = true;
				toggle = !toggle;
				VoiceConfiguration val = new VoiceConfiguration(Singleton<AudioManager>.instance.voiceConfig);
				if (toggle)
				{
					((TMP_Text)statusRef).text = "Mic Status: On";
					audio = 0.0353f;
				}
				else
				{
					((TMP_Text)statusRef).text = "Mic Status: Off";
					audio = 10f;
				}
				val.OpenMicrophoneTreshold = audio;
				Singleton<AudioManager>.instance.ApplyVoiceConfiguration(val);
			}
		}
		else if (isholding)
		{
			isholding = false;
		}
	}
}