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 UnlimitedTruckEnergy v1.0.0
UnlimitedTruckEnergy.dll
Decompiled 2 days agousing System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; 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: AssemblyCompany("codys")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("Keeps the R.E.P.O. truck charging station at or above half energy without changing weapons.")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("UnlimitedTruckEnergy")] [assembly: AssemblyTitle("UnlimitedTruckEnergy")] [assembly: AssemblyVersion("1.0.0.0")] [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 UnlimitedTruckEnergy { [BepInPlugin("codys.UnlimitedTruckEnergy", "Unlimited Truck Energy", "1.0")] public sealed class Plugin : BaseUnityPlugin { public const string PluginGuid = "codys.UnlimitedTruckEnergy"; public const string PluginName = "Unlimited Truck Energy"; public const string PluginVersion = "1.0"; private Harmony? _harmony; internal static ManualLogSource Log { get; private set; } private void Awake() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; _harmony = new Harmony("codys.UnlimitedTruckEnergy"); _harmony.PatchAll(); Log.LogInfo((object)"Unlimited Truck Energy 1.0 loaded. Weapons remain vanilla."); } private void OnDestroy() { Harmony? harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } } } internal static class TruckEnergy { [HarmonyPatch(typeof(ChargingStation), "Start")] private static class ChargingStationStartPatch { [HarmonyPostfix] private static void Postfix(ChargingStation __instance) { ClampToHalf(__instance); Plugin.Log.LogInfo((object)"Truck charging station initialized with a 50% minimum energy level."); } } [HarmonyPatch(typeof(ChargingStation), "Update")] private static class ChargingStationUpdatePatch { [HarmonyPrefix] private static void Prefix(ChargingStation __instance) { ClampToHalf(__instance); } [HarmonyPostfix] private static void Postfix(ChargingStation __instance) { ClampToHalf(__instance); } } private const int MinimumChargeTotal = 50; private const float MinimumChargeFloat = 0.5f; private static readonly FieldInfo ChargeTotalField = RequireField("chargeTotal"); private static readonly FieldInfo ChargeFloatField = RequireField("chargeFloat"); private static readonly FieldInfo ChargeSegmentsField = RequireField("chargeSegments"); private static readonly FieldInfo ChargeSegmentCurrentField = RequireField("chargeSegmentCurrent"); private static FieldInfo RequireField(string name) { return AccessTools.Field(typeof(ChargingStation), name) ?? throw new MissingFieldException(typeof(ChargingStation).FullName, name); } internal static void ClampToHalf(ChargingStation station) { if (Object.op_Implicit((Object)(object)station)) { int num = (int)ChargeTotalField.GetValue(station); float num2 = (float)ChargeFloatField.GetValue(station); if (num < 50) { ChargeTotalField.SetValue(station, 50); } if (num2 < 0.5f) { ChargeFloatField.SetValue(station, 0.5f); } int num3 = (int)ChargeSegmentsField.GetValue(station); int num4 = (int)ChargeSegmentCurrentField.GetValue(station); int num5 = Mathf.CeilToInt((float)num3 * 0.5f); if (num4 < num5) { ChargeSegmentCurrentField.SetValue(station, num5); } } } } }