Please disclose if your mod was created primarily 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 Battery v1.0.5
plugins/Battery.dll
Decompiled 2 years agousing 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 LethalThings.MonoBehaviours; using Microsoft.CodeAnalysis; [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: AssemblyCompany("Battery")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyDescription("Is your flashlight running out of battery quickly? Maybe it's time to use longer term batteries.")] [assembly: AssemblyFileVersion("1.0.5.0")] [assembly: AssemblyInformationalVersion("1.0.5+abe89dc3719a64f605d7ff5f91802620a79de7b5")] [assembly: AssemblyProduct("Battery")] [assembly: AssemblyTitle("Battery")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.5.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 Battery { public static class ConfigSettings { public static ConfigEntry<float> FlashlightBatteryUsage; public static ConfigEntry<float> ProFlashlightBatteryUsage; public static ConfigEntry<float> LaserPointerBatteryUsage; public static ConfigEntry<float> WalkieTalkieBatteryUsage; public static ConfigEntry<float> JetpackBatteryUsage; public static ConfigEntry<float> PatcherToolBatteryUsage; public static ConfigEntry<float> BoomboxItemBatteryUsage; public static ConfigEntry<float> HandheldRadarBatteryUsage; public static ConfigEntry<float> HackingToolBatteryUsage; public static ConfigEntry<bool> EnableFlashLight; public static ConfigEntry<bool> EnableProFlashLight; public static ConfigEntry<bool> EnableLaserPointer; public static ConfigEntry<bool> EnableWalkieTalkie; public static ConfigEntry<bool> EnableJetpack; public static ConfigEntry<bool> EnablePatcherTool; public static ConfigEntry<bool> EnableBoomboxItem; public static ConfigEntry<bool> EnableHandheldRadar; public static ConfigEntry<bool> EnableHackingTool; public static ConfigEntry<bool> requiresBatteryFlashLight; public static ConfigEntry<bool> requiresBatteryProFlashLight; public static ConfigEntry<bool> requiresBatteryLaserPointer; public static ConfigEntry<bool> requiresBatteryWalkieTalkie; public static ConfigEntry<bool> requiresBatteryJetpack; public static ConfigEntry<bool> requiresBatteryPatcherTool; public static ConfigEntry<bool> requiresBatteryBoomboxItem; public static ConfigEntry<bool> requiresBatteryHandheldRadar; public static ConfigEntry<bool> requiresBatteryHackingTool; public static void Init() { EnableFlashLight = ((BaseUnityPlugin)Plugin.Instance).Config.Bind<bool>("Battery", "EnableFlashLight", true, "Should the Values of the Game prevail or yours? If you want Your value to be valid, set it to True."); requiresBatteryFlashLight = ((BaseUnityPlugin)Plugin.Instance).Config.Bind<bool>("Battery", "requiresBatteryFlashLight", true, "Is Battery Required? (True - yes | False - no)"); FlashlightBatteryUsage = ((BaseUnityPlugin)Plugin.Instance).Config.Bind<float>("Battery", "FlashlightBatteryUsage", 150f, "The battery usage per update. The lower the value, the shorter the battery life. (Game Default: 140)"); EnableProFlashLight = ((BaseUnityPlugin)Plugin.Instance).Config.Bind<bool>("Battery", "EnableProFlashLight", true, "Should the Values of the Game prevail or yours? If you want Your value to be valid, set it to True."); requiresBatteryProFlashLight = ((BaseUnityPlugin)Plugin.Instance).Config.Bind<bool>("Battery", "requiresBatteryProFlashLight", true, "Is Battery Required? (True - yes | False - no)"); ProFlashlightBatteryUsage = ((BaseUnityPlugin)Plugin.Instance).Config.Bind<float>("Battery", "ProFlashlightBatteryUsage", 350f, "The battery usage per update. The lower the value, the shorter the battery life. (Game Default: 300)"); EnableLaserPointer = ((BaseUnityPlugin)Plugin.Instance).Config.Bind<bool>("Battery", "EnableLaserPointer", true, "Should the Values of the Game prevail or yours? If you want Your value to be valid, set it to True."); requiresBatteryLaserPointer = ((BaseUnityPlugin)Plugin.Instance).Config.Bind<bool>("Battery", "requiresBatteryLaserPointer", true, "Is Battery Required? (True - yes | False - no)"); LaserPointerBatteryUsage = ((BaseUnityPlugin)Plugin.Instance).Config.Bind<float>("Battery", "LaserPointerBatteryUsage", 350f, "The battery usage per update. The lower the value, the shorter the battery life. (Game Default: 300)"); EnableWalkieTalkie = ((BaseUnityPlugin)Plugin.Instance).Config.Bind<bool>("Battery", "EnableWalkieTalkie", true, "Should the Values of the Game prevail or yours? If you want Your value to be valid, set it to True."); requiresBatteryWalkieTalkie = ((BaseUnityPlugin)Plugin.Instance).Config.Bind<bool>("Battery", "requiresBatteryWalkieTalkie", true, "Is Battery Required? (True - yes | False - no)"); WalkieTalkieBatteryUsage = ((BaseUnityPlugin)Plugin.Instance).Config.Bind<float>("Battery", "WalkieTalkieBatteryUsage", 1000f, "The battery usage per update. The lower the value, the shorter the battery life. (Game Default: 820)"); EnableJetpack = ((BaseUnityPlugin)Plugin.Instance).Config.Bind<bool>("Battery", "EnableJetpack", true, "Should the Values of the Game prevail or yours? If you want Your value to be valid, set it to True."); requiresBatteryJetpack = ((BaseUnityPlugin)Plugin.Instance).Config.Bind<bool>("Battery", "requiresBatteryJetpack", true, "Is Battery Required? (True - yes | False - no)"); JetpackBatteryUsage = ((BaseUnityPlugin)Plugin.Instance).Config.Bind<float>("Battery", "JetpackBatteryUsage", 100f, "The battery usage per update. The lower the value, the shorter the battery life. (Game Default: 60)"); EnablePatcherTool = ((BaseUnityPlugin)Plugin.Instance).Config.Bind<bool>("Battery", "EnablePatcherTool", true, "Should the Values of the Game prevail or yours? If you want Your value to be valid, set it to True."); requiresBatteryPatcherTool = ((BaseUnityPlugin)Plugin.Instance).Config.Bind<bool>("Battery", "requiresBatteryPatcherTool", true, "Is Battery Required? (True - yes | False - no)"); PatcherToolBatteryUsage = ((BaseUnityPlugin)Plugin.Instance).Config.Bind<float>("Battery", "PatcherToolBatteryUsage", 30f, "The battery usage per update. The lower the value, the shorter the battery life. (Game Default: 22)"); EnableBoomboxItem = ((BaseUnityPlugin)Plugin.Instance).Config.Bind<bool>("Battery", "EnableBoomboxItem", true, "Should the Values of the Game prevail or yours? If you want Your value to be valid, set it to True."); requiresBatteryBoomboxItem = ((BaseUnityPlugin)Plugin.Instance).Config.Bind<bool>("Battery", "requiresBatteryBoomboxItem", true, "Is Battery Required? (True - yes | False - no)"); BoomboxItemBatteryUsage = ((BaseUnityPlugin)Plugin.Instance).Config.Bind<float>("Battery", "BoomboxItemBatteryUsage", 350f, "The battery usage per update. The lower the value, the shorter the battery life. (Game Default: 350)"); EnableHandheldRadar = ((BaseUnityPlugin)Plugin.Instance).Config.Bind<bool>("Battery", "EnableHandheldRadar", true, "Should the Values of the Game prevail or yours? If you want Your value to be valid, set it to True."); requiresBatteryHandheldRadar = ((BaseUnityPlugin)Plugin.Instance).Config.Bind<bool>("Battery", "requiresBatteryHandheldRadar", true, "Is Battery Required? (True - yes | False - no)"); HandheldRadarBatteryUsage = ((BaseUnityPlugin)Plugin.Instance).Config.Bind<float>("Battery", "HandheldRadarBatteryUsage", 1000f, "The battery usage per update. The lower the value, the shorter the battery life. (Game Default: ...)"); EnableHackingTool = ((BaseUnityPlugin)Plugin.Instance).Config.Bind<bool>("Battery", "EnableHackingTool", true, "Should the Values of the Game prevail or yours? If you want Your value to be valid, set it to True."); requiresBatteryHackingTool = ((BaseUnityPlugin)Plugin.Instance).Config.Bind<bool>("Battery", "requiresBatteryHackingTool", true, "Is Battery Required? (True - yes | False - no)"); HackingToolBatteryUsage = ((BaseUnityPlugin)Plugin.Instance).Config.Bind<float>("Battery", "HackingToolBatteryUsage", 1000f, "The battery usage per update. The lower the value, the shorter the battery life. (Game Default: ...)"); } } public enum FlashlightType { ProFlashlight, Flashlight, LaserPointer } [BepInPlugin("dev.herrwinfried.battery", "Battery", "1.0.5")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { private readonly Harmony _harmony = new Harmony("dev.herrwinfried.battery"); public static Plugin Instance; private void Awake() { Instance = this; _harmony.PatchAll(); ConfigSettings.Init(); Log("Plugin Battery-1.0.5 loaded!"); } public static void Log(string message) { ((BaseUnityPlugin)Instance).Logger.LogInfo((object)message); } } public class PluginInfo { public const string PLUGIN_GUID = "dev.herrwinfried.battery"; public const string PLUGIN_NAME = "Battery"; public const string PLUGIN_VERSION = "1.0.5"; } public static class MyPluginInfo { public const string PLUGIN_GUID = "Battery"; public const string PLUGIN_NAME = "Battery"; public const string PLUGIN_VERSION = "1.0.5"; } } namespace Battery.Patches { [HarmonyPatch(typeof(BoomboxItem))] internal class BoomboxItemPatch { [HarmonyPatch("ItemActivate")] [HarmonyPrefix] private static void ModifyBoomboxItemBatteryUsage(ref BoomboxItem __instance) { if (ConfigSettings.EnableBoomboxItem.Value) { ((GrabbableObject)__instance).itemProperties.batteryUsage = ConfigSettings.BoomboxItemBatteryUsage.Value; ((GrabbableObject)__instance).itemProperties.requiresBattery = ConfigSettings.requiresBatteryBoomboxItem.Value; } } } [HarmonyPatch(typeof(FlashlightItem))] internal class FlashlightItemPatch { [HarmonyPatch("ItemActivate")] [HarmonyPrefix] private static void ModifyFlashlightBatteryUsage(ref FlashlightItem __instance) { FlashlightType flashlightTypeID = (FlashlightType)__instance.flashlightTypeID; switch (flashlightTypeID) { case FlashlightType.ProFlashlight: if (ConfigSettings.EnableProFlashLight.Value) { ((GrabbableObject)__instance).itemProperties.batteryUsage = ConfigSettings.ProFlashlightBatteryUsage.Value; ((GrabbableObject)__instance).itemProperties.requiresBattery = ConfigSettings.requiresBatteryProFlashLight.Value; } break; case FlashlightType.Flashlight: if (ConfigSettings.EnableFlashLight.Value) { ((GrabbableObject)__instance).itemProperties.batteryUsage = ConfigSettings.FlashlightBatteryUsage.Value; ((GrabbableObject)__instance).itemProperties.requiresBattery = ConfigSettings.requiresBatteryFlashLight.Value; } break; case FlashlightType.LaserPointer: if (ConfigSettings.EnableLaserPointer.Value) { ((GrabbableObject)__instance).itemProperties.batteryUsage = ConfigSettings.LaserPointerBatteryUsage.Value; ((GrabbableObject)__instance).itemProperties.requiresBattery = ConfigSettings.requiresBatteryLaserPointer.Value; } break; default: Plugin.Log($"Unknown FlashlightType: {flashlightTypeID}"); break; } } } [HarmonyPatch(typeof(HackingTool))] public class HackingToolPatch { [HarmonyPatch("ItemActivate")] [HarmonyPrefix] private static void ModifyHandheldRadarBatteryUsage(ref HackingTool __instance) { if (ConfigSettings.EnableHackingTool.Value) { ((GrabbableObject)__instance).itemProperties.batteryUsage = ConfigSettings.HackingToolBatteryUsage.Value; ((GrabbableObject)__instance).itemProperties.requiresBattery = ConfigSettings.requiresBatteryHackingTool.Value; ((GrabbableObject)__instance).Update(); } } } [HarmonyPatch(typeof(HandheldRadar))] public class HandheldRadarPatch { [HarmonyPatch("ItemInteractLeftRight")] [HarmonyPrefix] private static void ModifyHandheldRadarBatteryUsage(ref HandheldRadar __instance) { if (ConfigSettings.EnableHandheldRadar.Value) { ((GrabbableObject)__instance).itemProperties.batteryUsage = ConfigSettings.HandheldRadarBatteryUsage.Value; ((GrabbableObject)__instance).itemProperties.requiresBattery = ConfigSettings.requiresBatteryHandheldRadar.Value; ((GrabbableObject)__instance).Update(); } } } [HarmonyPatch(typeof(JetpackItem))] internal class JetpackItemPatch { [HarmonyPatch("ItemActivate")] [HarmonyPrefix] private static void ModifyJetpackBatteryUsage(ref JetpackItem __instance) { if (ConfigSettings.EnableJetpack.Value) { ((GrabbableObject)__instance).itemProperties.batteryUsage = ConfigSettings.JetpackBatteryUsage.Value; ((GrabbableObject)__instance).itemProperties.requiresBattery = ConfigSettings.requiresBatteryJetpack.Value; } } } [HarmonyPatch(typeof(PatcherTool))] internal class PatcherToolPatch { [HarmonyPatch("ItemActivate")] [HarmonyPrefix] private static void ModifyPatcherToolBatteryUsage(ref PatcherTool __instance) { if (ConfigSettings.EnablePatcherTool.Value) { ((GrabbableObject)__instance).itemProperties.batteryUsage = ConfigSettings.PatcherToolBatteryUsage.Value; ((GrabbableObject)__instance).itemProperties.requiresBattery = ConfigSettings.requiresBatteryPatcherTool.Value; } } } [HarmonyPatch(typeof(WalkieTalkie))] internal class WalkieTalkieItemPatch { [HarmonyPatch("ItemActivate")] [HarmonyPostfix] private static void ModifyWalkieTalkieBatteryUsage(ref WalkieTalkie __instance) { if (ConfigSettings.EnableWalkieTalkie.Value) { ((GrabbableObject)__instance).itemProperties.batteryUsage = ConfigSettings.WalkieTalkieBatteryUsage.Value; ((GrabbableObject)__instance).itemProperties.requiresBattery = ConfigSettings.requiresBatteryWalkieTalkie.Value; } } } }