Decompiled source of HeinhouserHoloLens v1.0.1

Mods/HeinhouserHoloLens.dll

Decompiled 10 hours 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 HarmonyLib;
using HeinhouserHoloLens;
using Il2CppLiv.Lck;
using Il2CppRUMBLE.Managers;
using Il2CppRUMBLE.Recording.LCK;
using Il2CppRUMBLE.Recording.LCK.Extensions;
using Il2CppRUMBLE.Utilities;
using MelonLoader;
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(Core), "HeinhouserHoloLens", "1.0.1", "UlvakSkillz", null)]
[assembly: MelonGame("Buckethead Entertainment", "RUMBLE")]
[assembly: MelonColor(255, 195, 0, 255)]
[assembly: MelonAuthorColor(255, 195, 0, 255)]
[assembly: VerifyLoaderVersion(0, 7, 2, true)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("HeinhouserHoloLens")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+5cc1f8599dee451fc8a33c375f6c11c88e375958")]
[assembly: AssemblyProduct("HeinhouserHoloLens")]
[assembly: AssemblyTitle("HeinhouserHoloLens")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace HeinhouserHoloLens;

internal static class CameraSettings
{
	internal static int parkPlayer1 = 0;

	internal static int parkPlayer2 = 1;

	internal static float cameraMoveSpeed = 6.5f;

	internal static float cameraOrbitSpeed = 6f;

	internal static float cameraPositionCorrectionScaler = 0.01f;

	internal static float cameraDistanceFromMapCenterAllowed = 10.25f;

	internal static float playerCenterSmoothing = 6f;

	internal static float cameraPositionIncrease = 2f;

	internal static float cameraPositionFalloff = 0.25f;

	internal static float cameraPositionBuffer = 0.1f;

	internal static float allowedHeightScaler = 1.5f;

	internal static void SetStats(int parkPlayer1, int parkPlayer2, float cameraMoveSpeed, float cameraOrbitSpeed, float cameraPositionCorrectionScaler, float cameraDistanceFromMapCenterAllowed, float playerCenterSmoothing, float cameraPositionIncrease, float cameraPositionFalloff, float cameraPositionBuffer, float allowedHeightScaler)
	{
		CameraSettings.parkPlayer1 = parkPlayer1;
		CameraSettings.parkPlayer2 = parkPlayer2;
		CameraSettings.cameraMoveSpeed = cameraMoveSpeed;
		CameraSettings.cameraOrbitSpeed = cameraOrbitSpeed;
		CameraSettings.cameraPositionCorrectionScaler = cameraPositionCorrectionScaler;
		CameraSettings.cameraDistanceFromMapCenterAllowed = cameraDistanceFromMapCenterAllowed;
		CameraSettings.playerCenterSmoothing = playerCenterSmoothing;
		CameraSettings.cameraPositionIncrease = cameraPositionIncrease;
		CameraSettings.cameraPositionFalloff = cameraPositionFalloff;
		CameraSettings.cameraPositionBuffer = cameraPositionBuffer;
		CameraSettings.allowedHeightScaler = allowedHeightScaler;
	}

	internal static string SettingsToString()
	{
		return $"{(Core.isMatchmaking ? "player1 = 0, player2 = 1, " : ((Core.currentScene == "Park") ? $"parkPlayer1 = {parkPlayer1}, parkPlayer2 = {parkPlayer2}, " : ""))}cameraMoveSpeed = {cameraMoveSpeed}, cameraOrbitSpeed = {cameraOrbitSpeed}, cameraPositionCorrectionScaler = {cameraPositionCorrectionScaler}, CameraDistanceFromMapCenterAllowed = {cameraDistanceFromMapCenterAllowed}, playerCenterSmoothing = {playerCenterSmoothing}, cameraPositionIncrease = {cameraPositionIncrease}, cameraPositionFalloff = {cameraPositionFalloff}, cameraPositionBuffer = {cameraPositionBuffer}, allowedHeightScaler = {allowedHeightScaler}";
	}
}
internal class CameraControl
{
	[HarmonyPatch(typeof(LCKTabletUtility), "OnRecordingStarted", new Type[] { typeof(LckResult) })]
	public static class LCKTabletUtilityOnRecordingStartedPatch
	{
		private static void Postfix(LckResult result)
		{
			IsRecording = true;
			UpdateRecordingLens();
		}
	}

	[HarmonyPatch(typeof(LCKTabletUtility), "OnRecordingStopped", new Type[] { typeof(LckResult) })]
	public static class LCKTabletUtilityOnRecordingStoppedPatch
	{
		private static void Postfix(LckResult result)
		{
			IsRecording = false;
			UpdateRecordingLens();
		}
	}

	[CompilerGenerated]
	private sealed class <RunSpectateCamera>d__18 : IEnumerator<object>, IEnumerator, IDisposable
	{
		private int <>1__state;

		private object <>2__current;

		public int player1;

		public int player2;

		private Transform <selectedPlayer1>5__1;

		private Transform <selectedPlayer2>5__2;

		private Transform <cameraRotationControl>5__3;

		private Transform <originalParent>5__4;

		private Vector3 <originalLocalPos>5__5;

		private Quaternion <originalLocalRot>5__6;

		private float <localDistance>5__7;

		private float <remoteDistance>5__8;

		private float <playerCenterLerpSpot>5__9;

		private Vector3 <smoothedPlayersCenter>5__10;

		private bool <isOrbitingRight>5__11;

		private Vector3 <rawPlayersCenter>5__12;

		private float <distanceToPlayersCenter>5__13;

		private float <distanceToCenter>5__14;

		private float <baseDistance>5__15;

		private float <scaledIncrease>5__16;

		private float <idealCameraDistance>5__17;

		private float <allowedHeight>5__18;

		private float <clampedY>5__19;

		private Vector3 <clampedYVector>5__20;

		private Vector3 <dirFromCenter>5__21;

		private Vector3 <movementAmount>5__22;

		private Vector3 <desiredOrbitPos>5__23;

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

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

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

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<selectedPlayer1>5__1 = null;
			<selectedPlayer2>5__2 = null;
			<cameraRotationControl>5__3 = null;
			<originalParent>5__4 = null;
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Expected O, but got Unknown
			//IL_02c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_031d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0328: Unknown result type (might be due to invalid IL or missing references)
			//IL_0333: Unknown result type (might be due to invalid IL or missing references)
			//IL_0338: Unknown result type (might be due to invalid IL or missing references)
			//IL_033f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0345: Unknown result type (might be due to invalid IL or missing references)
			//IL_0355: Unknown result type (might be due to invalid IL or missing references)
			//IL_035a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0361: Unknown result type (might be due to invalid IL or missing references)
			//IL_036b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0381: Unknown result type (might be due to invalid IL or missing references)
			//IL_038c: Unknown result type (might be due to invalid IL or missing references)
			//IL_03de: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cb: 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_01db: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_020b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0216: 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_0251: Unknown result type (might be due to invalid IL or missing references)
			//IL_025c: 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_0491: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_04df: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0505: Unknown result type (might be due to invalid IL or missing references)
			//IL_0515: Unknown result type (might be due to invalid IL or missing references)
			//IL_0428: Unknown result type (might be due to invalid IL or missing references)
			//IL_042e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0433: Unknown result type (might be due to invalid IL or missing references)
			//IL_0438: Unknown result type (might be due to invalid IL or missing references)
			//IL_043c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0441: Unknown result type (might be due to invalid IL or missing references)
			//IL_0452: Unknown result type (might be due to invalid IL or missing references)
			//IL_0458: Unknown result type (might be due to invalid IL or missing references)
			//IL_045e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0469: Unknown result type (might be due to invalid IL or missing references)
			//IL_046e: Unknown result type (might be due to invalid IL or missing references)
			//IL_047e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0295: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_0626: Unknown result type (might be due to invalid IL or missing references)
			//IL_0631: Unknown result type (might be due to invalid IL or missing references)
			//IL_0530: Unknown result type (might be due to invalid IL or missing references)
			//IL_053b: Unknown result type (might be due to invalid IL or missing references)
			//IL_054b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0555: Unknown result type (might be due to invalid IL or missing references)
			//IL_072e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0744: Unknown result type (might be due to invalid IL or missing references)
			//IL_075a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0766: Unknown result type (might be due to invalid IL or missing references)
			//IL_0770: Expected O, but got Unknown
			//IL_05db: Unknown result type (might be due to invalid IL or missing references)
			//IL_05f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_083b: Unknown result type (might be due to invalid IL or missing references)
			//IL_084c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0666: Unknown result type (might be due to invalid IL or missing references)
			//IL_066b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0675: Unknown result type (might be due to invalid IL or missing references)
			//IL_067a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0686: Unknown result type (might be due to invalid IL or missing references)
			//IL_068c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0691: Unknown result type (might be due to invalid IL or missing references)
			//IL_0696: Unknown result type (might be due to invalid IL or missing references)
			//IL_06a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_06bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_056e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0579: Unknown result type (might be due to invalid IL or missing references)
			//IL_0583: Unknown result type (might be due to invalid IL or missing references)
			//IL_0588: Unknown result type (might be due to invalid IL or missing references)
			//IL_059a: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_05cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_06e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_06e7: Unknown result type (might be due to invalid IL or missing references)
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				Melon<Core>.Logger.Msg("Playing Spectate Mode: " + CameraSettings.SettingsToString());
				if (cameraIsBeingControlled)
				{
					cameraIsBeingControlled = false;
					<>2__current = (object)new WaitForFixedUpdate();
					<>1__state = 1;
					return true;
				}
				goto IL_0074;
			case 1:
				<>1__state = -1;
				goto IL_0074;
			case 2:
				{
					<>1__state = -1;
					break;
				}
				IL_0074:
				cameraIsBeingControlled = true;
				<selectedPlayer1>5__1 = ((Singleton<PlayerManager>.instance.AllPlayers.Count > player1) ? ((Component)Singleton<PlayerManager>.instance.AllPlayers[player1].Controller).transform.FindChild("Visuals/Skelington/Bone_Pelvis/Bone_Spine_A/Bone_Chest") : ((Component)Singleton<PlayerManager>.instance.localPlayer.Controller).transform.FindChild("Visuals/Skelington/Bone_Pelvis/Bone_Spine_A/Bone_Chest"));
				<selectedPlayer2>5__2 = ((Singleton<PlayerManager>.instance.AllPlayers.Count > player2) ? ((Component)Singleton<PlayerManager>.instance.AllPlayers[player2].Controller).transform.FindChild("Visuals/Skelington/Bone_Pelvis/Bone_Spine_A/Bone_Chest") : ((Component)Singleton<PlayerManager>.instance.localPlayer.Controller).transform.FindChild("Visuals/Skelington/Bone_Pelvis/Bone_Spine_A/Bone_Chest"));
				camera = ((Component)Singleton<PlayerManager>.instance.localPlayer.Controller.PlayerLIV.LckTablet.selfieCamera).gameObject.transform.parent;
				<cameraRotationControl>5__3 = new GameObject("SmoothCameraControl").transform;
				<originalParent>5__4 = ((Component)Singleton<PlayerManager>.instance.localPlayer.Controller.PlayerLIV.LckTablet.selfieCamera).gameObject.transform.parent.parent;
				<originalLocalPos>5__5 = camera.localPosition;
				<originalLocalRot>5__6 = camera.localRotation;
				<localDistance>5__7 = Vector3.Distance(camera.position, <selectedPlayer1>5__1.position);
				<remoteDistance>5__8 = Vector3.Distance(camera.position, <selectedPlayer2>5__2.position);
				<playerCenterLerpSpot>5__9 = <remoteDistance>5__8 / (<localDistance>5__7 + <remoteDistance>5__8);
				<smoothedPlayersCenter>5__10 = Vector3.Lerp(<selectedPlayer2>5__2.position, <selectedPlayer1>5__1.position, <playerCenterLerpSpot>5__9);
				camera.SetParent((Transform)null);
				<isOrbitingRight>5__11 = true;
				if (Core.showHoloLensInGame)
				{
					CreateHoloLens();
				}
				<cameraRotationControl>5__3.position = camera.position;
				<cameraRotationControl>5__3.rotation = camera.rotation;
				break;
			}
			if (cameraIsBeingControlled && (Object)(object)<selectedPlayer1>5__1 != (Object)null && (Object)(object)<selectedPlayer2>5__2 != (Object)null && (Object)(object)camera != (Object)null && (Object)(object)<cameraRotationControl>5__3 != (Object)null)
			{
				<localDistance>5__7 = Vector3.Distance(camera.position, <selectedPlayer1>5__1.position);
				<remoteDistance>5__8 = Vector3.Distance(camera.position, <selectedPlayer2>5__2.position);
				<playerCenterLerpSpot>5__9 = <remoteDistance>5__8 / (<localDistance>5__7 + <remoteDistance>5__8);
				<rawPlayersCenter>5__12 = Vector3.Lerp(<selectedPlayer2>5__2.position, <selectedPlayer1>5__1.position, <playerCenterLerpSpot>5__9);
				<smoothedPlayersCenter>5__10 = Vector3.Lerp(<smoothedPlayersCenter>5__10, <rawPlayersCenter>5__12, CameraSettings.playerCenterSmoothing * Time.fixedDeltaTime);
				<distanceToPlayersCenter>5__13 = Vector3.Distance(<smoothedPlayersCenter>5__10, camera.position);
				<baseDistance>5__15 = Vector3.Distance(<selectedPlayer1>5__1.position, <selectedPlayer2>5__2.position) / 2f;
				<scaledIncrease>5__16 = CameraSettings.cameraPositionIncrease / (1f + <baseDistance>5__15 * CameraSettings.cameraPositionFalloff);
				<idealCameraDistance>5__17 = <baseDistance>5__15 + <scaledIncrease>5__16;
				<allowedHeight>5__18 = Math.Min(10f, Vector3.Distance(<selectedPlayer1>5__1.position, <selectedPlayer2>5__2.position) / CameraSettings.allowedHeightScaler);
				if (Mathf.Abs(<distanceToPlayersCenter>5__13 - <idealCameraDistance>5__17) > CameraSettings.cameraPositionBuffer)
				{
					Vector3 val = <cameraRotationControl>5__3.position - <smoothedPlayersCenter>5__10;
					<dirFromCenter>5__21 = ((Vector3)(ref val)).normalized;
					<cameraRotationControl>5__3.position = Vector3.Lerp(<cameraRotationControl>5__3.position, <smoothedPlayersCenter>5__10 + <dirFromCenter>5__21 * <idealCameraDistance>5__17, Time.fixedDeltaTime * CameraSettings.cameraMoveSpeed);
				}
				<clampedY>5__19 = Mathf.Clamp(<cameraRotationControl>5__3.position.y, <smoothedPlayersCenter>5__10.y, <smoothedPlayersCenter>5__10.y + <allowedHeight>5__18);
				<clampedYVector>5__20 = new Vector3(<cameraRotationControl>5__3.position.x, <clampedY>5__19, <cameraRotationControl>5__3.position.z);
				<cameraRotationControl>5__3.position = Vector3.Lerp(<cameraRotationControl>5__3.position, <clampedYVector>5__20, Time.fixedDeltaTime * CameraSettings.cameraMoveSpeed);
				if (Core.isMatchmaking)
				{
					<distanceToCenter>5__14 = Vector2.Distance(Vector2.zero, new Vector2(<cameraRotationControl>5__3.position.x, <cameraRotationControl>5__3.position.z));
					while (Vector2.Distance(Vector2.zero, new Vector2(<smoothedPlayersCenter>5__10.x, <smoothedPlayersCenter>5__10.z)) < CameraSettings.cameraDistanceFromMapCenterAllowed && <distanceToCenter>5__14 > CameraSettings.cameraDistanceFromMapCenterAllowed)
					{
						Transform obj = <cameraRotationControl>5__3;
						obj.position += <cameraRotationControl>5__3.forward * CameraSettings.cameraPositionCorrectionScaler;
						<cameraRotationControl>5__3.LookAt(<smoothedPlayersCenter>5__10);
						<distanceToCenter>5__14 = Vector2.Distance(Vector2.zero, new Vector2(<cameraRotationControl>5__3.position.x, <cameraRotationControl>5__3.position.z));
					}
				}
				if (Vector3.Distance(camera.position, <cameraRotationControl>5__3.position) < CameraSettings.cameraPositionBuffer / CameraSettings.cameraDistanceFromMapCenterAllowed)
				{
					<movementAmount>5__22 = (float)(<isOrbitingRight>5__11 ? 1 : (-1)) * <cameraRotationControl>5__3.right * CameraSettings.cameraPositionCorrectionScaler;
					<desiredOrbitPos>5__23 = <cameraRotationControl>5__3.position - <movementAmount>5__22;
					if (!Core.isMatchmaking || Vector2.Distance(Vector2.zero, new Vector2(<desiredOrbitPos>5__23.x, <desiredOrbitPos>5__23.z)) <= CameraSettings.cameraDistanceFromMapCenterAllowed)
					{
						<cameraRotationControl>5__3.RotateAround(<smoothedPlayersCenter>5__10, Vector3.up, (<isOrbitingRight>5__11 ? 1f : (-1f)) * CameraSettings.cameraOrbitSpeed * Time.fixedDeltaTime);
					}
					else
					{
						<isOrbitingRight>5__11 = !<isOrbitingRight>5__11;
					}
				}
				<cameraRotationControl>5__3.LookAt(<smoothedPlayersCenter>5__10);
				camera.position = <cameraRotationControl>5__3.position;
				camera.rotation = <cameraRotationControl>5__3.rotation;
				<>2__current = (object)new WaitForFixedUpdate();
				<>1__state = 2;
				return true;
			}
			IsActiveHoloLensNormal = true;
			if ((Object)(object)activeHoloLens != (Object)null)
			{
				Object.Destroy((Object)(object)activeHoloLens);
			}
			if ((Object)(object)<cameraRotationControl>5__3 != (Object)null)
			{
				Object.Destroy((Object)(object)((Component)<cameraRotationControl>5__3).gameObject);
			}
			if ((Object)(object)camera != (Object)null)
			{
				camera.SetParent(<originalParent>5__4);
				camera.localPosition = <originalLocalPos>5__5;
				camera.localRotation = <originalLocalRot>5__6;
			}
			if (Core.revertTo1stPerson)
			{
				Singleton<PlayerManager>.instance.localPlayer.Controller.PlayerLIV.LckTablet.lckCameraController.CameraModeChanged((CameraMode)1);
			}
			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();
		}
	}

	[CompilerGenerated]
	private sealed class <StartSpectateCoroutine>d__17 : IEnumerator<object>, IEnumerator, IDisposable
	{
		private int <>1__state;

		private object <>2__current;

		public int player1;

		public int player2;

		private LCKCameraController <lckCameraController>5__1;

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

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

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

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

		private bool MoveNext()
		{
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Expected O, but got Unknown
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Expected O, but got Unknown
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Invalid comparison between Unknown and I4
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Expected O, but got Unknown
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				Singleton<PlayerManager>.instance.localPlayer.Controller.PlayerLIV.ShowTablet();
				<>2__current = (object)new WaitForSeconds(0.25f);
				<>1__state = 1;
				return true;
			case 1:
				<>1__state = -1;
				MelonCoroutines.Start(RunSpectateCamera(player1, player2));
				<>2__current = (object)new WaitForSeconds(0.5f);
				<>1__state = 2;
				return true;
			case 2:
				<>1__state = -1;
				<lckCameraController>5__1 = Singleton<PlayerManager>.instance.localPlayer.Controller.PlayerLIV.LckTablet.lckCameraController;
				<lckCameraController>5__1.CameraModeChanged((CameraMode)0);
				<lckCameraController>5__1.SelfieFOVDoubleButton.ApplySavedData(90);
				<lckCameraController>5__1.SelfieSmoothingDoubleButton.ApplySavedData(0);
				if ((int)<lckCameraController>5__1.CurrentCameraOrientation == 0)
				{
					<lckCameraController>5__1._orientationButton.RPC_OnPressed();
				}
				<>2__current = (object)new WaitForSeconds(0.25f);
				<>1__state = 3;
				return true;
			case 3:
				<>1__state = -1;
				Singleton<PlayerManager>.instance.localPlayer.Controller.PlayerLIV.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 static bool cameraIsBeingControlled = false;

	private static GameObject ddolHoloLens = null;

	private static GameObject activeHoloLens = null;

	private static Transform camera = null;

	private static bool IsRecording = false;

	private static bool grabbedMaterial = false;

	private static bool IsActiveHoloLensNormal = true;

	private static int headShotPercent = 100;

	internal static void OnLateInitializeMelon()
	{
		ddolHoloLens = Object.Instantiate<GameObject>(AssetBundles.LoadAssetFromStream<GameObject>(Core.instance, "HeinhouserHoloLens.hololens", "HoloLens"));
		((Object)ddolHoloLens).name = "HoloLens";
		ddolHoloLens.SetActive(false);
		Object.DontDestroyOnLoad((Object)(object)ddolHoloLens);
	}

	internal static void OnSceneWasLoaded()
	{
		cameraIsBeingControlled = false;
	}

	internal static void MapLoaded(string map)
	{
		if (!grabbedMaterial && Core.currentScene == "Gym")
		{
			((Renderer)((Component)ddolHoloLens.transform.GetChild(0).GetChild(3)).GetComponent<MeshRenderer>()).material = ((Renderer)TposePlayer.GetGameObject().GetComponent<MeshRenderer>()).material;
			grabbedMaterial = true;
		}
		if (Core.modEnabled && Core.isMatchmaking)
		{
			StartSpectate();
		}
		else if (Core.modEnabled && Core.revertTo1stPerson && Core.currentScene == "Gym")
		{
			Singleton<PlayerManager>.instance.localPlayer.Controller.PlayerLIV.LckTablet.lckCameraController.CameraModeChanged((CameraMode)1);
		}
	}

	internal static void Save(bool holoLensEnabledChanged, bool showCameraInGameChanged, bool parkSpectateActiveChanged)
	{
		int parkPlayer = CameraSettings.parkPlayer1;
		int parkPlayer2 = CameraSettings.parkPlayer2;
		float cameraMoveSpeed = CameraSettings.cameraMoveSpeed;
		float cameraOrbitSpeed = CameraSettings.cameraOrbitSpeed;
		float cameraPositionCorrectionScaler = CameraSettings.cameraPositionCorrectionScaler;
		float cameraDistanceFromMapCenterAllowed = CameraSettings.cameraDistanceFromMapCenterAllowed;
		float playerCenterSmoothing = CameraSettings.playerCenterSmoothing;
		float cameraPositionIncrease = CameraSettings.cameraPositionIncrease;
		float cameraPositionFalloff = CameraSettings.cameraPositionFalloff;
		float cameraPositionBuffer = CameraSettings.cameraPositionBuffer;
		float allowedHeightScaler = CameraSettings.allowedHeightScaler;
		CameraSettings.SetStats((int)Core.settings[4].SavedValue, (int)Core.settings[5].SavedValue, (float)Core.settings[6].SavedValue, (float)Core.settings[7].SavedValue, (float)Core.settings[8].SavedValue, (float)Core.settings[9].SavedValue, (float)Core.settings[10].SavedValue, (float)Core.settings[11].SavedValue, (float)Core.settings[12].SavedValue, (float)Core.settings[13].SavedValue, (float)Core.settings[14].SavedValue);
		Core.settings[15].SavedValue = Math.Clamp((int)Core.settings[15].SavedValue, 0, 100);
		Core.settings[15].Value = (int)Core.settings[15].SavedValue;
		headShotPercent = (int)Core.settings[15].SavedValue;
		bool flag = parkPlayer != CameraSettings.parkPlayer1 || parkPlayer2 != CameraSettings.parkPlayer2;
		if (cameraMoveSpeed != CameraSettings.cameraMoveSpeed || cameraOrbitSpeed != CameraSettings.cameraOrbitSpeed || cameraPositionCorrectionScaler != CameraSettings.cameraPositionCorrectionScaler || cameraDistanceFromMapCenterAllowed != CameraSettings.cameraDistanceFromMapCenterAllowed || playerCenterSmoothing != CameraSettings.playerCenterSmoothing || cameraPositionIncrease != CameraSettings.cameraPositionIncrease || cameraPositionFalloff != CameraSettings.cameraPositionFalloff || cameraPositionBuffer != CameraSettings.cameraPositionBuffer || allowedHeightScaler != CameraSettings.allowedHeightScaler)
		{
			if (Core.modEnabled && Core.isMatchmaking && cameraIsBeingControlled)
			{
				StartSpectate();
			}
			else if (Core.modEnabled && cameraIsBeingControlled && Core.currentScene == "Park")
			{
				StartSpectate(CameraSettings.parkPlayer1, CameraSettings.parkPlayer2);
			}
		}
		else if (Core.isMatchmaking)
		{
			if (Core.modEnabled && showCameraInGameChanged)
			{
				if (Core.showHoloLensInGame && (Object)(object)activeHoloLens == (Object)null)
				{
					CreateHoloLens();
				}
				else if (!Core.showHoloLensInGame && (Object)(object)activeHoloLens != (Object)null)
				{
					Object.Destroy((Object)(object)activeHoloLens);
					activeHoloLens = null;
				}
			}
			if (holoLensEnabledChanged)
			{
				if (Core.modEnabled)
				{
					StartSpectate();
				}
				else
				{
					cameraIsBeingControlled = false;
				}
			}
		}
		else
		{
			if (!(Core.currentScene == "Park"))
			{
				return;
			}
			if (flag && Core.parkSpectateActive && Core.modEnabled)
			{
				StartSpectate(CameraSettings.parkPlayer1, CameraSettings.parkPlayer2);
			}
			if (parkSpectateActiveChanged)
			{
				if (Core.parkSpectateActive)
				{
					StartSpectate(CameraSettings.parkPlayer1, CameraSettings.parkPlayer2);
				}
				else
				{
					cameraIsBeingControlled = false;
				}
			}
		}
	}

	private static void UpdateRecordingLens()
	{
		if (IsActiveHoloLensNormal && (Object)(object)activeHoloLens != (Object)null)
		{
			((Component)activeHoloLens.transform.GetChild(0).GetChild(0)).gameObject.SetActive(!IsRecording);
			((Component)activeHoloLens.transform.GetChild(0).GetChild(1)).gameObject.SetActive(IsRecording);
		}
	}

	private static void CreateHoloLens()
	{
		//IL_0064: 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)
		if ((Object)(object)activeHoloLens == (Object)null)
		{
			activeHoloLens = Object.Instantiate<GameObject>(ddolHoloLens);
			((Object)activeHoloLens).name = "HoloLens";
			activeHoloLens.SetActive(true);
			activeHoloLens.transform.SetParent(camera.GetChild(0));
			activeHoloLens.transform.localPosition = Vector3.zero;
			activeHoloLens.transform.localRotation = Quaternion.identity;
			if (headShotPercent != 0 && Core.random.Next(1, 101) <= headShotPercent)
			{
				IsActiveHoloLensNormal = false;
				((Component)activeHoloLens.transform.GetChild(0).GetChild(0)).gameObject.SetActive(false);
				((Component)activeHoloLens.transform.GetChild(0).GetChild(1)).gameObject.SetActive(false);
				((Component)activeHoloLens.transform.GetChild(0).GetChild(2)).gameObject.SetActive(false);
				((Component)activeHoloLens.transform.GetChild(0).GetChild(3)).gameObject.SetActive(true);
			}
			else
			{
				UpdateRecordingLens();
			}
		}
	}

	private static void StartSpectate(int player1 = 0, int player2 = 1)
	{
		MelonCoroutines.Start(StartSpectateCoroutine(player1, player2));
	}

	[IteratorStateMachine(typeof(<StartSpectateCoroutine>d__17))]
	private static IEnumerator StartSpectateCoroutine(int player1 = 0, int player2 = 1)
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <StartSpectateCoroutine>d__17(0)
		{
			player1 = player1,
			player2 = player2
		};
	}

	[IteratorStateMachine(typeof(<RunSpectateCamera>d__18))]
	private static IEnumerator RunSpectateCamera(int player1 = 0, int player2 = 1)
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <RunSpectateCamera>d__18(0)
		{
			player1 = player1,
			player2 = player2
		};
	}
}
public static class BuildInfo
{
	public const string ModName = "HeinhouserHoloLens";

