Decompiled source of RockCamYeeter v1.0.1

Mods/RockCamYeeter.dll

Decompiled 2 weeks 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.RMAPI;
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.1", "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.1";

	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;

		private DateTime <end>5__1;

		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_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Expected O, but got Unknown
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				<>4__this.trace = true;
				<end>5__1 = DateTime.Now.AddSeconds(time);
				break;
			case 1:
				<>1__state = -1;
				break;
			}
			if (DateTime.Now <= <end>5__1)
			{
				if (<>4__this.Camera.handleBars.isHeld == 3 || <>4__this.Camera.isShown % 2 == 0)
				{
					<>4__this.trace = false;
					<>4__this.body.velocity = Vector3.zero;
					<>4__this.body.angularVelocity = Vector3.zero;
					return false;
				}
				<>2__current = (object)new WaitForFixedUpdate();
				<>1__state = 1;
				return true;
			}
			<>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;

	private Vector3 size = new Vector3(0.45f, 0.23f, 0.15f);

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

	public override void OnLateInitializeMelon()
	{
		Actions.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
		//IL_011d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0127: Expected O, but got Unknown
		RockCamYeeter.ModName = "RockCamYeeter";
		RockCamYeeter.ModVersion = "1.0.1";
		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()));
		settings.Add((ModSetting)(object)RockCamYeeter.AddToList("Environment collision", false, 0, "coli with the envo or negatory", 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()
	{
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		enabled = (bool)settings[0].SavedValue;
		BoxCollider val = inland.GetComponent<BoxCollider>();
		if ((bool)settings[5].SavedValue)
		{
			if ((Object)(object)val == (Object)null)
			{
				val = inland.AddComponent<BoxCollider>();
			}
			val.size = size;
		}
		else if ((Object)(object)val != (Object)null)
		{
			Object.Destroy((Object)(object)val);
		}
	}

	public void mapLoaded(string currentScene)
	{
		//IL_0020: Unknown result type (might be due to invalid IL or missing references)
		//IL_002a: Expected O, but got Unknown
		//IL_002b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0035: Expected O, but got Unknown
		//IL_0080: Unknown result type (might be due to invalid IL or missing references)
		if (currentScene != "Loader" && enabled)
		{
			Camera = new Rock_Cam();
			inland = new GameObject();
			((Object)inland).name = "TheHolySpirit";
			body = inland.AddComponent<Rigidbody>();
			if ((bool)settings[5].SavedValue)
			{
				BoxCollider val = inland.AddComponent<BoxCollider>();
				val.size = size;
				inland.layer = 3;
			}
			body.useGravity = false;
			body.mass = 1f;
			body.linearDamping = 0.5f;
		}
	}

	public override void OnUpdate()
	{
		//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_0162: Unknown result type (might be due to invalid IL or missing references)
		//IL_0168: Unknown result type (might be due to invalid IL or missing references)
		//IL_016d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0177: Unknown result type (might be due to invalid IL or missing references)
		//IL_018d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0193: Unknown result type (might be due to invalid IL or missing references)
		//IL_0198: Unknown result type (might be due to invalid IL or missing references)
		//IL_019d: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0202: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_0306: Unknown result type (might be due to invalid IL or missing references)
		//IL_0331: 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 == 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 * Mathf.Deg2Rad;
			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;
		}
	}
}