Decompiled source of WideEye v1.2.0

mods/WideEye.dll

Decompiled 2 weeks ago
using System;
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 BoneLib;
using BoneLib.BoneMenu;
using BoneLib.Notifications;
using Il2CppSLZ.Bonelab;
using MelonLoader;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.Rendering;
using WideEye;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: MelonInfo(typeof(Mod), "WideEye", "1.2.0", "HL2H0", null)]
[assembly: MelonGame("Stress Level Zero", "BONELAB")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("WideEye")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+514093f7789a0af8e0c4b9b653217c17e27f9973")]
[assembly: AssemblyProduct("WideEye")]
[assembly: AssemblyTitle("WideEye")]
[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 WideEye
{
	public static class BuildInfo
	{
		public const string Name = "WideEye";

		public const string Version = "1.2.0";

		public const string Author = "HL2H0";
	}
	public class Mod : MelonMod
	{
		private static GameObject SC_GameObject;

		private static GameObject ST_GameObject;

		private static Camera SC_CameraComponent;

		private static SmoothFollower SC_SmootherComponent;

		private static Transform ST_Transform;

		private static Volume SC_VolumeComponent;

		private static int defaultFOV = 70;

		private static bool gotcamera = false;

		public static Page mainPage { get; private set; }

		public static Page ExperimentalPage { get; private set; }

		public static Page SupportPage { get; private set; }

		public static FunctionElement getCameraButton { get; private set; }

		public static IntElement fovSlider { get; private set; }

		public static FunctionElement setFovButton { get; private set; }

		public static FunctionElement resetAllButton { get; private set; }

		public static BoolElement PostSFXToogle { get; private set; }

		public static IntElement PositionSmoothing { get; private set; }

		public static IntElement RotationSmoothing { get; private set; }

		public static FunctionElement ApplySmoothingButton { get; private set; }

		public static FloatElement X_R_Offset { get; private set; }

		public static FloatElement Y_R_Offset { get; private set; }

		public static FloatElement Z_R_Offset { get; private set; }

		public static FunctionElement Apply_R_OffsetButton { get; private set; }

		public override void OnInitializeMelon()
		{
			((MelonBase)this).LoggerInstance.Msg("WideEye 1.2.0 Has Been Initialized.");
			Menu.OnPageOpened += OnPageOpened;
			Hooking.OnUIRigCreated += Hooking_OnUIRigCreated;
			SetupBoneMenu();
		}

		private void Hooking_OnUIRigCreated()
		{
			ST_Transform = ST_GameObject.GetComponent<Transform>();
			if ((Object)(object)ST_Transform != (Object)null)
			{
				MelonLogger.Msg("worked yay");
			}
		}

		public override void OnSceneWasUnloaded(int buildIndex, string sceneName)
		{
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			((MelonMod)this).OnSceneWasUnloaded(buildIndex, sceneName);
			mainPage.Remove((Element[])(object)new Element[4]
			{
				(Element)fovSlider,
				(Element)setFovButton,
				(Element)resetAllButton,
				(Element)PostSFXToogle
			});
			ExperimentalPage.RemoveAll();
			((Element)getCameraButton).ElementColor = Color.red;
			gotcamera = false;
		}

		public static void GetTargetCamera()
		{
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Expected O, but got Unknown
			SC_GameObject = GameObject.Find("GameplaySystems [0]/DisabledContainer/Spectator Camera/Spectator Camera");
			ST_GameObject = GameObject.Find("RigManager(bonelab) [0]/VRControllerRig/TrackingSpace/Headset/Spectator Target");
			List<object> list = new List<object>(2) { SC_GameObject, ST_GameObject };
			bool flag = false;
			foreach (object item in list)
			{
				if (item == null)
				{
					flag = true;
					break;
				}
			}
			if (flag)
			{
				MelonLogger.Error("Spectator Camera Components Not Found");
				Menu.DisplayDialog("Error", "Wow, that's rare! It looks like the camera couldn't be found.\n Try again.If the error keeps happening, go to the support page.", Dialog.ErrorIcon, (Action)null, (Action)null);
				return;
			}
			ST_Transform = ST_GameObject.GetComponent<Transform>();
			SC_SmootherComponent = SC_GameObject.GetComponent<SmoothFollower>();
			SC_VolumeComponent = SC_GameObject.GetComponent<Volume>();
			SC_CameraComponent = SC_GameObject.GetComponent<Camera>();
			if (!gotcamera)
			{
				RefreshBoneMenu();
				gotcamera = true;
				Notification val = new Notification
				{
					Title = NotificationText.op_Implicit("Success"),
					Message = NotificationText.op_Implicit("Camera Found !"),
					Type = (NotificationType)3,
					PopupLength = 3f
				};
				Notifier.Send(val);
			}
		}

		public static void SetCameraFOV()
		{
			if ((Object)(object)SC_GameObject != (Object)null)
			{
				SC_CameraComponent.fieldOfView = fovSlider.Value;
			}
		}

		public static void ResetAll()
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			fovSlider.Value = 70;
			SC_CameraComponent.fieldOfView = defaultFOV;
			ST_Transform.localRotation = Quaternion.Euler(0f, 10f, 0f);
			X_R_Offset.Value = 11f;
			Y_R_Offset.Value = 0f;
			Z_R_Offset.Value = 0f;
			SC_SmootherComponent.TranslationSmoothTime = 0f;
			SC_SmootherComponent.RotationalSmoothTime = 0.07f;
			PositionSmoothing.Value = 0;
			RotationSmoothing.Value = 0;
			((Behaviour)SC_VolumeComponent).enabled = true;
			PostSFXToogle.Value = true;
		}

		public static void Apply_R_Offset()
		{
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)ST_Transform != (Object)null)
			{
				Vector3 val = default(Vector3);
				((Vector3)(ref val))..ctor(X_R_Offset.Value, Y_R_Offset.Value, Z_R_Offset.Value);
				ST_Transform.localRotation = Quaternion.Euler(val);
			}
		}

		public static void ApplySmoothing()
		{
			SC_SmootherComponent.RotationalSmoothTime = RotationSmoothing.Value;
			SC_SmootherComponent.TranslationSmoothTime = PositionSmoothing.Value;
		}

		private static void OnPageOpened(Page page)
		{
			if ((page == ExperimentalPage) & !gotcamera)
			{
				Menu.DisplayDialog("Error", "Camera Is Not Found, Please click on the 'Find Camera Button'", Dialog.ErrorIcon, (Action)null, (Action)null);
			}
		}

		public static void RefreshBoneMenu()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: 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_007c: 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_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
			((Element)getCameraButton).ElementColor = Color.green;
			fovSlider = mainPage.CreateInt("FOV", Color.white, defaultFOV, 10, int.MinValue, int.MaxValue, (Action<int>)null);
			setFovButton = mainPage.CreateFunction("Set FOV", Color.green, (Action)SetCameraFOV);
			resetAllButton = mainPage.CreateFunction("Reset All", Color.red, (Action)ResetAll);
			PostSFXToogle = mainPage.CreateBool("Post-Processing", Color.yellow, true, (Action<bool>)delegate(bool isEnabled)
			{
				if (isEnabled)
				{
					((Behaviour)SC_VolumeComponent).enabled = true;
				}
				else
				{
					((Behaviour)SC_VolumeComponent).enabled = false;
				}
			});
			X_R_Offset = ExperimentalPage.CreateFloat("X Rotation Offset", Color.red, 11f, 0.1f, float.MinValue, float.MaxValue, (Action<float>)null);
			Y_R_Offset = ExperimentalPage.CreateFloat("Y Rotation Offset", Color.green, 0f, 0.1f, float.MinValue, float.MaxValue, (Action<float>)null);
			Z_R_Offset = ExperimentalPage.CreateFloat("Z Rotation Offset", Color.blue, 0f, 0.1f, float.MinValue, float.MaxValue, (Action<float>)null);
			Apply_R_OffsetButton = ExperimentalPage.CreateFunction("Apply Rotation Offset", Color.white, (Action)Apply_R_Offset);
			PositionSmoothing = ExperimentalPage.CreateInt("Position Smoothing", Color.white, 0, 1, int.MinValue, int.MaxValue, (Action<int>)null);
			RotationSmoothing = ExperimentalPage.CreateInt("Rotation Smoothing", Color.white, 0, 1, int.MinValue, int.MaxValue, (Action<int>)null);
			ApplySmoothingButton = ExperimentalPage.CreateFunction("Apply Values", Color.white, (Action)ApplySmoothing);
			((Element)ApplySmoothingButton).SetTooltip("Using position smoothing may cause the spectator camera to clip through the head mesh.");
		}

		public static void SetupBoneMenu()
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Expected O, but got Unknown
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Expected O, but got Unknown
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			mainPage = Page.Root.CreatePage("Wide Eye", Color.white, 0, true);
			SupportPage = mainPage.CreatePage("Support", Color.white, 0, true);
			FunctionElement val = new FunctionElement("Open GitHub Issues", Color.white, (Action)delegate
			{
				//IL_000c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0011: Unknown result type (might be due to invalid IL or missing references)
				//IL_0017: Unknown result type (might be due to invalid IL or missing references)
				//IL_001c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0021: Unknown result type (might be due to invalid IL or missing references)
				//IL_0027: Unknown result type (might be due to invalid IL or missing references)
				//IL_002c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0031: 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_0044: Expected O, but got Unknown
				Application.OpenURL("https://github.com/HL2H0/WideEye/issues");
				Notification val3 = new Notification
				{
					Title = NotificationText.op_Implicit("Success"),
					Message = NotificationText.op_Implicit("Opened Github Issues On Desktop"),
					Type = (NotificationType)3,
					PopupLength = 3f
				};
				Notifier.Send(val3);
			});
			SupportPage.Add((Element)(object)val);
			((Element)val).SetTooltip("Open the GitHub issues page for WideEye");
			SupportPage.Add((Element)new FunctionElement("Discord", Color.blue, (Action)delegate
			{
				//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_000c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0011: Unknown result type (might be due to invalid IL or missing references)
				//IL_0016: Unknown result type (might be due to invalid IL or missing references)
				//IL_001c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0021: Unknown result type (might be due to invalid IL or missing references)
				//IL_0026: Unknown result type (might be due to invalid IL or missing references)
				//IL_0028: 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_0039: Expected O, but got Unknown
				Notification val2 = new Notification
				{
					Title = NotificationText.op_Implicit("Success"),
					Message = NotificationText.op_Implicit("Copied Username to clipboard"),
					Type = (NotificationType)3,
					PopupLength = 3f
				};
				Notifier.Send(val2);
				GUIUtility.systemCopyBuffer = "@hiiiiiiiiiiiiiiiiii";
			}));
			ExperimentalPage = mainPage.CreatePage("Experimental", Color.yellow, 0, true);
			getCameraButton = mainPage.CreateFunction("Find Camera", Color.red, (Action)GetTargetCamera);
		}
	}
}