Decompiled source of RockCamYeeter v1.0.0

Mods/RockCamYeeter.dll

Decompiled a week ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using MelonLoader;
using RockCamYeeter;
using Rock_Cam_Essentials;
using RumbleModUI;
using RumbleModdingAPI;
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(Main), "RockCamYeeter", "1.0.0", "Deterraleon", null)]
[assembly: MelonGame("Buckethead Entertainment", "RUMBLE")]
[assembly: MelonColor(255, 255, 119, 255)]
[assembly: MelonAuthorColor(255, 255, 119, 255)]
[assembly: VerifyLoaderVersion(0, 6, 6, true)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("RockCamYeeter")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("RockCamYeeter")]
[assembly: AssemblyTitle("RockCamYeeter")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace RockCamYeeter;

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

	public const string ModVersion = "1.0.0";

	public const string Author = "Deterraleon";
}
public class Main : MelonMod
{
	[CompilerGenerated]
	private sealed class <follow>d__7 : IEnumerator<object>, IEnumerator, IDisposable
	{
		private int <>1__state;

		private object <>2__current;

		public float time;

		public Main <>4__this;

		object IEnumerator<object>.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		object IEnumerator.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		[DebuggerHidden]
		public <follow>d__7(int <>1__state)
		{
			this.<>1__state = <>1__state;
		}

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Expected O, but got Unknown
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				<>4__this.trace = true;
				<>2__current = (object)new WaitForSeconds(time);
				<>1__state = 1;
				return true;
			case 1:
				<>1__state = -1;
				<>4__this.trace = false;
				if (<>4__this.Camera.handleBars.isHeld == 0 && (bool)<>4__this.settings[4].SavedValue)
				{
					<>4__this.Camera.HideTablet();
				}
				return false;
			}
		}

		bool IEnumerator.MoveNext()
		{
			//ILSpy generated this explicit interface implementation from .override directive in MoveNext
			return this.MoveNext();
		}

		[DebuggerHidden]
		void IEnumerator.Reset()
		{
			throw new NotSupportedException();
		}
	}

	private string currentScene = "Loader";

	private Mod RockCamYeeter = new Mod();

	private bool enabled = true;

	private List<ModSetting> settings = new List<ModSetting>();

	public object prevfollow = null;

	private Vector3 velocity = Vector3.zero;

	private Vector3 position = Vector3.zero;

	private Vector3 oldposition = Vector3.zero;

	private Vector3 oldoldposition = Vector3.zero;

	private Vector3 angularVelocity = Vector3.zero;

	private Quaternion angle = Quaternion.identityQuaternion;

	private Quaternion oldangle = Quaternion.identityQuaternion;

	private Rigidbody body;

	private GameObject inland;

	public Rock_Cam Camera;

	public bool trace = false;

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

	public override void OnLateInitializeMelon()
	{
		Calls.onMapInitialized += mapLoaded;
		UI.instance.UI_Initialized += UIInit;
	}

	private void UIInit()
	{
		//IL_004c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0056: Expected O, but got Unknown
		//IL_0077: Unknown result type (might be due to invalid IL or missing references)
		//IL_0081: Expected O, but got Unknown
		//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ac: Expected O, but got Unknown
		//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d7: Expected O, but got Unknown
		//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ff: Expected O, but got Unknown
		RockCamYeeter.ModName = "RockCamYeeter";
		RockCamYeeter.ModVersion = "1.0.0";
		RockCamYeeter.SetFolder("RockCamYeeter");
		settings.Add((ModSetting)(object)RockCamYeeter.AddToList("Enabled", true, 0, "Toggles Mod On/Off", new Tags()));
		settings.Add((ModSetting)(object)RockCamYeeter.AddToList("Time yeeting", 7f, "The ammount of time the rockcam will be yeeted for after release", new Tags()));
		settings.Add((ModSetting)(object)RockCamYeeter.AddToList("Vertical yeeting cutoff", -5f, "The value that the rockcam will stop yeeting upon going below", new Tags()));
		settings.Add((ModSetting)(object)RockCamYeeter.AddToList("Velocity Threshhold", 0.5f, "The min velocity for the rockcam to yeet", new Tags()));
		settings.Add((ModSetting)(object)RockCamYeeter.AddToList("Turn off after yeetend", false, 0, "Will hide the camera after certain ways of ending a yeet(btw may not work i'm too lazy to actually check)", new Tags()));
		RockCamYeeter.GetFromFile();
		RockCamYeeter.ModSaved += Save;
		UI.instance.AddMod(RockCamYeeter);
	}

	[IteratorStateMachine(typeof(<follow>d__7))]
	public IEnumerator follow(float time)
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <follow>d__7(0)
		{
			<>4__this = this,
			time = time
		};
	}

	public void Save()
	{
		enabled = (bool)settings[0].SavedValue;
	}

	public void mapLoaded()
	{
		//IL_0022: Unknown result type (might be due to invalid IL or missing references)
		//IL_002c: Expected O, but got Unknown
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0037: Expected O, but got Unknown
		if (currentScene != "Loader" && enabled)
		{
			Camera = new Rock_Cam();
			inland = new GameObject();
			((Object)inland).name = "TheHolySpirit";
			body = inland.AddComponent<Rigidbody>();
			body.useGravity = false;
			body.mass = 1f;
			body.linearDamping = 0.5f;
		}
	}

	public override void OnUpdate()
	{
		//IL_017b: Unknown result type (might be due to invalid IL or missing references)
		//IL_018c: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01db: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
		//IL_0201: Unknown result type (might be due to invalid IL or missing references)
		//IL_0206: Unknown result type (might be due to invalid IL or missing references)
		//IL_007c: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00db: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e2: 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_00f8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0109: Unknown result type (might be due to invalid IL or missing references)
		//IL_010e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0119: Unknown result type (might be due to invalid IL or missing references)
		//IL_012a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0239: Unknown result type (might be due to invalid IL or missing references)
		//IL_0246: Unknown result type (might be due to invalid IL or missing references)
		//IL_024b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0253: Unknown result type (might be due to invalid IL or missing references)
		//IL_0261: Unknown result type (might be due to invalid IL or missing references)
		//IL_0266: Unknown result type (might be due to invalid IL or missing references)
		//IL_030c: Unknown result type (might be due to invalid IL or missing references)
		//IL_036a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0395: Unknown result type (might be due to invalid IL or missing references)
		if (!(currentScene != "Loader") || !enabled)
		{
			return;
		}
		Camera.handleBars.isHeldUpdate();
		int num = Camera.IsShownUpdate();
		if (Camera.handleBars.isHeld == 1)
		{
			inland.transform.position = ((Component)Camera._CameraController).gameObject.transform.position;
			inland.transform.rotation = ((Component)Camera._CameraController).gameObject.transform.rotation;
			oldoldposition = oldposition;
			oldposition = position;
			position = ((Component)body).transform.position;
			oldangle = angle;
			angle = ((Component)body).transform.rotation;
			angularVelocity = body.angularVelocity;
			body.velocity = Vector3.zero;
			body.angularVelocity = Vector3.zero;
		}
		if (Camera.handleBars.isHeld == 3)
		{
			try
			{
				MelonCoroutines.Stop(prevfollow);
			}
			catch
			{
				MelonLogger.Error("Yeah so the coroutine you wanted to remove? It ain't here");
			}
			trace = false;
			body.velocity = Vector3.zero;
			body.angularVelocity = Vector3.zero;
		}
		if (Camera.handleBars.isHeld == 2)
		{
			body.velocity = (((Component)body).transform.position - oldposition) / Time.deltaTime;
			Quaternion val = ((Component)body).transform.rotation * Quaternion.Inverse(oldangle);
			float num2 = default(float);
			Vector3 val2 = default(Vector3);
			((Quaternion)(ref val)).ToAngleAxis(ref num2, ref val2);
			if (num2 > 180f)
			{
				num2 -= 360f;
			}
			float num3 = num2 * ((float)Math.PI / 180f);
			Vector3 val3 = ((Vector3)(ref val2)).normalized * (num3 / Time.deltaTime);
			body.angularVelocity = val3;
			Vector3 val4 = body.velocity;
			if (((Vector3)(ref val4)).magnitude > (float)settings[3].SavedValue)
			{
				try
				{
					MelonCoroutines.Stop(prevfollow);
				}
				catch
				{
					MelonLogger.Error("Yeah so the coroutine you wanted to remove? It ain't here");
				}
				prevfollow = MelonCoroutines.Start(follow((float)settings[1].SavedValue));
			}
		}
		if (Camera.handleBars.isHeld == 0 && trace)
		{
			if (((Component)Camera._CameraController).transform.position.y < (float)settings[2].SavedValue)
			{
				trace = false;
			}
			body.useGravity = true;
			((Component)Camera._CameraController).gameObject.transform.position = inland.transform.position;
			((Component)Camera._CameraController).gameObject.transform.rotation = inland.transform.rotation;
		}
		else
		{
			body.useGravity = false;
		}
	}
}