Decompiled source of Fly And Quicksave v3.0.1

Mods/FlyAndQuicksave.dll

Decompiled 2 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BabyStepsQuickSave;
using HarmonyLib;
using Il2Cpp;
using MelonLoader;
using Microsoft.CodeAnalysis;
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(Core), "FlyAndQuickSave", "1.0.0", "Caleb Orchard", null)]
[assembly: MelonGame("DefaultCompany", "BabySteps")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("FlyAndQuicksave")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("FlyAndQuicksave")]
[assembly: AssemblyTitle("FlyAndQuicksave")]
[assembly: NeutralResourcesLanguage("en-US")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace BabyStepsQuickSave
{
	public class Core : MelonMod
	{
		[CompilerGenerated]
		private sealed class <AdjustPlayerRotationAwayFromCamera>d__8 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public Core <>4__this;

			private Camera <cam>5__1;

			private Vector3 <playerPos>5__2;

			private Transform <playerTransform>5__3;

			private Vector3 <cameraPos>5__4;

			private Vector3 <directionFromCamera>5__5;

			private GameObject <dudest>5__6;

			private Quaternion <targetRotation>5__7;

			private Vector3 <preservedPosition>5__8;

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

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

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

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<cam>5__1 = null;
				<playerTransform>5__3 = null;
				<dudest>5__6 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0146: Unknown result type (might be due to invalid IL or missing references)
				//IL_014b: Unknown result type (might be due to invalid IL or missing references)
				//IL_01d0: 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_019b: Unknown result type (might be due to invalid IL or missing references)
				//IL_01a0: 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_01ec: Unknown result type (might be due to invalid IL or missing references)
				//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
				//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
				//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
				//IL_0203: Unknown result type (might be due to invalid IL or missing references)
				//IL_0236: Unknown result type (might be due to invalid IL or missing references)
				//IL_023b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0240: Unknown result type (might be due to invalid IL or missing references)
				//IL_024c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0251: Unknown result type (might be due to invalid IL or missing references)
				//IL_025d: Unknown result type (might be due to invalid IL or missing references)
				//IL_026f: Unknown result type (might be due to invalid IL or missing references)
				//IL_028b: Unknown result type (might be due to invalid IL or missing references)
				//IL_02ba: Unknown result type (might be due to invalid IL or missing references)
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = null;
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					if ((Object)(object)<>4__this.pm == (Object)null)
					{
						<dudest>5__6 = GameObject.Find("Dudest");
						if ((Object)(object)<dudest>5__6 == (Object)null)
						{
							MelonLogger.Msg("Could not find Dudest object");
							return false;
						}
						<>4__this.pm = <dudest>5__6.GetComponent<PlayerMovement>();
						<dudest>5__6 = null;
					}
					if ((Object)(object)<>4__this.pm == (Object)null)
					{
						MelonLogger.Msg("PlayerMovement component not found");
						return false;
					}
					<cam>5__1 = null;
					if (flyCamActive && (Object)(object)<>4__this.pm.flyCam != (Object)null)
					{
						<cam>5__1 = ((Component)<>4__this.pm.flyCam).GetComponent<Camera>();
					}
					if ((Object)(object)<cam>5__1 == (Object)null)
					{
						<cam>5__1 = Camera.main;
					}
					if ((Object)(object)<cam>5__1 == (Object)null)
					{
						MelonLogger.Msg("No camera found");
						return false;
					}
					<playerPos>5__2 = Vector3.zero;
					<playerTransform>5__3 = null;
					if ((Object)(object)<>4__this.pm.hipPivot != (Object)null)
					{
						<playerTransform>5__3 = <>4__this.pm.hipPivot;
						<playerPos>5__2 = <>4__this.pm.hipPivot.position;
					}
					else
					{
						<playerTransform>5__3 = ((Component)<>4__this.pm).transform;
						<playerPos>5__2 = ((Component)<>4__this.pm).transform.position;
					}
					<cameraPos>5__4 = ((Component)<cam>5__1).transform.position;
					<directionFromCamera>5__5 = <playerPos>5__2 - <cameraPos>5__4;
					<directionFromCamera>5__5.y = 0f;
					if (((Vector3)(ref <directionFromCamera>5__5)).sqrMagnitude > 0.01f)
					{
						<targetRotation>5__7 = Quaternion.LookRotation(<directionFromCamera>5__5);
						<preservedPosition>5__8 = <playerTransform>5__3.position;
						<playerTransform>5__3.rotation = <targetRotation>5__7;
						<playerTransform>5__3.position = <preservedPosition>5__8;
						<>4__this.pm.camAng = ((Quaternion)(ref <targetRotation>5__7)).eulerAngles.y;
						MelonLogger.Msg($"Rotation set to: {((Quaternion)(ref <targetRotation>5__7)).eulerAngles.y} degrees");
					}
					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 DevCheatChaperone dCC;

		private DevCheatsGoHere dCGH;

		private PlayerMovement pm;

		public static bool flyCamActive;

		private float flyCamSpeed = 10f;

		private float flyCamSpeedMultiplier = 1f;

		public override void OnInitializeMelon()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Expected O, but got Unknown
			GameObject val = new GameObject("DevCheatChaperone_Mod");
			dCC = val.AddComponent<DevCheatChaperone>();
			dCGH = val.AddComponent<DevCheatsGoHere>();
			Harmony val2 = new Harmony("BabyStepsQuickSave.InputOverride");
			val2.PatchAll();
		}

		public override void OnUpdate()
		{
			if (Input.GetKeyDown((KeyCode)290))
			{
				dCGH.SaveNatePos();
			}
			else if (Input.GetKeyDown((KeyCode)291))
			{
				dCGH.LoadNatePos();
			}
			else if (Input.GetKeyDown((KeyCode)282))
			{
				if ((Object)(object)pm == (Object)null)
				{
					GameObject val = GameObject.Find("Dudest");
					pm = val.GetComponent<PlayerMovement>();
				}
				pm.ToggleFlyCam();
				flyCamActive = !flyCamActive;
			}
			if (flyCamActive && (Object)(object)pm != (Object)null && (Object)(object)pm.flyCam != (Object)null)
			{
				HandleFlyCamMovement();
				HandleFlyCamScrollWheel();
				if (Input.GetMouseButtonDown(0))
				{
					MelonCoroutines.Start(AdjustPlayerRotationAwayFromCamera());
				}
			}
		}

		[IteratorStateMachine(typeof(<AdjustPlayerRotationAwayFromCamera>d__8))]
		private IEnumerator AdjustPlayerRotationAwayFromCamera()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <AdjustPlayerRotationAwayFromCamera>d__8(0)
			{
				<>4__this = this
			};
		}

		private void HandleFlyCamMovement()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: 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)
			Vector3 val = Vector3.zero;
			if (Input.GetKey((KeyCode)119))
			{
				val += Vector3.forward;
			}
			if (Input.GetKey((KeyCode)115))
			{
				val += Vector3.back;
			}
			if (Input.GetKey((KeyCode)97))
			{
				val += Vector3.left;
			}
			if (Input.GetKey((KeyCode)100))
			{
				val += Vector3.right;
			}
			if (Input.GetKey((KeyCode)101))
			{
				val += Vector3.up;
			}
			if (Input.GetKey((KeyCode)113))
			{
				val += Vector3.down;
			}
			if (((Vector3)(ref val)).magnitude > 1f)
			{
				((Vector3)(ref val)).Normalize();
			}
			float num = 1f;
			bool flag = Input.GetKey((KeyCode)304) || Input.GetKey((KeyCode)303);
			bool flag2 = Input.GetKey((KeyCode)306) || Input.GetKey((KeyCode)305);
			if (flag && flag2)
			{
				num = 7f;
			}
			else if (flag2)
			{
				num = 5f;
			}
			else if (flag)
			{
				num = 2f;
			}
			Transform transform = ((Component)pm.flyCam).transform;
			Vector3 val2 = transform.TransformDirection(val);
			Vector3 val3 = val2 * Mathf.Abs(flyCamSpeed * flyCamSpeedMultiplier * num);
			transform.position += val3 * Time.deltaTime;
		}

		private void HandleFlyCamScrollWheel()
		{
			float axis = Input.GetAxis("Mouse ScrollWheel");
			if (axis == 0f)
			{
				return;
			}
			if (Input.GetKey((KeyCode)308) || Input.GetKey((KeyCode)307))
			{
				if (axis > 0f)
				{
					pm.IncreaseFlyCamFOV();
				}
				else
				{
					pm.DecreaseFlyCamFOV();
				}
			}
			else if (axis > 0f)
			{
				flyCamSpeedMultiplier = Mathf.Min(flyCamSpeedMultiplier * 1.2f, 10f);
			}
			else
			{
				flyCamSpeedMultiplier = Mathf.Max(flyCamSpeedMultiplier * 0.8f, 0.1f);
			}
		}
	}
	[HarmonyPatch(typeof(Input))]
	public static class InputPatches
	{
		[HarmonyPrefix]
		[HarmonyPatch("GetKey", new Type[] { typeof(KeyCode) })]
		public static bool GetKeyPrefix(KeyCode key, ref bool __result)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Invalid comparison between Unknown and I4
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Invalid comparison between Unknown and I4
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Invalid comparison between Unknown and I4
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Invalid comparison between Unknown and I4
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Invalid comparison between Unknown and I4
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Invalid comparison between Unknown and I4
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Invalid comparison between Unknown and I4
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Invalid comparison between Unknown and I4
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Invalid comparison between Unknown and I4
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Invalid comparison between Unknown and I4
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Invalid comparison between Unknown and I4
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Invalid comparison between Unknown and I4
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Invalid comparison between Unknown and I4
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Invalid comparison between Unknown and I4
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Invalid comparison between Unknown and I4
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Invalid comparison between Unknown and I4
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Invalid comparison between Unknown and I4
			if (!Core.flyCamActive)
			{
				return true;
			}
			if ((int)key == 119 || (int)key == 97 || (int)key == 115 || (int)key == 100 || (int)key == 113 || (int)key == 101 || (int)key == 304 || (int)key == 303 || (int)key == 306 || (int)key == 305 || (int)key == 308 || (int)key == 307 || (int)key == 282 || (int)key == 284 || (int)key == 285 || (int)key == 290 || (int)key == 291)
			{
				return true;
			}
			__result = false;
			return false;
		}

		[HarmonyPrefix]
		[HarmonyPatch("GetKeyDown", new Type[] { typeof(KeyCode) })]
		public static bool GetKeyDownPrefix(KeyCode key, ref bool __result)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Invalid comparison between Unknown and I4
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Invalid comparison between Unknown and I4
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Invalid comparison between Unknown and I4
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Invalid comparison between Unknown and I4
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Invalid comparison between Unknown and I4
			if (!Core.flyCamActive)
			{
				return true;
			}
			if ((int)key == 282 || (int)key == 284 || (int)key == 285 || (int)key == 290 || (int)key == 291)
			{
				return true;
			}
			__result = false;
			return false;
		}

		[HarmonyPrefix]
		[HarmonyPatch("GetAxis", new Type[] { typeof(string) })]
		public static bool GetAxisPrefix(string axisName, ref float __result)
		{
			if (!Core.flyCamActive)
			{
				return true;
			}
			if (axisName == "Mouse ScrollWheel" || axisName == "Mouse X" || axisName == "Mouse Y")
			{
				return true;
			}
			__result = 0f;
			return false;
		}

		[HarmonyPrefix]
		[HarmonyPatch("GetMouseButton", new Type[] { typeof(int) })]
		public static bool GetMouseButtonPrefix(int button, ref bool __result)
		{
			if (!Core.flyCamActive)
			{
				return true;
			}
			if (button == 0)
			{
				return true;
			}
			__result = false;
			return false;
		}

		[HarmonyPrefix]
		[HarmonyPatch("GetMouseButtonDown", new Type[] { typeof(int) })]
		public static bool GetMouseButtonDownPrefix(int button, ref bool __result)
		{
			if (!Core.flyCamActive)
			{
				return true;
			}
			if (button == 0)
			{
				return true;
			}
			__result = false;
			return false;
		}

		[HarmonyPrefix]
		[HarmonyPatch("GetMouseButtonUp", new Type[] { typeof(int) })]
		public static bool GetMouseButtonUpPrefix(int button, ref bool __result)
		{
			if (!Core.flyCamActive)
			{
				return true;
			}
			if (button == 0)
			{
				return true;
			}
			__result = false;
			return false;
		}
	}
}