using System.Collections;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
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("LethalCharger")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("LethalCharger")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("3B0DF6BE-FE01-4B4B-A0E6-B6602CED9C92")]
[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 LethalCharger
{
[BepInPlugin("LethalCharger", "LethalCharger", "1.0.0.0")]
public class Plugin : BaseUnityPlugin
{
public void Awake()
{
((BaseUnityPlugin)this).Logger.LogInfo((object)"LethalCharger loaded!");
Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null);
}
}
}
namespace LethalCharger.Patches
{
[HarmonyPatch(typeof(ItemCharger))]
public class ItemChargerPatch
{
[HarmonyPatch("Update")]
[HarmonyPrefix]
public static bool ItemChargerUpdatePrefix(ItemCharger __instance, ref float ___updateInterval, ref InteractTrigger ___triggerScript)
{
if (!Object.op_Implicit((Object)(object)NetworkManager.Singleton))
{
return false;
}
___updateInterval += Time.deltaTime;
if (___updateInterval <= 1f)
{
return false;
}
___updateInterval = 0f;
if ((Object)(object)GameNetworkManager.Instance?.localPlayerController.currentlyHeldObjectServer != (Object)null)
{
___triggerScript.interactable = true;
}
return false;
}
[HarmonyPatch("ChargeItem")]
[HarmonyPostfix]
public static void ChargeItemPostfix(ItemCharger __instance)
{
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
PlayerControllerB val = GameNetworkManager.Instance?.localPlayerController;
if ((Object)(object)val == (Object)null)
{
Debug.LogError((object)"Invalid player");
return;
}
if ((Object)(object)val.currentlyHeldObjectServer != (Object)null)
{
Debug.LogError((object)val.serverPlayerPosition);
if (!val.currentlyHeldObjectServer.itemProperties.requiresBattery)
{
Landmine.SpawnExplosion(val.serverPlayerPosition + Vector3.up, true, 5.7f, 6f, 50, 0f, (GameObject)null, false);
}
return;
}
IHittable val2 = (IHittable)(object)val;
if (val2 != null)
{
IShockableWithGun val3 = (IShockableWithGun)(object)val;
if (val3 != null)
{
Debug.Log((object)"Игрок сует пальцы в розетку - ебашим током");
PlayAudio(val.waterBubblesAudio);
val2.Hit(1, Vector3.up, val, true, -1);
val3.ShockWithGun(val);
((MonoBehaviour)__instance).StartCoroutine(StopEffectAfterDelay(val3, 3f));
}
}
}
private static IEnumerator StopEffectAfterDelay(IShockableWithGun shockableWithGun, float delay)
{
yield return (object)new WaitForSeconds(delay);
shockableWithGun.StopShockingWithGun();
}
private static void PlayAudio(AudioSource audioSource)
{
AudioClip clip = audioSource.clip;
audioSource.PlayOneShot(clip);
}
}
}