Decompiled source of Rumble LIV Camera Enabler v2.1.1

Mods/LIVCameraEnabler.dll

Decompiled a week ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using Il2CppRUMBLE.Utilities;
using LIV_Camera_Enabler;
using MelonLoader;
using RumbleModUI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: MelonInfo(typeof(LIVCameraStart), "LIV Camera Enabler", "2.1.1", "UlvakSkillz", null)]
[assembly: MelonGame("Buckethead Entertainment", "RUMBLE")]
[assembly: MelonColor(255, 195, 0, 255)]
[assembly: MelonAuthorColor(255, 195, 0, 255)]
[assembly: VerifyLoaderVersion(0, 6, 6, true)]
[assembly: AssemblyTitle("LIV Camera Enabler")]
[assembly: AssemblyDescription("Start playing Rumble with the F10 Camera Active")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("LIV Camera Enabler")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("ce5c6056-f5fe-45d6-92f5-42037a30db8f")]
[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 LIV_Camera_Enabler;

public class LIVCameraStart : MelonMod
{
	private string currentScene = "Loader";

	private bool sceneChanged = false;

	private RecordingCamera playerLIV;

	private UI UI = UI.instance;

	public static Mod LIVCameraEnabler = new Mod();

	private bool enabled = true;

	private bool cameraType = true;

	public override void OnLateInitializeMelon()
	{
		//IL_0045: Unknown result type (might be due to invalid IL or missing references)
		//IL_004a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0057: Expected O, but got Unknown
		//IL_0069: Unknown result type (might be due to invalid IL or missing references)
		//IL_0073: Expected O, but got Unknown
		//IL_0085: Unknown result type (might be due to invalid IL or missing references)
		//IL_008f: Expected O, but got Unknown
		LIVCameraEnabler.ModName = "LIV Camera Enabler";
		LIVCameraEnabler.ModVersion = "2.1.1";
		LIVCameraEnabler.SetFolder("LIVCameraEnabler");
		LIVCameraEnabler.AddDescription("Description", "Description", "Enables the LIV Camera or Legacy Camera", new Tags
		{
			IsSummary = true
		});
		LIVCameraEnabler.AddToList("Enabled", true, 0, "Enable/Disable Mod", new Tags());
		LIVCameraEnabler.AddToList("Camera Type", true, 0, "True = LIV Camera, False = Legacy Camera", new Tags());
		LIVCameraEnabler.GetFromFile();
		UI.instance.UI_Initialized += UIInit;
		LIVCameraEnabler.ModSaved += Save;
		Save();
	}

	private void Save()
	{
		enabled = (bool)LIVCameraEnabler.Settings[1].SavedValue;
		cameraType = (bool)LIVCameraEnabler.Settings[2].SavedValue;
		if (currentScene != "Loader")
		{
			UpdateCamera();
		}
	}

	private void UIInit()
	{
		UI.AddMod(LIVCameraEnabler);
	}

	public void UpdateCamera()
	{
		try
		{
			if (!enabled)
			{
				return;
			}
			playerLIV = Singleton<RecordingCamera>.instance;
			if (cameraType)
			{
				playerLIV.OnLegacyRecordingCameraEnabledChanged(false);
				playerLIV.SaveConfiguration();
				if (IsProcessRunning("capture"))
				{
					playerLIV.OnModernRecordingCameraEnabledChanged(true);
				}
				else
				{
					sceneChanged = false;
				}
			}
			else
			{
				playerLIV.OnModernRecordingCameraEnabledChanged(false);
				playerLIV.SaveConfiguration();
				playerLIV.OnLegacyRecordingCameraEnabledChanged(true);
			}
			playerLIV.SaveConfiguration();
			sceneChanged = false;
		}
		catch
		{
		}
	}

	public override void OnFixedUpdate()
	{
		if (sceneChanged && currentScene != "Loader")
		{
			UpdateCamera();
		}
	}

	public override void OnSceneWasLoaded(int buildIndex, string sceneName)
	{
		currentScene = sceneName;
		sceneChanged = true;
	}

	private static bool IsProcessRunning(string processName)
	{
		return Process.GetProcessesByName(processName).Length != 0;
	}
}