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 Simple Recharge v1.0.0
SimpleRecharge.dll
Decompiled 17 hours agousing System; using System.Collections.Generic; 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 BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using SimpleRecharge.src; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: IgnoresAccessChecksTo("")] [assembly: AssemblyCompany("SergeIgn")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+9e98c064b707d487337243552a0a994c3dcca70b")] [assembly: AssemblyProduct("SimpleRecharge")] [assembly: AssemblyTitle("SimpleRecharge")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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] [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] [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 SimpleRecharge { [BepInPlugin("SergeIgn.SimpleRecharge", "SimpleRecharge", "1.0.0")] public class SimpleRechargePlugin : BaseUnityPlugin { public const string PluginGuid = "SergeIgn.SimpleRecharge"; public const string PluginName = "SimpleRecharge"; public const string PluginVersion = "1.0.0"; internal ItemManager ItemManager; internal RechargeManager RechargeManager; private ConfigEntry<int> _configPeriodicChargeAmount; private ConfigEntry<int> _configExtractionChargeAmount; private ConfigEntry<float> _configIntervalSeconds; private ConfigEntry<string> _configChargeableItemNames; private ConfigEntry<bool> _configIsWhitelist; internal static SimpleRechargePlugin Instance { get; private set; } internal static ManualLogSource Logger => Instance._logger; private ManualLogSource _logger => ((BaseUnityPlugin)this).Logger; internal Harmony? Harmony { get; set; } private void Awake() { Instance = this; ((Component)this).gameObject.transform.parent = null; ((Object)((Component)this).gameObject).hideFlags = (HideFlags)61; SetupConfig(); ItemManager = new ItemManager(_configIsWhitelist.Value, _configChargeableItemNames.Value); RechargeManager = new RechargeManager(((Component)this).gameObject, ItemManager, _configIntervalSeconds.Value, _configPeriodicChargeAmount.Value, _configExtractionChargeAmount.Value); Patch(); Logger.LogInfo((object)"SimpleRecharge v1.0.0 has loaded!"); } internal void Patch() { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Expected O, but got Unknown //IL_001a: Expected O, but got Unknown if (Harmony == null) { Harmony val = new Harmony("SergeIgn.SimpleRecharge"); Harmony val2 = val; Harmony = val; } Harmony.PatchAll(); } internal void Unpatch() { Harmony? harmony = Harmony; if (harmony != null) { harmony.UnpatchSelf(); } } private void Update() { RechargeManager.Update(); HandleDebugInput(); } private void HandleDebugInput() { //IL_0044: Unknown result type (might be due to invalid IL or missing references) if (Input.GetKeyDown((KeyCode)282)) { Logger.LogInfo((object)"F1 key pressed, listing all items with charge in the scene."); ItemBattery[] array = Object.FindObjectsOfType<ItemBattery>(); ItemBattery[] array2 = array; foreach (ItemBattery val in array2) { Logger.LogInfo((object)$"Found GameObject: {((Object)val).name} at position {((Component)val).transform.position}"); Logger.LogInfo((object)$" ----> {val} has battery life: {val.batteryLife}"); } Logger.LogInfo((object)("Time since level load: " + Time.timeSinceLevelLoad)); } if (!Input.GetKeyDown((KeyCode)283)) { return; } Logger.LogInfo((object)"F2 key pressed, providing list of valid chargeable items."); foreach (ItemBattery item in ItemManager.Items) { Logger.LogInfo((object)("Chargeable item: " + ((Object)item).name)); } } private void SetupConfig() { //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Expected O, but got Unknown _configExtractionChargeAmount = ((BaseUnityPlugin)this).Config.Bind<int>("Recharge", "Extraction Recharge Amount", 750, "Amount of battery charge restored after extraction."); _configPeriodicChargeAmount = ((BaseUnityPlugin)this).Config.Bind<int>("Recharge", "Periodic Recharge Amount", 150, "Amount of battery charge restored periodically."); _configIntervalSeconds = ((BaseUnityPlugin)this).Config.Bind<float>("Recharge", "Periodic recharge interval", 30f, new ConfigDescription("Interval between small recharges in seconds.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 3600f), Array.Empty<object>())); _configChargeableItemNames = ((BaseUnityPlugin)this).Config.Bind<string>("Items", "Items", "Drone Torque, Rubber Duck, Phase Bridge, Orb Zero Gravity, Melee Inflatable Hammer, Melee Frying Pan, Gun Shockwave", "Comma-separated list of item names."); _configIsWhitelist = ((BaseUnityPlugin)this).Config.Bind<bool>("Items", "Whitelist", true, "True means, that only items in the Items list will be recharged. False = no recharge for listed items"); } } } namespace SimpleRecharge.src { public class ItemManager { private readonly List<ItemBattery> _items = new List<ItemBattery>(); private readonly HashSet<string> _itemNames = new HashSet<string>(); private readonly bool isWhiteList; public IReadOnlyList<ItemBattery> Items => _items; public ItemManager(bool whiteListSettings, string itemNamesCommaSeparated) { isWhiteList = whiteListSettings; SetItemNames(itemNamesCommaSeparated); } public void FindItems() { _items.Clear(); ItemBattery[] array = Object.FindObjectsOfType<ItemBattery>(); foreach (ItemBattery item in array) { if (ShouldInclude(item)) { _items.Add(item); } } } public void Clear() { _items.Clear(); } private bool ShouldInclude(ItemBattery item) { bool flag = _itemNames.Contains(((Object)item).name); return isWhiteList == flag; } private void SetItemNames(string itemNamesCommaSeparated) { _itemNames.Clear(); string[] array = itemNamesCommaSeparated.Split(','); foreach (string text in array) { _itemNames.Add("Item " + text.Trim() + "(Clone)"); } } } public class RechargeManager { private readonly ItemManager _itemManager; private readonly GameObject _pluginInstance; private float _timer; private readonly float _interval; private readonly int _periodicChargeAmount; private readonly int _extractionChargeAmount; public RechargeManager(GameObject mainPluginGameObject, ItemManager itemManager, float interval, int periodicChargeAmount, int extractionChargeAmount) { _pluginInstance = mainPluginGameObject; _itemManager = itemManager; _interval = interval; _periodicChargeAmount = periodicChargeAmount; _extractionChargeAmount = extractionChargeAmount; } public void Update() { _timer += Time.deltaTime; if (!(_timer < _interval)) { _timer -= _interval; RechargeItems(_periodicChargeAmount); } } public void RechargeItems(int amount) { foreach (ItemBattery item in _itemManager.Items) { item.ChargeBattery(_pluginInstance.gameObject, (float)amount); } } public void RechargeItems() { RechargeItems(_extractionChargeAmount); } } } namespace SimpleRecharge.Patches { [HarmonyPatch(typeof(ExtractionPoint), "ActivateTheFirstExtractionPointAutomaticallyWhenAPlayerLeaveTruck")] public static class Patch_extraction_FindItems { private static void Postfix(ExtractionPoint __instance) { SimpleRechargePlugin.Instance.ItemManager.FindItems(); int count = SimpleRechargePlugin.Instance.ItemManager.Items.Count; if (count == 0) { SimpleRechargePlugin.Logger.LogInfo((object)"No chargeable items found in the scene."); } else { SimpleRechargePlugin.Logger.LogInfo((object)$"{count} valid chargeable items found in the scene."); } } } [HarmonyPatch(typeof(ExtractionPoint), "DestroyAllPhysObjectsInHaulList")] public static class Patch_extraction_ChargeItems { private static void Postfix(ExtractionPoint __instance) { SimpleRechargePlugin.Instance.RechargeManager.RechargeItems(); } } [HarmonyPatch(typeof(RunManager), "ChangeLevel")] public static class RunManagerPatch { private static void Prefix() { SimpleRechargePlugin.Instance.ItemManager.Clear(); SimpleRechargePlugin.Logger.LogInfo((object)"Chargeable items list cleared on level change."); } } }