using 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.0.0")]
public sealed class EnergyCrystalAutoRefillPlugin : BaseUnityPlugin
{
public sealed class ForcedChatRpcReceiver : MonoBehaviourPun
{
[PunRPC]
private void REPOJP_PCA_ForceChatInTruck(string message)
{
PlayerAvatar localPlayerAvatar = GetLocalPlayerAvatar();
if (!((Object)(object)localPlayerAvatar == (Object)null) && !localPlayerAvatar.isDisabled && !((Object)(object)localPlayerAvatar.RoomVolumeCheck == (Object)null) && localPlayerAvatar.RoomVolumeCheck.inTruck && (Object)(object)ChatManager.instance != (Object)null)
{
ChatManager.instance.ForceSendMessage(message);
}
}
private static PlayerAvatar GetLocalPlayerAvatar()
{
try
{
List<PlayerAvatar> list = SemiFunc.PlayerGetList();
for (int i = 0; i < list.Count; i++)
{
if ((Object)(object)list[i] != (Object)null && list[i].isLocal)
{
return list[i];
}
}
}
catch
{
}
return PlayerAvatar.instance;
}
}
[HarmonyPatch(typeof(ChargingStation), "Start")]
private static class ChargingStationRpcHelperEnsurePatch
{
[HarmonyPostfix]
private static void Postfix(ChargingStation __instance)
{
if (!((Object)(object)__instance == (Object)null) && !((Object)(object)((Component)__instance).gameObject.GetComponent<ForcedChatRpcReceiver>() != (Object)null))
{
((Component)__instance).gameObject.AddComponent<ForcedChatRpcReceiver>();
}
}
}
[HarmonyPatch(typeof(ChargingStation), "Update")]
private static class ChargingStationUpdatePostfixPatch
{
private enum FlowState
{
Idle,
Running,
Cooldown
}
[CompilerGenerated]
private sealed class <FlowCoroutine>d__19 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public ChargingStation station;
private int <costK>5__1;
private int <currencyBeforeWait>5__2;
private float <endWait>5__3;
private int <currencyBeforeSpend>5__4;
private bool <refillOk>5__5;
private int <savingsAfter>5__6;
private float <cd>5__7;
private int <i>5__8;
private int <curNow>5__9;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <FlowCoroutine>d__19(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
//IL_01f0: 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);
ForceChatInTruckPlayers(station, $"Refill costs {<costK>5__1}k$.");
<currencyBeforeWait>5__2 = SemiFunc.StatGetRunCurrency();
if (<costK>5__1 > 0 && <currencyBeforeWait>5__2 < <costK>5__1)
{
ForceChatInTruckPlayers(station, $"Not enough savings. Need {<costK>5__1}k$, have {<currencyBeforeWait>5__2}k$.");
_requireReinsertAfterInsufficient = true;
_sequenceRunning = false;
_state = FlowState.Idle;
return false;
}
<endWait>5__3 = Time.time + 5f;
goto IL_01a9;
case 1:
<>1__state = -1;
goto IL_01a9;
case 2:
{
<>1__state = -1;
ResetTryCache();
UpdateTryCache(station);
if (!IsDepleted(station) || !_tryCacheValid || !_tryCached)
{
_sequenceRunning = false;
_state = FlowState.Idle;
return false;
}
<i>5__8--;
break;
}
IL_01a9:
if (Time.time < <endWait>5__3)
{
ResetTryCache();
UpdateTryCache(station);
if (!IsDepleted(station) || !_tryCacheValid || !_tryCached)
{
_sequenceRunning = false;
_state = FlowState.Idle;
return false;
}
<>2__current = null;
<>1__state = 1;
return true;
}
<i>5__8 = 5;
break;
}
if (<i>5__8 >= 1)
{
ForceChatInTruckPlayers(station, <i>5__8.ToString());
<>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__4 = SemiFunc.StatGetRunCurrency();
if (<costK>5__1 > 0 && <currencyBeforeSpend>5__4 < <costK>5__1)
{
ForceChatInTruckPlayers(station, $"Not enough savings. Need {<costK>5__1}k$, have {<currencyBeforeSpend>5__4}k$.");
_requireReinsertAfterInsufficient = true;
_sequenceRunning = false;
_state = FlowState.Idle;
return false;
}
if (<costK>5__1 > 0)
{
SemiFunc.StatSetRunCurrency(<currencyBeforeSpend>5__4 - <costK>5__1);
}
<refillOk>5__5 = false;
try
{
DoRefillAddPowerCrystalsOnly(station);
<refillOk>5__5 = true;
}
catch
{
<refillOk>5__5 = false;
}
if (!<refillOk>5__5)
{
if (<costK>5__1 > 0)
{
<curNow>5__9 = SemiFunc.StatGetRunCurrency();
SemiFunc.StatSetRunCurrency(<curNow>5__9 + <costK>5__1);
}
_sequenceRunning = false;
_state = FlowState.Idle;
return false;
}
<savingsAfter>5__6 = SemiFunc.StatGetRunCurrency();
ForceChatInTruckPlayers(station, $"Savings: {<savingsAfter>5__6}k$.");
<cd>5__7 = Mathf.Clamp(CfgCooldownSeconds.Value, 1f, 300f);
_cooldownEndTime = Time.time + <cd>5__7;
_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();
}
}
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 FiPhotonView = AccessTools.Field(typeof(ChargingStation), "photonView");
private static readonly FieldInfo FiChargeArea = AccessTools.Field(typeof(ChargingStation), "chargeArea");
private static readonly FieldInfo FiChargeRate = AccessTools.Field(typeof(ChargingStation), "chargeRate");
private static readonly FieldInfo FiEnergyPerCrystal = AccessTools.Field(typeof(ChargingStation), "energyPerCrystal");
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)
{
int num = Mathf.CeilToInt(Mathf.Max(0f, _cooldownEndTime - Time.time));
ForceChatInTruckPlayers(__instance, $"Cooldown: {num}s.");
_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__19))]
private static IEnumerator FlowCoroutine(ChargingStation station)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <FlowCoroutine>d__19(0)
{
station = station
};
}
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, FiEnergyPerCrystal, 10);
int num2 = SafeGetInt(station, FiChargeSegments, 40);
int num3 = Mathf.Clamp(CfgPowerCrystalsToAdd.Value, 1, 10);
TryAddPowerCrystalPurchase(station, num3);
float num4 = SafeGetFloat(station, FiChargeFloat, 0f);
int num5 = Mathf.Clamp(station.chargeTotal, 0, 100);
int num6 = Mathf.Max(1, num) * Mathf.Max(1, num3);
int num7 = Mathf.Clamp(num5 + num6, 1, 100);
int num8 = Mathf.Clamp(station.chargeInt * num, 1, 100);
num7 = Mathf.Clamp(num7, 1, num8);
float num9 = (float)num7 / 100f;
station.chargeTotal = num7;
SafeSetFloat(station, FiChargeFloat, num9);
int num10 = Mathf.Clamp(Mathf.RoundToInt(num9 * (float)num2), 1, num2);
SafeSetInt(station, FiChargeSegmentCurrent, num10);
if (FiChargeRate != null)
{
try
{
float num11 = 1f / (float)num / (float)Mathf.Max(1, station.chargeTotal);
FiChargeRate.SetValue(station, num11);
}
catch
{
}
}
try
{
PunManager.instance.SetRunStatSet("chargingStationChargeTotal", num7);
PunManager.instance.SetRunStatSet("chargingStationCharge", station.chargeInt);
}
catch
{
}
PhotonView val = SafeGetPhotonView(station);
if (!((Object)(object)val != (Object)null) || !SemiFunc.IsMultiplayer())
{
return;
}
try
{
val.RPC("ChargingStationSegmentChangedRPC", (RpcTarget)3, new object[1] { (byte)Mathf.Clamp(num10, 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 ForceChatInTruckPlayers(ChargingStation station, string message)
{
if (!SemiFunc.IsMultiplayer())
{
PlayerAvatar instance = PlayerAvatar.instance;
if ((Object)(object)instance != (Object)null && (Object)(object)instance.RoomVolumeCheck != (Object)null && instance.RoomVolumeCheck.inTruck && (Object)(object)ChatManager.instance != (Object)null)
{
ChatManager.instance.ForceSendMessage(message);
}
return;
}
PhotonView val = SafeGetPhotonView(station);
if ((Object)(object)val == (Object)null)
{
return;
}
try
{
val.RPC("REPOJP_PCA_ForceChatInTruck", (RpcTarget)0, new object[1] { message });
}
catch
{
}
}
private static PhotonView SafeGetPhotonView(ChargingStation station)
{
if ((Object)(object)station == (Object)null)
{
return null;
}
try
{
object? obj = FiPhotonView?.GetValue(station);
return (PhotonView)((obj is PhotonView) ? obj : null);
}
catch
{
return null;
}
}
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.0.0";
private static ConfigEntry<bool> CfgEnableMod;
private static ConfigEntry<int> CfgCostPerRefillK;
private static ConfigEntry<int> CfgPowerCrystalsToAdd;
private static ConfigEntry<float> CfgCooldownSeconds;
private static ConfigEntry<bool> CfgDebugOnGuiHeartbeat;
private const float PreCountdownDelaySeconds = 5f;
private const int CountdownSecondsFixed = 5;
private const float TryScanIntervalSeconds = 0.5f;
private Harmony _harmony;
internal static EnergyCrystalAutoRefillPlugin Instance;
private int _lastOnGuiFrame = -1;
private void Awake()
{
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: Expected O, but got Unknown
//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
//IL_00af: Expected O, but got Unknown
//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
//IL_00ec: Expected O, but got Unknown
//IL_0117: Unknown result type (might be due to invalid IL or missing references)
//IL_0121: Expected O, but got Unknown
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", 20, 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", 5, 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>()));
CfgDebugOnGuiHeartbeat = ((BaseUnityPlugin)this).Config.Bind<bool>("Z Debug", "DebugOnGuiHeartbeat", false, "Log one heartbeat per frame from OnGUI (debug).OnGUIから1フレーム1回ハートビートログ(デバッグ)");
_harmony = new Harmony("REPOJP.EnergyCrystalAutoRefill");
_harmony.PatchAll(typeof(ChargingStationRpcHelperEnsurePatch));
_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;
}
}
private void OnGUI()
{
if (CfgDebugOnGuiHeartbeat != null && CfgDebugOnGuiHeartbeat.Value && _lastOnGuiFrame != Time.frameCount)
{
_lastOnGuiFrame = Time.frameCount;
((BaseUnityPlugin)this).Logger.LogInfo((object)"OnGUI heartbeat.");
}
}
}
}