Decompiled source of First Person v1.0.1

ClassLibrary6.dll

Decompiled a day ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using UnityEngine;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("ClassLibrary6")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ClassLibrary6")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("66d40910-6d0a-4bb0-9793-dd16290cc3c4")]
[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 Gemini.Foddy.FirstPerson3D;

[BepInPlugin("com.user.goi.firstperson3d", "Getting Over It First Person 3D", "2.4.0")]
[BepInProcess("GettingOverIt.exe")]
public class FirstPerson3DMod : BaseUnityPlugin
{
	[CompilerGenerated]
	private sealed class <InitializeFirstPersonPerspective>d__24 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public FirstPerson3DMod <>4__this;

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

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

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

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

		private bool MoveNext()
		{
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				break;
			case 1:
				<>1__state = -1;
				break;
			}
			if ((Object)(object)<>4__this.player == (Object)null)
			{
				<>4__this.FindPlayerAndComponents();
				<>2__current = null;
				<>1__state = 1;
				return true;
			}
			<>4__this.DisablePlayerMeshRenderers(<>4__this.player.transform);
			<>4__this.PurgeCloudSystems();
			<>4__this.mainCam = Camera.main;
			if ((Object)(object)<>4__this.mainCam != (Object)null)
			{
				<>4__this.cameraTransform = ((Component)<>4__this.mainCam).transform;
				<>4__this.cameraTransform.SetParent((Transform)null);
				<>4__this.mainCam.orthographic = false;
				<>4__this.mainCam.fieldOfView = <>4__this.targetFOV;
				<>4__this.mainCam.nearClipPlane = 0.05f;
				<>4__this.mainCam.farClipPlane = 100000f;
				<>4__this.rotationY = 0f;
				<>4__this.rotationX = 90f;
				<>4__this.facingBackward = false;
				<>4__this.isFlipped = false;
				<>4__this.cameraTransform.localRotation = Quaternion.Euler(0f, <>4__this.rotationX, 0f);
			}
			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 GameObject player;

	private Camera mainCam;

	private Transform cameraTransform;

	private Transform physicsZTarget;

	private float rotationX = 90f;

	private float rotationY = 0f;

	private float lookSensitivity = 3f;

	private bool facingBackward = false;

	private bool isFlipped = false;

	private Vector3 baseEyeLevelOffset = new Vector3(0f, 1.5f, 0f);

	public static float ThirdAxisSliderValue = -0.5f;

	private float manualAdjustmentX = -0.2f;

	private float manualAdjustmentY = 0f;

	private float targetFOV = 75f;

	private float minFOV = 65f;

	private float maxFOV = 85f;

	private float zoomSensitivity = 5f;

	private float zoomLerpSpeed = 10f;

	private void Awake()
	{
		SceneManager.sceneLoaded += OnSceneLoaded;
	}

	private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
	{
		ResetAndFindPlayer();
	}

	private void Update()
	{
		//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0225: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)player == (Object)null || (Object)(object)physicsZTarget == (Object)null)
		{
			FindPlayerAndComponents();
		}
		else
		{
			if ((Object)(object)cameraTransform == (Object)null || (Object)(object)mainCam == (Object)null)
			{
				return;
			}
			if (Input.GetKeyDown((KeyCode)101))
			{
				facingBackward = !facingBackward;
				rotationX = (facingBackward ? 270f : 90f);
				if (!Input.GetMouseButton(0))
				{
					float num = (isFlipped ? 180f : 0f);
					cameraTransform.localRotation = Quaternion.Euler(0f - rotationY, rotationX, num);
				}
			}
			float axis = Input.GetAxis("Mouse ScrollWheel");
			if (Mathf.Abs(axis) > 0.01f)
			{
				targetFOV -= axis * zoomSensitivity * 10f;
				targetFOV = Mathf.Clamp(targetFOV, minFOV, maxFOV);
			}
			mainCam.fieldOfView = Mathf.Lerp(mainCam.fieldOfView, targetFOV, Time.deltaTime * zoomLerpSpeed);
			if (Input.GetMouseButton(0))
			{
				Cursor.visible = false;
				Cursor.lockState = (CursorLockMode)1;
				float num2 = Input.GetAxis("Mouse Y") * lookSensitivity;
				rotationY += num2;
				float num3 = Mathf.Abs(rotationY % 360f);
				if ((num3 > 90f && num3 < 270f && !isFlipped) || ((num3 <= 90f || num3 >= 270f) && isFlipped))
				{
					isFlipped = !isFlipped;
				}
				float num4 = (isFlipped ? 180f : 0f);
				cameraTransform.localRotation = Quaternion.Euler(0f - rotationY, rotationX, num4);
			}
			else
			{
				Cursor.visible = true;
				Cursor.lockState = (CursorLockMode)0;
			}
		}
	}

	private void LateUpdate()
	{
		//IL_0045: Unknown result type (might be due to invalid IL or missing references)
		//IL_004b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0050: Unknown result type (might be due to invalid IL or missing references)
		//IL_0055: Unknown result type (might be due to invalid IL or missing references)
		//IL_007b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0096: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)(object)player == (Object)null) && !((Object)(object)cameraTransform == (Object)null))
		{
			Transform val = physicsZTarget ?? player.transform;
			Vector3 position = player.transform.position + baseEyeLevelOffset;
			position.x += manualAdjustmentX;
			position.y += manualAdjustmentY;
			position.z = val.position.z + ThirdAxisSliderValue;
			cameraTransform.position = position;
		}
	}

	private void ResetAndFindPlayer()
	{
		player = null;
		physicsZTarget = null;
		mainCam = null;
		cameraTransform = null;
		((MonoBehaviour)this).StartCoroutine(InitializeFirstPersonPerspective());
	}

	private void FindPlayerAndComponents()
	{
		player = GameObject.Find("Player") ?? GameObject.Find("Bennett");
		if ((Object)(object)player == (Object)null)
		{
			return;
		}
		object obj = player.transform.Find("Handle");
		if (obj == null)
		{
			obj = player.transform.Find("Hinge");
			if (obj == null)
			{
				Rigidbody componentInChildren = player.GetComponentInChildren<Rigidbody>();
				obj = ((componentInChildren != null) ? ((Component)componentInChildren).transform : null);
			}
		}
		Transform val = (Transform)obj;
		GameObject obj2 = GameObject.Find("Hammer");
		object obj3 = ((obj2 != null) ? obj2.transform : null);
		if (obj3 == null)
		{
			GameObject obj4 = GameObject.Find("Tip");
			obj3 = ((obj4 != null) ? obj4.transform : null);
		}
		Transform val2 = (Transform)obj3;
		physicsZTarget = val ?? val2 ?? player.transform;
		if ((Object)(object)cameraTransform == (Object)null)
		{
			((MonoBehaviour)this).StartCoroutine(InitializeFirstPersonPerspective());
		}
	}

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

	private void DisablePlayerMeshRenderers(Transform parent)
	{
		Transform[] componentsInChildren = ((Component)parent).GetComponentsInChildren<Transform>(true);
		foreach (Transform val in componentsInChildren)
		{
			string text = ((Object)val).name.ToLower();
			if (text.Contains("dude") || text.Contains("eye") || text.Contains("pot") || text.Contains("potcollider") || text.Contains("body") || text.Contains("player"))
			{
				MeshRenderer component = ((Component)val).GetComponent<MeshRenderer>();
				if ((Object)(object)component != (Object)null)
				{
					((Renderer)component).enabled = false;
				}
				SkinnedMeshRenderer component2 = ((Component)val).GetComponent<SkinnedMeshRenderer>();
				if ((Object)(object)component2 != (Object)null)
				{
					((Renderer)component2).enabled = false;
				}
			}
		}
	}

	private void PurgeCloudSystems()
	{
		GameObject[] array = Object.FindObjectsOfType<GameObject>();
		foreach (GameObject val in array)
		{
			string text = ((Object)val).name.ToLower();
			if (text.Contains("cloud system") || text.Contains("clouds"))
			{
				val.SetActive(false);
			}
		}
	}
}