Decompiled source of fast flash v0.1.0

BepInEx/plugins/HJM_fast_flash/HJM.utilitylight.dll

Decompiled 4 hours ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using BepInEx;
using GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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 HJM.UtilityLight
{
	[BepInPlugin("hjm.utilitylight", "原生工具槽手电快捷键", "0.1.0")]
	public sealed class Plugin : BaseUnityPlugin
	{
		private void Awake()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			new Harmony("hjm.utilitylight").PatchAll();
		}

		private void Update()
		{
			Keyboard current = Keyboard.current;
			if (current == null || !((ButtonControl)current.fKey).wasPressedThisFrame)
			{
				return;
			}
			PlayerControllerB val = (((Object)(object)GameNetworkManager.Instance == (Object)null) ? null : GameNetworkManager.Instance.localPlayerController);
			if ((Object)(object)val == (Object)null || !((NetworkBehaviour)val).IsOwner || !val.isPlayerControlled || val.isPlayerDead || val.isTypingChat || val.inSpecialMenu || val.inTerminalMenu || val.inSpecialInteractAnimation || ((Object)(object)val.quickMenuManager != (Object)null && val.quickMenuManager.isMenuOpen))
			{
				return;
			}
			GrabbableObject itemOnlySlot = val.ItemOnlySlot;
			FlashlightItem val2 = (FlashlightItem)(object)((itemOnlySlot is FlashlightItem) ? itemOnlySlot : null);
			if ((Object)(object)val2 == (Object)null || !((NetworkBehaviour)val2).IsOwner || (Object)(object)((GrabbableObject)val2).playerHeldBy != (Object)(object)val || ((GrabbableObject)val2).insertedBattery == null || (!((GrabbableObject)val2).isBeingUsed && ((GrabbableObject)val2).insertedBattery.empty))
			{
				return;
			}
			bool num = (Object)(object)val.currentlyHeldObjectServer != (Object)(object)val2;
			if (num)
			{
				val.pocketedFlashlight = (GrabbableObject)(object)val2;
				val2.usingPlayerHelmetLight = true;
			}
			((GrabbableObject)val2).UseItemOnClient(true);
			if (num)
			{
				val.ChangeHelmetLight(val2.flashlightTypeID, ((GrabbableObject)val2).isBeingUsed);
				if ((Object)(object)val2.flashlightBulb != (Object)null)
				{
					((Behaviour)val2.flashlightBulb).enabled = false;
				}
				if ((Object)(object)val2.flashlightBulbGlow != (Object)null)
				{
					((Behaviour)val2.flashlightBulbGlow).enabled = false;
				}
			}
		}
	}
}