Decompiled source of RecursiveRockCam v1.2.0

Mods/RecursiveRockCam.dll

Decompiled 3 weeks ago
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using HarmonyLib;
using Il2CppRUMBLE.Players;
using MelonLoader;
using MelonLoader.Preferences;
using RecursiveRockCam;
using RumbleModdingAPI.RMAPI;
using UIFramework;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: MelonInfo(typeof(MainClass), "RecursiveRockCam", "1.2.0", "Kalamart", null)]
[assembly: VerifyLoaderVersion(0, 6, 5, true)]
[assembly: MelonGame("Buckethead Entertainment", "RUMBLE")]
[assembly: MelonColor(255, 255, 31, 90)]
[assembly: MelonAuthorColor(255, 255, 31, 90)]
[assembly: MelonAdditionalDependencies(new string[] { "UIFramework", "RumbleModdingAPI" })]
[assembly: AssemblyDescription("Makes the Rock Cam screen visible in Rock Cam")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("621d30a5-8fa1-4d87-9826-92c0149b033e")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("RecursiveRockCam")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+72d9d513f3fa8fff91892fc53a1a9f0f74967145")]
[assembly: AssemblyProduct("RecursiveRockCam")]
[assembly: AssemblyTitle("RecursiveRockCam")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace RecursiveRockCam;

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

	public const string ModVersion = "1.2.0";

	public const string Description = "Makes the Rock Cam screen visible in Rock Cam";

	public const string Author = "Kalamart";

	public const string Company = "";
}
public class MainClass : MelonMod
{
	[HarmonyPatch(typeof(PlayerController), "Initialize", new Type[] { typeof(Player) })]
	public static class playerspawn
	{
		private static void Postfix(ref PlayerController __instance, ref Player player)
		{
			if (Players.GetLocalPlayer() == player)
			{
				updateRockCamScreen();
			}
		}
	}

	internal const string USER_DATA = "UserData/RecursiveRockCam/";

	internal const string CONFIG_FILE = "config.cfg";

	public static bool screenVisible = true;

	public static GameObject screen = null;

	internal static MelonPreferences_Category GeneralCategory;

	internal static MelonPreferences_Entry<bool> ScreenVisible;

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

	private static void LogWarn(string msg)
	{
		MelonLogger.Warning(msg);
	}

	private static void LogError(string msg)
	{
		MelonLogger.Error(msg);
	}

	private void PrefInit()
	{
		if (!Directory.Exists("UserData/RecursiveRockCam/"))
		{
			Directory.CreateDirectory("UserData/RecursiveRockCam/");
		}
		GeneralCategory = MelonPreferences.CreateCategory("RecursiveRockCam", "General Settings");
		GeneralCategory.SetFilePath(Path.Combine("UserData/RecursiveRockCam/", "config.cfg"));
		ScreenVisible = GeneralCategory.CreateEntry<bool>("Screen visible", true, "Make Rock Cam screen visible in Rock Cam recordings.", (string)null, false, false, (ValueValidator)null, (string)null);
	}

	private void OnUISaved()
	{
		updateRockCamScreen();
	}

	public override void OnInitializeMelon()
	{
		PrefInit();
		((ModelModItem)UI.Register((MelonBase)(object)this, (MelonPreferences_Category[])(object)new MelonPreferences_Category[1] { GeneralCategory })).OnModSaved += OnUISaved;
	}

	public override void OnSceneWasLoaded(int buildIndex, string sceneName)
	{
		if (sceneName != "Loader")
		{
			screen = null;
			updateRockCamScreen();
		}
	}

	private static void updateRockCamScreen()
	{
		try
		{
			screenVisible = ScreenVisible.Value;
			PlayerController localPlayerController = Players.GetLocalPlayerController();
			if (localPlayerController != null)
			{
				if (screen == null)
				{
					screen = ((Component)((Component)localPlayerController).gameObject.transform.GetChild(7).GetChild(0).GetChild(2)
						.GetChild(0)
						.GetChild(3)
						.GetChild(0)).gameObject;
				}
				if (screenVisible)
				{
					screen.layer = LayerMask.NameToLayer("UI");
				}
				else
				{
					screen.layer = LayerMask.NameToLayer("RecordingCamera");
				}
			}
		}
		catch (Exception)
		{
		}
	}
}