Decompiled source of HideFlashlightHand v1.0.0

HideFlashlightHand.dll

Decompiled 2 days ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
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: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("")]
[assembly: AssemblyCompany("zabu")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("zabumod")]
[assembly: AssemblyTitle("zabumod")]
[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.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;
		}
	}
	[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 REPOJP.HideFlashlightHand
{
	[BepInPlugin("REPOJP.HideFlashlightHand", "HideFlashlightHand", "1.0.0")]
	public sealed class HideFlashlightHandPlugin : BaseUnityPlugin
	{
		public const string PluginGuid = "REPOJP.HideFlashlightHand";

		public const string PluginName = "HideFlashlightHand";

		public const string PluginVersion = "1.0.0";

		internal static ConfigEntry<bool> CfgEnableMod;

		internal static ConfigEntry<bool> CfgHideHalo;

		internal static ConfigEntry<bool> CfgUseRendererScan;

		private void Awake()
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Expected O, but got Unknown
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Expected O, but got Unknown
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Expected O, but got Unknown
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Expected O, but got Unknown
			CfgEnableMod = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "EnableMod", true, new ConfigDescription("Enable this mod.このMODを有効化", (AcceptableValueBase)null, Array.Empty<object>()));
			CfgHideHalo = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "HideHalo", true, new ConfigDescription("Hide halo/flare visuals too.ハロー等の発光演出も非表示", (AcceptableValueBase)null, Array.Empty<object>()));
			CfgUseRendererScan = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "UseRendererScan", false, new ConfigDescription("Disable all Renderers under the flashlight object to hide any model parts. Useful if the mesh reference changes in future updates.懐中電灯オブジェクト配下のRendererを全停止してモデル系をまとめて非表示 メッシュ参照が将来変更された場合の保険として有用", (AcceptableValueBase)null, Array.Empty<object>()));
			Harmony val = new Harmony("REPOJP.HideFlashlightHand");
			val.PatchAll();
		}
	}
	internal static class FlashlightHideCore
	{
		private sealed class RendererCache
		{
			public Renderer[] Renderers;
		}

		private static readonly ConditionalWeakTable<FlashlightController, RendererCache> RendererCaches = new ConditionalWeakTable<FlashlightController, RendererCache>();

		internal static void ApplyHide(FlashlightController inst)
		{
			if ((Object)(object)inst == (Object)null || !HideFlashlightHandPlugin.CfgEnableMod.Value || (Object)(object)inst.PlayerAvatar == (Object)null || !inst.PlayerAvatar.isLocal)
			{
				return;
			}
			if (HideFlashlightHandPlugin.CfgUseRendererScan.Value)
			{
				RendererCache orCreateValue = RendererCaches.GetOrCreateValue(inst);
				if (orCreateValue.Renderers == null)
				{
					try
					{
						orCreateValue.Renderers = ((Component)inst).GetComponentsInChildren<Renderer>(true);
					}
					catch
					{
						orCreateValue.Renderers = Array.Empty<Renderer>();
					}
				}
				Renderer[] renderers = orCreateValue.Renderers;
				foreach (Renderer val in renderers)
				{
					if (!((Object)(object)val == (Object)null) && val.enabled)
					{
						val.enabled = false;
					}
				}
			}
			else if ((Object)(object)inst.mesh != (Object)null && ((Renderer)inst.mesh).enabled)
			{
				((Renderer)inst.mesh).enabled = false;
			}
			if (HideFlashlightHandPlugin.CfgHideHalo.Value && (Object)(object)inst.halo != (Object)null && inst.halo.enabled)
			{
				inst.halo.enabled = false;
			}
		}
	}
	[HarmonyPatch(typeof(FlashlightController))]
	internal static class FlashlightControllerPatches
	{
		[HarmonyPostfix]
		[HarmonyPatch("Start")]
		private static void Start_Postfix(FlashlightController __instance)
		{
			FlashlightHideCore.ApplyHide(__instance);
		}

		[HarmonyPostfix]
		[HarmonyPatch("Update")]
		private static void Update_Postfix(FlashlightController __instance)
		{
			FlashlightHideCore.ApplyHide(__instance);
		}
	}
}