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 InfiniteItemBatteryMod v1.0.0
InfiniteItemBatteryMod.dll
Decompiled a day agousing System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; 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(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyCompany("InfiniteItemBatteryMod")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("InfiniteItemBatteryMod")] [assembly: AssemblyTitle("InfiniteItemBatteryMod")] [assembly: AssemblyVersion("1.0.0.0")] [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 InfiniteItemBatteryMod { public class ModConfig { public ConfigEntry<bool> Enabled; public ConfigEntry<string> ToggleKey; public ModConfig(ConfigFile cfg) { Enabled = cfg.Bind<bool>("General", "Enabled", true, "เป\u0e34ด/ป\u0e34ด infinite battery (true = แบตไม\u0e48จำก\u0e31ด)"); ToggleKey = cfg.Bind<string>("General", "ToggleKey", "F6", "ค\u0e35ย\u0e4cล\u0e31ดสำหร\u0e31บ toggle mod on/off\nใส\u0e48ช\u0e37\u0e48อป\u0e38\u0e48มได\u0e49เลย เช\u0e48น F5, F6, F7, Insert, Home, Keypad0"); } public KeyCode GetToggleKeyCode() { //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) if (Enum.TryParse<KeyCode>(ToggleKey.Value, ignoreCase: true, out KeyCode result)) { return result; } Plugin.Log.LogWarning((object)("[InfiniteItemBatteryMod] Invalid ToggleKey '" + ToggleKey.Value + "', falling back to F6.")); return (KeyCode)287; } } [BepInPlugin("com.yourname.infiniteitembatterymod", "InfiniteItemBatteryMod", "1.0.0")] public class Plugin : BaseUnityPlugin { internal static ManualLogSource Log; internal static ModConfig Cfg; private readonly Harmony _harmony = new Harmony("com.yourname.infiniteitembatterymod"); private GUIStyle _styleOn = null; private GUIStyle _styleOff = null; private bool _stylesInit = false; private float _hudTimer = 0f; private const float HudDuration = 2.5f; private void Awake() { Log = ((BaseUnityPlugin)this).Logger; Cfg = new ModConfig(((BaseUnityPlugin)this).Config); _harmony.PatchAll(); Log.LogInfo((object)"InfiniteItemBatteryMod loaded!"); Log.LogInfo((object)$"Enabled={Cfg.Enabled.Value} | ToggleKey={Cfg.ToggleKey.Value}"); } private void Update() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) if (Input.GetKeyDown(Cfg.GetToggleKeyCode())) { Cfg.Enabled.Value = !Cfg.Enabled.Value; _hudTimer = 2.5f; string text = (Cfg.Enabled.Value ? "ON" : "OFF"); Log.LogInfo((object)("[InfiniteItemBatteryMod] Toggled " + text + " via hotkey.")); } if (_hudTimer > 0f) { _hudTimer -= Time.deltaTime; } } private void InitStyles() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected O, but got Unknown //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Expected O, but got Unknown //IL_00a1: Unknown result type (might be due to invalid IL or missing references) if (!_stylesInit) { _styleOn = new GUIStyle { fontSize = 22, fontStyle = (FontStyle)1, alignment = (TextAnchor)4 }; _styleOn.normal.textColor = new Color(0.2f, 1f, 0.2f, 1f); _styleOff = new GUIStyle { fontSize = 22, fontStyle = (FontStyle)1, alignment = (TextAnchor)4 }; _styleOff.normal.textColor = new Color(1f, 0.3f, 0.3f, 1f); _stylesInit = true; } } private void OnGUI() { //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Expected O, but got Unknown //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) if (!(_hudTimer <= 0f)) { InitStyles(); float num = Mathf.Clamp01(_hudTimer / 0.8f); string text; GUIStyle val; if (Cfg.Enabled.Value) { text = "♾ Infinite Battery: ON"; val = _styleOn; } else { text = "⬜ Infinite Battery: OFF"; val = _styleOff; } Color textColor = val.normal.textColor; textColor.a = num; val.normal.textColor = textColor; GUIStyle val2 = new GUIStyle(val); val2.normal.textColor = new Color(0f, 0f, 0f, num * 0.6f); GUI.Label(new Rect((float)Screen.width / 2f - 149f, (float)Screen.height * 0.12f + 1f, 300f, 40f), text, val2); GUI.Label(new Rect((float)Screen.width / 2f - 150f, (float)Screen.height * 0.12f, 300f, 40f), text, val); } } } } namespace InfiniteItemBatteryMod.Patches { [HarmonyPatch(typeof(ItemBattery), "RemoveFullBar")] public static class RemoveFullBarPatch { public static bool Prefix(ItemBattery __instance, int _bars) { if (!Plugin.Cfg.Enabled.Value) { return true; } Plugin.Log.LogInfo((object)$"[InfiniteItemBatteryMod] RemoveFullBar blocked ({_bars} bars)."); return false; } } [HarmonyPatch(typeof(ItemBattery), "Update")] public static class UpdatePatch { public static void Postfix(ItemBattery __instance) { if (Plugin.Cfg.Enabled.Value && SemiFunc.IsMasterClientOrSingleplayer()) { int num = __instance.batteryBars; if (num <= 0) { num = 6; } float num2 = 100f / (float)num; if (__instance.batteryLife < num2) { __instance.batteryLife = 100f; } } } } [HarmonyPatch(typeof(ItemBattery), "Drain")] public static class DrainPatch { public static bool Prefix() { if (!Plugin.Cfg.Enabled.Value) { return true; } return false; } } }