Decompiled source of Mod Name No Spaces v1.0.0

Mods/StaticCamera.dll

Decompiled 2 years ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using LIV.SDK.Unity;
using MelonLoader;
using RUMBLE.Players;
using RUMBLE.Players.Subsystems;
using RumbleModdingAPI;
using StaticCamera;
using UnityEngine;
using UnityEngine.InputSystem;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: MelonInfo(typeof(Class1), "SaticCamera", "1.0.0", "PeppaStone", null)]
[assembly: MelonGame("Buckethead Entertainment", "RUMBLE")]
[assembly: AssemblyTitle("StaticCamera")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("StaticCamera")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("0d79be14-00c6-4570-a460-e58f37c30ddb")]
[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 StaticCamera;

public class Class1 : MelonMod
{
	private GameObject playerLiv;

	private Stopwatch stopwatch = new Stopwatch();

	private GameObject staticLivCam;

	private static InputActionMap map = new InputActionMap("Rest Xr Map");

	private static InputAction rightThumbstick = InputActionSetupExtensions.AddAction(map, "Right Joysitck Click", (InputActionType)1, "<XRController>{RightHand}/thumbstickClick", (string)null, (string)null, (string)null, (string)null);

	private static InputAction leftThumbstick = InputActionSetupExtensions.AddAction(map, "Left Joystick Click", (InputActionType)1, "<XRController>{LeftHand}/thumbstickClick", (string)null, (string)null, (string)null, (string)null);

	private PlayerController playerController;

	private bool livSetUp = false;

	public override void OnSceneWasLoaded(int buildIndex, string sceneName)
	{
		if (sceneName != "Loader")
		{
			map.Enable();
			stopwatch = new Stopwatch();
			stopwatch.Stop();
			stopwatch.Restart();
			stopwatch.Start();
		}
	}

	public override void OnUpdate()
	{
		//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00de: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_0105: Unknown result type (might be due to invalid IL or missing references)
		//IL_0107: Unknown result type (might be due to invalid IL or missing references)
		if (stopwatch.IsRunning && stopwatch.ElapsedMilliseconds >= 3000)
		{
			SetupLivCamera();
		}
		if (livSetUp && rightThumbstick.ReadValue<float>() == 1f && leftThumbstick.ReadValue<float>() == 1f)
		{
			staticLivCam.transform.position = ((Component)((Component)((Component)((Component)playerController).transform.GetChild(1)).transform.GetChild(0)).transform.GetChild(0)).transform.position;
			Quaternion rotation = ((Component)((Component)((Component)((Component)playerController).transform.GetChild(1)).transform.GetChild(0)).transform.GetChild(0)).transform.rotation;
			Vector3 eulerAngles = ((Quaternion)(ref rotation)).eulerAngles;
			eulerAngles.z = 0f;
			staticLivCam.transform.rotation = Quaternion.Euler(eulerAngles);
		}
	}

	public void SetupLivCamera()
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Expected O, but got Unknown
		staticLivCam = new GameObject();
		((Object)staticLivCam).name = "LivCam";
		playerController = Managers.GetPlayerManager().localPlayer.Controller;
		playerLiv = ((Component)((Component)playerController).transform.GetChild(8)).gameObject;
		staticLivCam.AddComponent<PlayerController>();
		staticLivCam.GetComponent<PlayerController>().controllerType = (ControllerType)2;
		playerLiv.GetComponent<LIV>().stage = staticLivCam.transform;
		((PlayerControllerSubsystem)playerLiv.GetComponent<PlayerLIV>()).parentController = staticLivCam.GetComponent<PlayerController>();
		stopwatch.Stop();
		livSetUp = true;
	}
}