Decompiled source of ThirdPersonMod v1.6.0

ThirdPerson.dll

Decompiled a day ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BoneLib;
using BoneLib.BoneMenu;
using MelonLoader;
using NatinoMods;
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(NatinoModsMod), "Third Person Mod", "1.5.0", "Natino", null)]
[assembly: MelonGame("Stress Level Zero", "BONELAB")]
[assembly: AssemblyTitle("BoneMenuKill2")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("BoneMenuKill2")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("308c52f2-f62a-4cd1-8739-0916c1b6d1de")]
[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 NatinoMods;

public class NatinoModsMod : MelonMod
{
	public static bool IsThirdPersonEnabled;

	private static GameObject thirdPersonCamObj;

	private static Camera tpCamera;

	public override void OnInitializeMelon()
	{
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		//IL_001e: Unknown result type (might be due to invalid IL or missing references)
		Page val = Page.Root.CreatePage("Third Person", Color.cyan, 0, true);
		val.CreateBool("Desktop 3rd Person", Color.blue, false, (Action<bool>)delegate(bool flag)
		{
			IsThirdPersonEnabled = flag;
			ToggleDesktopCamera(flag);
		});
	}

	private void ToggleDesktopCamera(bool active)
	{
		//IL_003b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0045: Expected O, but got Unknown
		MelonLogger.Msg("Desktop 3rd Person: " + (active ? "ON" : "OFF"));
		if (active)
		{
			if ((Object)(object)thirdPersonCamObj == (Object)null)
			{
				thirdPersonCamObj = new GameObject("Natino_3rdPersonCam");
				tpCamera = thirdPersonCamObj.AddComponent<Camera>();
				if ((Object)(object)Camera.main != (Object)null)
				{
					tpCamera.CopyFrom(Camera.main);
				}
				tpCamera.stereoTargetEye = (StereoTargetEyeMask)0;
				tpCamera.depth = 99f;
			}
			thirdPersonCamObj.SetActive(true);
		}
		else if ((Object)(object)thirdPersonCamObj != (Object)null)
		{
			thirdPersonCamObj.SetActive(false);
		}
	}

	public override void OnLateUpdate()
	{
		//IL_0069: Unknown result type (might be due to invalid IL or missing references)
		//IL_006f: 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_008d: 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_00ac: 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)
		//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
		if (!IsThirdPersonEnabled || !((Object)(object)thirdPersonCamObj != (Object)null) || !((Object)(object)tpCamera != (Object)null))
		{
			return;
		}
		try
		{
			if ((Object)(object)Player.RigManager != (Object)null)
			{
				Transform val = (((Object)(object)Player.Head != (Object)null) ? ((Component)Player.Head).transform : ((Component)Player.RigManager.physicsRig).transform);
				Vector3 val2 = val.position - val.forward * 2.5f + Vector3.up * 1f;
				thirdPersonCamObj.transform.position = Vector3.Lerp(thirdPersonCamObj.transform.position, val2, Time.deltaTime * 10f);
				thirdPersonCamObj.transform.LookAt(val.position);
			}
		}
		catch
		{
		}
	}
}