Decompiled source of ControllerGeoHide v1.0.1

BepInEx\plugins\invent60-ControllerGeoHide\ControllerGeoHide.dll

Decompiled 8 hours ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using FistVR;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Sodalite;
using Sodalite.Api;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.6", FrameworkDisplayName = ".NET Framework 4.6")]
[assembly: AssemblyCompany("ControllerGeoHide")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("ControllerGeoHide")]
[assembly: AssemblyTitle("ControllerGeoHide")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.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]
	[Microsoft.CodeAnalysis.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 ControllerGeoHide
{
	[BepInPlugin("h3vr.invent60.controllergeo", "ControllerGeoHide", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class ControllerGeoHidePlugin : BaseUnityPlugin
	{
		internal static ConfigEntry<bool> CfgEnabled;

		private void Awake()
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Expected O, but got Unknown
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Expected O, but got Unknown
			CfgEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Hide controller geometry", true, "Hides the controller 3D model on both hands. Toggle at runtime via Wrist Menu > Custom Buttons.");
			new Harmony("h3vr.invent60.controllergeo").PatchAll(typeof(ControllerGeoHidePlugin));
			WristMenuButton btn = null;
			btn = new WristMenuButton(ButtonLabel(), (ButtonClickEvent)delegate
			{
				bool flag = !CfgEnabled.Value;
				CfgEnabled.Value = flag;
				if (btn != null)
				{
					btn.Text = ButtonLabel();
				}
				if (!flag)
				{
					FVRViveHand[] array = Object.FindObjectsOfType<FVRViveHand>();
					foreach (FVRViveHand val in array)
					{
						if ((Object)(object)val?.Display_Controller != (Object)null)
						{
							val.Display_Controller.SetActive(true);
						}
					}
				}
			});
			WristMenuAPI.CustomButtonsSection.Buttons.Add(btn);
			((BaseUnityPlugin)this).Logger.LogInfo((object)"[ControllerGeoHide] Loaded.");
		}

		private static string ButtonLabel()
		{
			return "Hide CtrlGeo: " + (CfgEnabled.Value ? "ON" : "OFF");
		}

		[HarmonyPatch(typeof(FVRViveHand), "Update")]
		[HarmonyPostfix]
		private static void PostHandUpdate(FVRViveHand __instance)
		{
			if (CfgEnabled.Value && (Object)(object)__instance.Display_Controller != (Object)null && __instance.Display_Controller.activeSelf)
			{
				__instance.Display_Controller.SetActive(false);
			}
		}
	}
}