Decompiled source of Depth Perception v1.1.0

DepthPerception.dll

Decompiled a month ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BoneLib;
using BoneLib.BoneMenu;
using DepthPerception;
using MelonLoader;
using MelonLoader.Preferences;
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(DPercept), "Depth Perception", "1.1.0", "AMOAM", null)]
[assembly: MelonGame("Stress Level Zero", "BONELAB")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("DepthPerception")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("DepthPerception")]
[assembly: AssemblyTitle("DepthPerception")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
}
namespace DepthPerception
{
	public class DPercept : MelonMod
	{
		private MelonPreferences_Category dpsettings;

		private MelonPreferences_Entry<float> savedScale;

		private MelonPreferences_Entry<bool> savedActive;

		private float camscale = 1f;

		private bool active = true;

		public override void OnInitializeMelon()
		{
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: 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)
			((MelonBase)this).OnInitializeMelon();
			Hooking.OnLevelLoaded += OnSceneChanged;
			dpsettings = MelonPreferences.CreateCategory("DepthPerception");
			savedScale = dpsettings.CreateEntry<float>("dpScale", 1f, "Depth Scale", "Multiplies the distance between your VR eye cameras.", false, false, (ValueValidator)null, (string)null);
			savedActive = dpsettings.CreateEntry<bool>("dpActive", true, "Depth Scaling Enabled", "If the multiplier should be applied.", false, false, (ValueValidator)null, (string)null);
			camscale = savedScale.Value;
			active = savedActive.Value;
			Page val = Page.Root.CreatePage("Depth Perception", new Color(1f, 1f, 0f), 0, true);
			val.CreateFloat("DP Scale", Color.cyan, camscale, 0.2f, 0f, 10f, (Action<float>)DPChanged);
			val.CreateBool("Enabled", Color.green, active, (Action<bool>)EnabledChanged);
			DPChanged(camscale);
		}

		private void DPChanged(float newScale)
		{
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			camscale = newScale;
			MelonLogger.Msg("Depth Perception changed to " + camscale);
			savedScale.Value = camscale;
			MelonPreferences.Save();
			if (active && Object.op_Implicit((Object)(object)Player.ControllerRig))
			{
				((Component)Player.ControllerRig).transform.Find("TrackingSpace/Headset").localScale = new Vector3(camscale, camscale, camscale);
			}
		}

		private void EnabledChanged(bool newEnabled)
		{
			//IL_0088: 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)
			active = newEnabled;
			MelonLogger.Msg("Depth Perception " + (active ? "enabled" : "disabled"));
			savedActive.Value = active;
			MelonPreferences.Save();
			if (Object.op_Implicit((Object)(object)Player.ControllerRig))
			{
				((Component)Player.ControllerRig).transform.Find("TrackingSpace/Headset").localScale = (Vector3)(active ? new Vector3(camscale, camscale, camscale) : Vector3.one);
			}
		}

		private void OnSceneChanged(LevelInfo li)
		{
			DPChanged(camscale);
		}
	}
}