using System;
using System.Collections;
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.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using Unity.Netcode;
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("MetalRecharging_Updated")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("MetalRecharging_Updated")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("bc64cce8-fd6a-4086-9c0c-7f908f4e2f9a")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace MetalRecharging_Updated;
[HarmonyPatch(typeof(ItemCharger))]
internal class ItemChargerPatch : NetworkBehaviour
{
[CompilerGenerated]
private sealed class <KaboomCoroutine>d__2 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
public Vector3 boomLocation;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <KaboomCoroutine>d__2(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Expected O, but got Unknown
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<>2__current = (object)new WaitForSeconds(0.75f);
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
Landmine.SpawnExplosion(boomLocation, true, 1f, 1f, 50, 0f, (GameObject)null, 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();
}
}
[HarmonyPatch("Update")]
[HarmonyPrefix]
private static bool ItemChargerUpdate(ItemCharger __instance, ref float ___updateInterval, ref InteractTrigger ___triggerScript)
{
if ((Object)(object)NetworkManager.Singleton == (Object)null)
{
return false;
}
if (___updateInterval > 1f)
{
___updateInterval = 0f;
if ((Object)(object)GameNetworkManager.Instance != (Object)null && (Object)(object)GameNetworkManager.Instance.localPlayerController != (Object)null)
{
GrabbableObject currentlyHeldObjectServer = GameNetworkManager.Instance.localPlayerController.currentlyHeldObjectServer;
if ((Object)(object)currentlyHeldObjectServer == (Object)null || (!currentlyHeldObjectServer.itemProperties.isConductiveMetal && !currentlyHeldObjectServer.itemProperties.requiresBattery))
{
___triggerScript.interactable = false;
___triggerScript.disabledHoverTip = "(Requires battery-powered item)";
}
else
{
___triggerScript.interactable = true;
}
___triggerScript.twoHandedItemAllowed = true;
return false;
}
}
___updateInterval += Time.deltaTime;
return false;
}
[HarmonyPatch("ChargeItem")]
[HarmonyPostfix]
private static void ItemChargerCharge(ItemCharger __instance)
{
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
GrabbableObject currentlyHeldObjectServer = GameNetworkManager.Instance.localPlayerController.currentlyHeldObjectServer;
if ((Object)(object)currentlyHeldObjectServer != (Object)null && !currentlyHeldObjectServer.itemProperties.requiresBattery && currentlyHeldObjectServer.itemProperties.isConductiveMetal)
{
PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
((MonoBehaviour)__instance).StartCoroutine(KaboomCoroutine(((Component)localPlayerController).transform.position));
}
}
[IteratorStateMachine(typeof(<KaboomCoroutine>d__2))]
private static IEnumerator KaboomCoroutine(Vector3 boomLocation)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <KaboomCoroutine>d__2(0)
{
boomLocation = boomLocation
};
}
}
[BepInPlugin("lynksdev.MetalRecharging_Updated", "Metal Recharing Updated", "1.0")]
public class MRUPlugin : BaseUnityPlugin
{
private const string modGUID = "lynksdev.MetalRecharging_Updated";
private const string modName = "Metal Recharing Updated";
private const string modVersion = "1.0";
private readonly Harmony harmony = new Harmony("lynksdev.MetalRecharging_Updated");
private static MRUPlugin instance;
internal ManualLogSource mls;
private void Awake()
{
if ((Object)(object)instance == (Object)null)
{
instance = this;
}
mls = Logger.CreateLogSource("lynksdev.MetalRecharging_Updated");
mls.LogInfo((object)"Plugin lynksdev.MetalRecharging_Updated is loaded!\n\n\n\n CHARGE YOUR METAL");
harmony.PatchAll(typeof(MRUPlugin));
harmony.PatchAll(typeof(ItemChargerPatch));
}
}