Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of HandyFlashlight v0.1.2
BepInEx/plugins/HJM-HandyFlashlight/HJM.utilitylight.dll
Decompiled 2 hours agousing System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using BepInEx; using GameNetcodeStuff; 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.1")] public sealed class Plugin : BaseUnityPlugin { private void Update() { Keyboard current = Keyboard.current; if (current != null && ((ButtonControl)current.fKey).wasPressedThisFrame) { GameNetworkManager instance = GameNetworkManager.Instance; Toggle(((Object)(object)instance == (Object)null) ? null : instance.localPlayerController); } } internal static bool CanUse(PlayerControllerB p) { if ((Object)(object)p != (Object)null && ((NetworkBehaviour)p).IsOwner && p.isPlayerControlled && !p.isPlayerDead && !p.isTypingChat && !p.inSpecialMenu && !p.inTerminalMenu && !p.inSpecialInteractAnimation) { if (!((Object)(object)p.quickMenuManager == (Object)null)) { return !p.quickMenuManager.isMenuOpen; } return true; } return false; } private static bool Usable(FlashlightItem f, PlayerControllerB p) { if ((Object)(object)f == (Object)null || !((NetworkBehaviour)f).IsOwner || (Object)(object)((GrabbableObject)f).playerHeldBy != (Object)(object)p || (Object)(object)((GrabbableObject)f).itemProperties == (Object)null || ((GrabbableObject)f).insertedBattery == null) { return false; } if (((Object)((GrabbableObject)f).itemProperties).name == "HJM_InfinitySource") { return false; } if (!((GrabbableObject)f).isBeingUsed && ((GrabbableObject)f).itemProperties.requiresBattery) { return !((GrabbableObject)f).insertedBattery.empty; } return true; } internal static FlashlightItem Find(PlayerControllerB p) { if ((Object)(object)p == (Object)null) { return null; } GrabbableObject currentlyHeldObjectServer = p.currentlyHeldObjectServer; FlashlightItem val = (FlashlightItem)(object)((currentlyHeldObjectServer is FlashlightItem) ? currentlyHeldObjectServer : null); if (Usable(val, p)) { return val; } GrabbableObject itemOnlySlot = p.ItemOnlySlot; FlashlightItem val2 = (FlashlightItem)(object)((itemOnlySlot is FlashlightItem) ? itemOnlySlot : null); if (Usable(val2, p)) { return val2; } FlashlightItem val3 = null; if (p.ItemSlots != null) { GrabbableObject[] itemSlots = p.ItemSlots; foreach (GrabbableObject obj in itemSlots) { FlashlightItem val4 = (FlashlightItem)(object)((obj is FlashlightItem) ? obj : null); if (Usable(val4, p)) { if (((GrabbableObject)val4).isBeingUsed) { return val4; } if ((Object)(object)val3 == (Object)null) { val3 = val4; } } } } return val3; } internal static void Toggle(PlayerControllerB p) { if (!CanUse(p)) { return; } FlashlightItem val = Find(p); if ((Object)(object)val == (Object)null) { return; } bool num = (Object)(object)p.currentlyHeldObjectServer != (Object)(object)val; if (num) { p.pocketedFlashlight = (GrabbableObject)(object)val; val.usingPlayerHelmetLight = true; } ((GrabbableObject)val).UseItemOnClient(true); if (num) { p.ChangeHelmetLight(val.flashlightTypeID, ((GrabbableObject)val).isBeingUsed); if ((Object)(object)val.flashlightBulb != (Object)null) { ((Behaviour)val.flashlightBulb).enabled = false; } if ((Object)(object)val.flashlightBulbGlow != (Object)null) { ((Behaviour)val.flashlightBulbGlow).enabled = false; } } } } }