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 EnergyCrystalAutoRefill v1.2.2
EnergyCrystalAutoRefill.dll
Decompiled 3 weeks agousing System; using System.Collections; 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 HarmonyLib; using Microsoft.CodeAnalysis; using Photon.Pun; 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(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: IgnoresAccessChecksTo("")] [assembly: AssemblyCompany("zabu")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("zabumod")] [assembly: AssemblyTitle("zabumod")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.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.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] [Microsoft.CodeAnalysis.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] [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 REPOJP.EnergyCrystalAutoRefill { [BepInPlugin("REPOJP.EnergyCrystalAutoRefill", "EnergyCrystalAutoRefill", "1.2.0")] public sealed class EnergyCrystalAutoRefillPlugin : BaseUnityPlugin { private sealed class ForcedMessageInfo { private readonly Queue<string> _messages = new Queue<string>(); private bool _isSending; public int Count => _messages.Count; public void AddMessage(string message) { if (!string.IsNullOrEmpty(message)) { _messages.Enqueue(message); } } public bool TryDequeue(out string message) { if (_messages.Count > 0) { message = _messages.Dequeue(); return true; } message = null; return false; } public bool IsSending() { return _isSending; } public void SetSending(bool value) { _isSending = value; } } [HarmonyPatch(typeof(ChargingStation), "Update")] private static class ChargingStationUpdatePostfixPatch { private enum FlowState { Idle, Running, Cooldown } [CompilerGenerated] private sealed class <FlowCoroutine>d__16 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public ChargingStation station; private int <costK>5__1; private ForcedMessageInfo <costInfo>5__2; private int <currencyBeforeWait>5__3; private float <endWait>5__4; private ForcedMessageInfo <countdownInfo>5__5; private int <currencyBeforeSpend>5__6; private bool <refillOk>5__7; private int <savingsAfter>5__8; private ForcedMessageInfo <savingsInfo>5__9; private float <cd>5__10; private ForcedMessageInfo <insufficientInfo>5__11; private int <i>5__12; private string <message>5__13; private ForcedMessageInfo <insufficientInfo>5__14; private int <curNow>5__15; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <FlowCoroutine>d__16(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <costInfo>5__2 = null; <countdownInfo>5__5 = null; <savingsInfo>5__9 = null; <insufficientInfo>5__11 = null; <message>5__13 = null; <insufficientInfo>5__14 = null; <>1__state = -2; } private bool MoveNext() { //IL_02f2: Unknown result type (might be due to invalid IL or missing references) //IL_02fc: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; if ((Object)(object)station == (Object)null) { _sequenceRunning = false; _state = FlowState.Idle; return false; } ResetTryCache(); UpdateTryCache(station); if (!IsDepleted(station) || !_tryCacheValid || !_tryCached) { _sequenceRunning = false; _state = FlowState.Idle; return false; } <costK>5__1 = Mathf.Clamp(CfgCostPerRefillK.Value, 0, 100); <costInfo>5__2 = new ForcedMessageInfo(); <costInfo>5__2.AddMessage($"Buy cost {<costK>5__1}k$."); BroadcastTruckMessage($"Buy cost {<costK>5__1}k$."); StartForcedMessageQueue(<costInfo>5__2); <currencyBeforeWait>5__3 = SemiFunc.StatGetRunCurrency(); if (<costK>5__1 > 0 && <currencyBeforeWait>5__3 < <costK>5__1) { <insufficientInfo>5__11 = new ForcedMessageInfo(); <insufficientInfo>5__11.AddMessage("No money…"); <insufficientInfo>5__11.AddMessage($"My money is {<currencyBeforeWait>5__3}k$."); <insufficientInfo>5__11.AddMessage($"Need {<costK>5__1}k$."); BroadcastTruckMessage("No money…"); BroadcastTruckMessage($"My money is {<currencyBeforeWait>5__3}k$."); BroadcastTruckMessage($"Need {<costK>5__1}k$."); StartForcedMessageQueue(<insufficientInfo>5__11); _requireReinsertAfterInsufficient = true; _sequenceRunning = false; _state = FlowState.Idle; return false; } <endWait>5__4 = Time.time + 5f; goto IL_025d; case 1: <>1__state = -1; goto IL_025d; case 2: { <>1__state = -1; ResetTryCache(); UpdateTryCache(station); if (!IsDepleted(station) || !_tryCacheValid || !_tryCached) { _sequenceRunning = false; _state = FlowState.Idle; return false; } <message>5__13 = null; break; } IL_025d: if (Time.time < <endWait>5__4) { ResetTryCache(); UpdateTryCache(station); if (!IsDepleted(station) || !_tryCacheValid || !_tryCached) { _sequenceRunning = false; _state = FlowState.Idle; return false; } <>2__current = null; <>1__state = 1; return true; } <countdownInfo>5__5 = new ForcedMessageInfo(); <i>5__12 = 5; while (<i>5__12 >= 1) { <countdownInfo>5__5.AddMessage(<i>5__12.ToString()); <i>5__12--; } break; } if (<countdownInfo>5__5.Count > 0) { if (<countdownInfo>5__5.TryDequeue(out <message>5__13)) { ForceTruckPlayersChat(<message>5__13); } <>2__current = (object)new WaitForSeconds(1f); <>1__state = 2; return true; } ResetTryCache(); UpdateTryCache(station); if (!IsDepleted(station) || !_tryCacheValid || !_tryCached) { _sequenceRunning = false; _state = FlowState.Idle; return false; } <currencyBeforeSpend>5__6 = SemiFunc.StatGetRunCurrency(); if (<costK>5__1 > 0 && <currencyBeforeSpend>5__6 < <costK>5__1) { <insufficientInfo>5__14 = new ForcedMessageInfo(); <insufficientInfo>5__14.AddMessage("No money…"); <insufficientInfo>5__14.AddMessage($"My money is {<currencyBeforeSpend>5__6}k$."); <insufficientInfo>5__14.AddMessage($"Need {<costK>5__1}k$."); BroadcastTruckMessage("No money…"); BroadcastTruckMessage($"My money is {<currencyBeforeSpend>5__6}k$."); BroadcastTruckMessage($"Need {<costK>5__1}k$."); StartForcedMessageQueue(<insufficientInfo>5__14); _requireReinsertAfterInsufficient = true; _sequenceRunning = false; _state = FlowState.Idle; return false; } if (<costK>5__1 > 0) { SemiFunc.StatSetRunCurrency(<currencyBeforeSpend>5__6 - <costK>5__1); } <refillOk>5__7 = false; try { DoRefillAddPowerCrystalsOnly(station); <refillOk>5__7 = true; } catch { <refillOk>5__7 = false; } if (!<refillOk>5__7) { if (<costK>5__1 > 0) { <curNow>5__15 = SemiFunc.StatGetRunCurrency(); SemiFunc.StatSetRunCurrency(<curNow>5__15 + <costK>5__1); } _sequenceRunning = false; _state = FlowState.Idle; return false; } <savingsAfter>5__8 = SemiFunc.StatGetRunCurrency(); <savingsInfo>5__9 = new ForcedMessageInfo(); <savingsInfo>5__9.AddMessage($"My money is {<savingsAfter>5__8}k$."); BroadcastTruckMessage($"My money is {<savingsAfter>5__8}k$."); StartForcedMessageQueue(<savingsInfo>5__9); <cd>5__10 = Mathf.Clamp(CfgCooldownSeconds.Value, 1f, 300f); _cooldownEndTime = Time.time + <cd>5__10; _cooldownChatSent = false; _state = FlowState.Cooldown; _sequenceRunning = false; return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <ForcedMessageQueueCoroutine>d__18 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public ForcedMessageInfo info; private string <message>5__1; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <ForcedMessageQueueCoroutine>d__18(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <message>5__1 = null; <>1__state = -2; } private bool MoveNext() { //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; if (info == null) { return false; } break; case 1: <>1__state = -1; <message>5__1 = null; break; } if (info.Count > 0) { if (info.TryDequeue(out <message>5__1)) { ForceTruckPlayersChat(<message>5__1); } <>2__current = (object)new WaitForSeconds(1.2f); <>1__state = 1; return true; } info.SetSending(value: false); return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private static readonly FieldInfo FiChargeFloat = AccessTools.Field(typeof(ChargingStation), "chargeFloat"); private static readonly FieldInfo FiChargeSegments = AccessTools.Field(typeof(ChargingStation), "chargeSegments"); private static readonly FieldInfo FiChargeSegmentCurrent = AccessTools.Field(typeof(ChargingStation), "chargeSegmentCurrent"); private static readonly FieldInfo FiChargeArea = AccessTools.Field(typeof(ChargingStation), "chargeArea"); private static FlowState _state; private static bool _sequenceRunning; private static float _cooldownEndTime; private static bool _cooldownChatSent; private static bool _requireReinsertAfterInsufficient; private static float _tryScanTimer; private static bool _tryCached; private static bool _tryCacheValid; private static bool _lastTrying; [HarmonyPostfix] private static void Postfix(ChargingStation __instance) { if (CfgEnableMod == null || !CfgEnableMod.Value || (Object)(object)__instance == (Object)null || SemiFunc.RunIsShop() || ((Object)(object)RunManager.instance != (Object)null && RunManager.instance.levelIsShop) || !SemiFunc.IsMasterClientOrSingleplayer() || ((Object)(object)RunManager.instance != (Object)null && RunManager.instance.restarting)) { return; } UpdateTryCache(__instance); bool flag = _tryCacheValid && _tryCached; if (_state == FlowState.Cooldown) { if (!(Time.time >= _cooldownEndTime)) { if (flag && IsDepleted(__instance) && !_cooldownChatSent) { ForcedMessageInfo forcedMessageInfo = new ForcedMessageInfo(); int num = Mathf.CeilToInt(Mathf.Max(0f, _cooldownEndTime - Time.time)); forcedMessageInfo.AddMessage($"Cooldown {num}s."); StartForcedMessageQueue(forcedMessageInfo); _cooldownChatSent = true; } _lastTrying = flag; return; } _state = FlowState.Idle; _sequenceRunning = false; _cooldownChatSent = false; } if (!IsDepleted(__instance)) { _lastTrying = false; if (_state == FlowState.Running) { _state = FlowState.Idle; _sequenceRunning = false; } return; } if (_requireReinsertAfterInsufficient) { if (!(!_lastTrying && flag)) { _lastTrying = flag; return; } _requireReinsertAfterInsufficient = false; } if (!flag) { _lastTrying = false; return; } if (_state == FlowState.Idle && !_sequenceRunning) { StartSequence(__instance); } _lastTrying = flag; } private static void StartSequence(ChargingStation station) { if (!_sequenceRunning) { _sequenceRunning = true; _state = FlowState.Running; if ((Object)(object)Instance != (Object)null) { ((MonoBehaviour)Instance).StartCoroutine(FlowCoroutine(station)); return; } _sequenceRunning = false; _state = FlowState.Idle; } } [IteratorStateMachine(typeof(<FlowCoroutine>d__16))] private static IEnumerator FlowCoroutine(ChargingStation station) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <FlowCoroutine>d__16(0) { station = station }; } private static void StartForcedMessageQueue(ForcedMessageInfo info) { if (info != null && !((Object)(object)Instance == (Object)null) && !info.IsSending()) { info.SetSending(value: true); ((MonoBehaviour)Instance).StartCoroutine(ForcedMessageQueueCoroutine(info)); } } [IteratorStateMachine(typeof(<ForcedMessageQueueCoroutine>d__18))] private static IEnumerator ForcedMessageQueueCoroutine(ForcedMessageInfo info) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <ForcedMessageQueueCoroutine>d__18(0) { info = info }; } private static void UpdateTryCache(ChargingStation station) { if (_tryCacheValid && _tryScanTimer < 0.5f) { _tryScanTimer += Time.deltaTime; return; } _tryScanTimer += Time.deltaTime; if (!_tryCacheValid || !(_tryScanTimer < 0.5f)) { _tryScanTimer = 0f; _tryCached = DetectTryingToChargeStrict(station); _tryCacheValid = true; } } private static void ResetTryCache() { _tryScanTimer = 0.5f; _tryCacheValid = false; _tryCached = false; } private static bool DetectTryingToChargeStrict(ChargingStation station) { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)station == (Object)null) { return false; } Transform val = SafeGetTransform(station, FiChargeArea); if ((Object)(object)val == (Object)null) { return false; } try { Collider[] array = Physics.OverlapBox(val.position, val.localScale / 2f, val.localRotation, LayerMask.op_Implicit(SemiFunc.LayerMaskGetPhysGrabObject())); for (int i = 0; i < array.Length; i++) { ItemBattery componentInParent = ((Component)array[i]).GetComponentInParent<ItemBattery>(); if ((Object)(object)componentInParent != (Object)null && componentInParent.batteryLifeInt < componentInParent.batteryBars) { return true; } } } catch { } return false; } private static bool IsDepleted(ChargingStation station) { if ((Object)(object)station == (Object)null) { return false; } float num = SafeGetFloat(station, FiChargeFloat, 0f); int chargeTotal = station.chargeTotal; int num2 = SafeGetInt(station, FiChargeSegments, 40); int num3 = SafeGetInt(station, FiChargeSegmentCurrent, Mathf.RoundToInt(num * (float)num2)); return chargeTotal <= 0 || num <= 0f || num3 <= 0; } private static void DoRefillAddPowerCrystalsOnly(ChargingStation station) { if ((Object)(object)station == (Object)null) { return; } int num = SafeGetInt(station, FiChargeSegments, 40); int num2 = Mathf.Clamp(CfgPowerCrystalsToAdd.Value, 1, 10); TryAddPowerCrystalPurchase(station, num2); int num3 = Mathf.Clamp(station.chargeTotal, 0, 100); int num4 = 9 * num2; int num5 = (station.chargeTotal = Mathf.Clamp(num3 + num4, 1, 100)); float num6 = (float)num5 / 100f; SafeSetFloat(station, FiChargeFloat, num6); int num7 = Mathf.Clamp(Mathf.RoundToInt(num6 * (float)num), 1, num); SafeSetInt(station, FiChargeSegmentCurrent, num7); try { PunManager.instance.SetRunStatSet("chargingStationChargeTotal", num5); PunManager.instance.SetRunStatSet("chargingStationCharge", station.chargeInt); } catch { } PhotonView component = ((Component)station).GetComponent<PhotonView>(); if (!((Object)(object)component != (Object)null) || !SemiFunc.IsMultiplayer()) { return; } try { component.RPC("ChargingStationSegmentChangedRPC", (RpcTarget)3, new object[1] { (byte)Mathf.Clamp(num7, 0, 255) }); } catch { } } private static void TryAddPowerCrystalPurchase(ChargingStation station, int addCount) { if ((Object)(object)station == (Object)null) { return; } int num = Mathf.Clamp(addCount, 1, 10); station.chargeInt = Mathf.Max(1, station.chargeInt + num); try { if ((Object)(object)station.item != (Object)null && (Object)(object)StatsManager.instance != (Object)null) { int itemPurchased = StatsManager.instance.GetItemPurchased(station.item); StatsManager.instance.SetItemPurchase(station.item, itemPurchased + num); } } catch { } try { if (!((Object)(object)StatsManager.instance != (Object)null)) { return; } if (StatsManager.instance.itemsPurchased != null) { int num2 = 0; if (StatsManager.instance.itemsPurchased.ContainsKey("Item Power Crystal")) { num2 = StatsManager.instance.itemsPurchased["Item Power Crystal"]; } StatsManager.instance.itemsPurchased["Item Power Crystal"] = Mathf.Max(0, num2 + num); } if (StatsManager.instance.itemsPurchasedTotal != null) { int num3 = 0; if (StatsManager.instance.itemsPurchasedTotal.ContainsKey("Item Power Crystal")) { num3 = StatsManager.instance.itemsPurchasedTotal["Item Power Crystal"]; } StatsManager.instance.itemsPurchasedTotal["Item Power Crystal"] = Mathf.Max(0, num3 + num); } } catch { } } private static void BroadcastTruckMessage(string message) { try { if ((Object)(object)TruckScreenText.instance != (Object)null) { TruckScreenText.instance.MessageSendCustom("", message, 0); } } catch { } } private static void ForceTruckPlayersChat(string message) { try { List<PlayerAvatar> list = SemiFunc.PlayerGetList(); if (list == null || list.Count == 0) { return; } foreach (PlayerAvatar item in list) { if (!((Object)(object)item == (Object)null) && !item.isDisabled && !((Object)(object)item.RoomVolumeCheck == (Object)null) && item.RoomVolumeCheck.inTruck) { item.ChatMessageSend(message); } } } catch { } } private static Transform SafeGetTransform(object obj, FieldInfo fi) { if (obj == null || fi == null) { return null; } try { object? value = fi.GetValue(obj); return (Transform)((value is Transform) ? value : null); } catch { return null; } } private static int SafeGetInt(object obj, FieldInfo fi, int fallback) { if (obj == null || fi == null) { return fallback; } try { object value = fi.GetValue(obj); if (value is int) { int result = (int)value; if (true) { return result; } } } catch { } return fallback; } private static float SafeGetFloat(object obj, FieldInfo fi, float fallback) { if (obj == null || fi == null) { return fallback; } try { object value = fi.GetValue(obj); if (value is float) { float result = (float)value; if (true) { return result; } } } catch { } return fallback; } private static void SafeSetInt(object obj, FieldInfo fi, int value) { if (obj == null || fi == null) { return; } try { fi.SetValue(obj, value); } catch { } } private static void SafeSetFloat(object obj, FieldInfo fi, float value) { if (obj == null || fi == null) { return; } try { fi.SetValue(obj, value); } catch { } } } public const string PluginGuid = "REPOJP.EnergyCrystalAutoRefill"; public const string PluginName = "EnergyCrystalAutoRefill"; public const string PluginVersion = "1.2.0"; private const int ChargeTotalPerCrystal = 9; private static ConfigEntry<bool> CfgEnableMod; private static ConfigEntry<int> CfgCostPerRefillK; private static ConfigEntry<int> CfgPowerCrystalsToAdd; private static ConfigEntry<float> CfgCooldownSeconds; private const float PreCountdownDelaySeconds = 5f; private const int CountdownSecondsFixed = 5; private const float TryScanIntervalSeconds = 0.5f; private Harmony _harmony; internal static EnergyCrystalAutoRefillPlugin Instance; private void Awake() { //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Expected O, but got Unknown //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Expected O, but got Unknown //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Expected O, but got Unknown //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Expected O, but got Unknown ((BaseUnityPlugin)this).Logger.LogInfo((object)"\r\n█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████\r\n ▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄ ▄▄ ▄▄▄▄ ▄▄▄▄▄▄▄ ▄▄ ▄▄ ▄▄\r\n███▀▀▀▀▀ ███▀▀▀▀▀ ██ ██ ▄██▀▀██▄ ██ ███▀▀███▄ ██ ▀▀ ██ ██\r\n███▄▄▄▄ ████▄ ▄█▀█▄ ████▄ ▄████ ██ ██ ███ ████▄ ██ ██ ▄█▀▀▀ ▀██▀▀ ▀▀█▄ ██ ███ ███ ██ ██ ▀██▀▀ ▄███▄ ███▄▄███▀ ▄█▀█▄ ▀██▀ ██ ██ ██\r\n███ ██ ██ ██▄█▀ ██ ▀▀ ██ ██ ██▄██ ███ ██ ▀▀ ██▄██ ▀███▄ ██ ▄█▀██ ██ ███▀▀███ ██ ██ ██ ██ ██ ███▀▀██▄ ██▄█▀ ██ ██ ██ ██\r\n▀███████ ██ ██ ▀█▄▄▄ ██ ▀████ ▀██▀ ▀███████ ██ ▀██▀ ▄▄▄█▀ ██ ▀█▄██ ██ ███ ███ ▀██▀█ ██ ▀███▀ ███ ▀███ ▀█▄▄▄ ██ ██▄ ██ ██\r\n ██ ██ ██ \r\n ▀▀▀ ▀▀▀ ▀▀▀ \r\n█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████\r\n"); try { ((Component)this).transform.parent = null; ((Object)((Component)this).gameObject).hideFlags = (HideFlags)61; Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject); Instance = this; CfgEnableMod = ((BaseUnityPlugin)this).Config.Bind<bool>("A General", "EnableMod", true, "Enable or disable this mod.このMODの有効無効"); CfgCostPerRefillK = ((BaseUnityPlugin)this).Config.Bind<int>("A General", "CostPerRefill", 10, new ConfigDescription("Cost per refill in k$.補充1回あたりのコスト(k$)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>())); CfgPowerCrystalsToAdd = ((BaseUnityPlugin)this).Config.Bind<int>("A General", "PowerCrystalsToAdd", 1, new ConfigDescription("How many power crystals worth to add per refill.補充するパワークリスタル量", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 10), Array.Empty<object>())); CfgCooldownSeconds = ((BaseUnityPlugin)this).Config.Bind<float>("A General", "CooldownSeconds", 10f, new ConfigDescription("Cooldown seconds after a refill.補充後クールダウン秒", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 300f), Array.Empty<object>())); _harmony = new Harmony("REPOJP.EnergyCrystalAutoRefill"); _harmony.PatchAll(typeof(ChargingStationUpdatePostfixPatch)); ((BaseUnityPlugin)this).Logger.LogInfo((object)"EnergyCrystalAutoRefill loaded."); } catch (Exception arg) { ((BaseUnityPlugin)this).Logger.LogError((object)$"Failure: Awake\n{arg}"); throw; } } private void OnDestroy() { try { Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } } catch { } if ((Object)(object)Instance == (Object)(object)this) { Instance = null; } } } }