using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
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;
using lethalpanicbutton.Patches;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("lethalpanicbutton")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("lethalpanicbutton")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("72fe1a18-712e-4c43-9147-618ff0e2071f")]
[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 lethalpanicbutton
{
[BepInPlugin("lethalpanicbutton", "Lethal Panic Button", "1.1.0")]
public class lethalpanicbase : BaseUnityPlugin
{
private const string modGUID = "lethalpanicbutton";
private const string modName = "Lethal Panic Button";
private const string modVersion = "1.1.0";
private readonly Harmony harmony = new Harmony("lethalpanicbutton");
private static lethalpanicbase Instance;
internal ManualLogSource mls;
internal static List<AudioClip> SoundFX;
internal static AssetBundle Bundle;
private void Awake()
{
if ((Object)(object)Instance == (Object)null)
{
Instance = this;
}
mls = Logger.CreateLogSource("lethalpanicbutton");
mls.LogInfo((object)"Radios Online");
harmony.PatchAll(typeof(PlayerControllerBPatch));
mls = ((BaseUnityPlugin)this).Logger;
SoundFX = new List<AudioClip>();
string location = ((BaseUnityPlugin)Instance).Info.Location;
location = location.TrimEnd("lethalpanicbutton.dll".ToCharArray());
Bundle = AssetBundle.LoadFromFile(location + "panic");
if ((Object)(object)Bundle != (Object)null)
{
mls.LogInfo((object)"Found Panic Sound! It's tmantime");
SoundFX = Bundle.LoadAllAssets<AudioClip>().ToList();
}
else
{
mls.LogError((object)"Sound Not Found");
}
}
}
}
namespace lethalpanicbutton.Patches
{
[HarmonyPatch(typeof(PlayerControllerB))]
internal class PlayerControllerBPatch
{
private static WalkieTalkie GetWalkie()
{
WalkieTalkie result = null;
for (int i = 0; i < WalkieTalkie.allWalkieTalkies.Count; i++)
{
if ((Object)(object)StartOfRound.Instance.allPlayerScripts[NetworkManager.Singleton.LocalClientId] == (Object)(object)((GrabbableObject)WalkieTalkie.allWalkieTalkies[i]).playerHeldBy)
{
result = WalkieTalkie.allWalkieTalkies[i];
}
}
return result;
}
private static void BroadcastSFXFromWalkieTalkie(AudioClip sfx)
{
for (int i = 0; i < WalkieTalkie.allWalkieTalkies.Count && ((GrabbableObject)WalkieTalkie.allWalkieTalkies[i]).isBeingUsed; i++)
{
WalkieTalkie.allWalkieTalkies[i].thisAudio.PlayOneShot(sfx);
}
}
[HarmonyPatch("SpawnDeadBody")]
[HarmonyPostfix]
private static void deathsoundpatch(ref DeadBodyInfo ___deadBody)
{
___deadBody.bodyAudio.PlayOneShot(lethalpanicbase.SoundFX[0]);
WalkieTalkie walkie = GetWalkie();
if ((Object)(object)walkie == (Object)null || ((GrabbableObject)walkie).isBeingUsed)
{
BroadcastSFXFromWalkieTalkie(lethalpanicbase.SoundFX[0]);
}
}
}
}