	public const string ModVersion = "1.0.1";

	public const string Author = "UlvakSkillz";
}
public class Core : MelonMod
{
	internal static MelonMod instance;

	internal static string currentScene = "Loader";

	private readonly Mod HeinhouserHoloLens = new Mod();

	internal static readonly List<ModSetting> settings = new List<ModSetting>();

	internal static bool modEnabled = true;

	internal static bool showHoloLensInGame = true;

	internal static bool parkSpectateActive = false;

	internal static bool revertTo1stPerson = true;

	internal static bool isMatchmaking = false;

	internal static Random random = new Random();

	public override void OnSceneWasLoaded(int buildIndex, string sceneName)
	{
		currentScene = sceneName;
		isMatchmaking = currentScene.Contains("Map");
		if (settings.Count > 3)
		{
			settings[3].Value = false;
			settings[3].SavedValue = false;
		}
		CameraControl.OnSceneWasLoaded();
	}

	public override void OnLateInitializeMelon()
	{
		instance = (MelonMod)(object)this;
		CameraControl.OnLateInitializeMelon();
		Actions.onMapInitialized += CameraControl.MapLoaded;
		UI.instance.UI_Initialized += UIInit;
	}

	private void UIInit()
	{
		//IL_004b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0055: Expected O, but got Unknown
		//IL_0072: Unknown result type (might be due to invalid IL or missing references)
		//IL_007c: Expected O, but got Unknown
		//IL_0099: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a3: Expected O, but got Unknown
		//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_00d2: Expected O, but got Unknown
		//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0107: Expected O, but got Unknown
		//IL_0132: Unknown result type (might be due to invalid IL or missing references)
		//IL_013c: Expected O, but got Unknown
		//IL_016b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0175: Expected O, but got Unknown
		//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ae: Expected O, but got Unknown
		//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e7: Expected O, but got Unknown
		//IL_0216: Unknown result type (might be due to invalid IL or missing references)
		//IL_0220: Expected O, but got Unknown
		//IL_024f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0259: Expected O, but got Unknown
		//IL_0288: Unknown result type (might be due to invalid IL or missing references)
		//IL_0292: Expected O, but got Unknown
		//IL_02c1: Unknown result type (might be due to invalid IL or missing references)
		//IL_02cb: Expected O, but got Unknown
		//IL_02fa: Unknown result type (might be due to invalid IL or missing references)
		//IL_0304: Expected O, but got Unknown
		//IL_0333: Unknown result type (might be due to invalid IL or missing references)
		//IL_033d: Expected O, but got Unknown
		//IL_0359: Unknown result type (might be due to invalid IL or missing references)
		//IL_0363: Expected O, but got Unknown
		HeinhouserHoloLens.ModName = "HeinhouserHoloLens";
		HeinhouserHoloLens.ModVersion = "1.0.1";
		HeinhouserHoloLens.SetFolder("HeinhouserHoloLens");
		settings.Add((ModSetting)(object)HeinhouserHoloLens.AddToList("Enable HoloLens", true, 0, "Toggles HoloLens Camera On/Off", new Tags()));
		settings.Add((ModSetting)(object)HeinhouserHoloLens.AddToList("Show HoloLens in Game", true, 0, "Toggles Camera Visuals On/Off", new Tags()));
		settings.Add((ModSetting)(object)HeinhouserHoloLens.AddToList("Revert To 1st Person", true, 0, "Reverts to 1st Person View whenever Entering the Gym or Spectating Stops", new Tags()));
		settings.Add((ModSetting)(object)HeinhouserHoloLens.AddToList("Park Spectate Activate", false, 0, "Toggles On/Off Park Spectate", new Tags
		{
			DoNotSave = true
		}));
		settings.Add((ModSetting)(object)HeinhouserHoloLens.AddToList("Park Player 1", 0, "Selects what Player to Spectate as Player 1 (0 = You, 1 = Oldest Remote Player, 2 = 2nd Oldest Remote Player, etc)" + Environment.NewLine + "Defaults to Local Player if invalid", new Tags()));
		settings.Add((ModSetting)(object)HeinhouserHoloLens.AddToList("Park Player 2", 1, "Selects what Player to Spectate as Player 2 (0 = You, 1 = Oldest Remote Player, 2 = 2nd Oldest Remote Player, etc)" + Environment.NewLine + "Defaults to Local Player if invalid", new Tags()));
		settings.Add((ModSetting)(object)HeinhouserHoloLens.AddToList("Camera Move Speed", 6.5f, "Controls how fast the Camera moves Forwards/Backwards and Up/Down" + Environment.NewLine + "Default: 6.5", new Tags()));
		settings.Add((ModSetting)(object)HeinhouserHoloLens.AddToList("Camera Orbit Speed", 6f, "Controls how fast the Camera Orbits around the Viewing Point" + Environment.NewLine + "Default: 6", new Tags()));
		settings.Add((ModSetting)(object)HeinhouserHoloLens.AddToList("Camera Position Correction Scaler", 0.01f, "Controls how fast the Camera moves when Orbiting and getting away from Walls" + Environment.NewLine + "Default: 0.01", new Tags()));
		settings.Add((ModSetting)(object)HeinhouserHoloLens.AddToList("Max Camera Distance From Map Center", 10.25f, "Controls how far the Camera can move from the Center of the Matchmaking Map" + Environment.NewLine + "Default: 10.25", new Tags()));
		settings.Add((ModSetting)(object)HeinhouserHoloLens.AddToList("Player Center Smoothing", 6f, "Controls how Smooth the Look at Center of the Players moves" + Environment.NewLine + "Default: 6", new Tags()));
		settings.Add((ModSetting)(object)HeinhouserHoloLens.AddToList("Camera Position Increase", 2f, "Controls how far away the Camera is from the Player's Center Point" + Environment.NewLine + "Default: 2", new Tags()));
		settings.Add((ModSetting)(object)HeinhouserHoloLens.AddToList("Camera Position Falloff", 0.25f, "Controls how fast the Camera Position Increase amount falls off" + Environment.NewLine + "Default: 0.25", new Tags()));
		settings.Add((ModSetting)(object)HeinhouserHoloLens.AddToList("Camera Position Buffer", 0.1f, "Determines if the Camera needs to move (small but not 0 is best)" + Environment.NewLine + "Default: 0.1", new Tags()));
		settings.Add((ModSetting)(object)HeinhouserHoloLens.AddToList("Allowed Height Scaler", 1.5f, "Scaled the Allowed Height of the Camera in comparison to the Player's Center Point Height (smaller = higher, bigger = lower)" + Environment.NewLine + "Default: 1.5", new Tags()));
		settings.Add((ModSetting)(object)HeinhouserHoloLens.AddToList("Head Camera Chance Percent", 1, "Changes the % chance to replace the HoloLens with a Player Head", new Tags()));
		HeinhouserHoloLens.GetFromFile();
		HeinhouserHoloLens.ModSaved += Save;
		UI.instance.AddMod(HeinhouserHoloLens);
		Save();
	}

	private void Save()
	{
		bool flag = modEnabled;
		bool flag2 = showHoloLensInGame;
		bool flag3 = parkSpectateActive;
		modEnabled = (bool)settings[0].SavedValue;
		showHoloLensInGame = (bool)settings[1].SavedValue;
		parkSpectateActive = (bool)settings[2].SavedValue;
		revertTo1stPerson = (bool)settings[3].SavedValue;
		CameraControl.Save(modEnabled != flag, showHoloLensInGame != flag2, parkSpectateActive != flag3);
	}
}