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 SolarBatteriesFixed v1.0.0
plugins/SolarBatteriesFixed.dll
Decompiled 18 hours agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("SolarBatteriesFixed")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("SolarBatteriesFixed")] [assembly: AssemblyCopyright("Copyright © 2026")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("ee236160-9117-4c81-ac86-1605e33e0437")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyVersion("1.0.0.0")] namespace SolarBatteriesFixed; [BepInPlugin("cn_xc.SolarBatteriesFixed", "Solar Batteries Fixed", "1.0.0")] [BepInProcess("REPO.exe")] public class SolarBatteriesFixedPlugin : BaseUnityPlugin { internal static ManualLogSource Log; public static ConfigEntry<bool> EnableMod; public static ConfigEntry<int> ChargeRate; public static ConfigEntry<float> MaxRange; private readonly Harmony harmony = new Harmony("cn_xc.SolarBatteriesFixed"); private void Awake() { //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Expected O, but got Unknown //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Expected O, but got Unknown //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; EnableMod = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "EnableMod", true, "是否启用手电筒太阳能充电功能"); ChargeRate = ((BaseUnityPlugin)this).Config.Bind<int>("General", "ChargeRate", 5, new ConfigDescription("电池每秒充电百分比(整数,1-10)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 10), Array.Empty<object>())); MaxRange = ((BaseUnityPlugin)this).Config.Bind<float>("General", "MaxRange", 3f, new ConfigDescription("手电筒照射电池的最大有效距离", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 10f), Array.Empty<object>())); try { MethodInfo methodInfo = AccessTools.Method(typeof(ItemBattery), "Update", (Type[])null, (Type[])null); if (methodInfo != null) { harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(SolarBatteriesFixedPlugin), "UpdatePrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); Log.LogInfo((object)"✅ Prefix 补丁成功: ItemBattery.Update"); } else { Log.LogError((object)"❌ 找不到 ItemBattery.Update 方法"); } } catch (Exception ex) { Log.LogError((object)("补丁失败: " + ex.Message)); } Log.LogInfo((object)"Solar Batteries Fixed v1.0.0 加载完成!"); } [HarmonyPrefix] public static bool UpdatePrefix(ItemBattery __instance) { if (!EnableMod.Value) { return true; } if (!SemiFunc.IsMasterClientOrSingleplayer()) { return true; } if (__instance.batteryLife >= 100f) { return true; } List<PlayerAvatar> list = SemiFunc.PlayerGetList(); if (list == null || list.Count == 0) { return true; } foreach (PlayerAvatar item in list) { if ((Object)(object)item == (Object)null) { continue; } FlashlightController flashlightController = item.flashlightController; if (!((Object)(object)flashlightController == (Object)null) && flashlightController.LightActive) { Light spotlight = flashlightController.spotlight; if (!((Object)(object)spotlight == (Object)null) && IsBatteryLit(__instance, spotlight, MaxRange.Value)) { __instance.ChargeBattery(((Component)item).gameObject, (float)ChargeRate.Value); break; } } } return true; } private static bool IsBatteryLit(ItemBattery battery, Light spot, float maxRange) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0015: 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_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: 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_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) Vector3 val = (((Object)(object)battery.batteryTransform != (Object)null) ? battery.batteryTransform.position : ((Component)battery).transform.position); Vector3 position = ((Component)spot).transform.position; Vector3 val2 = val - position; float magnitude = ((Vector3)(ref val2)).magnitude; if (magnitude > maxRange) { return false; } float num = Vector3.Angle(((Component)spot).transform.forward, val2); if (num > spot.spotAngle * 0.5f) { return false; } RaycastHit val3 = default(RaycastHit); if (Physics.Raycast(position, ((Vector3)(ref val2)).normalized, ref val3, magnitude, LayerMask.op_Implicit(SemiFunc.LayerMaskGetVisionObstruct())) && (Object)(object)((RaycastHit)(ref val3)).transform != (Object)(object)((Component)battery).transform && !((RaycastHit)(ref val3)).transform.IsChildOf(((Component)battery).transform)) { return false; } return true; } }