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 GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.Networking;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("WilhelmScreamOnDeath")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+14237598ab671b0523d206a9f74bf86e95a50e9d")]
[assembly: AssemblyProduct("WilhelmScreamOnDeath")]
[assembly: AssemblyTitle("WilhelmScreamOnDeath")]
[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 WilhelmScreamOnDeath
{
[BepInPlugin("WilhelmScreamOnDeath", "WilhelmScreamOnDeath", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
private readonly Harmony harmony = new Harmony("WilhelmScreamOnDeath");
public static Plugin Instance { get; private set; }
public void Awake()
{
if ((Object)(object)Instance == (Object)null)
{
Instance = this;
harmony.PatchAll();
LogInfo("Plugin WilhelmScreamOnDeath is loaded!");
}
else
{
LogError("Awake() was called more than once!");
}
}
public void LogInfo(object data)
{
((BaseUnityPlugin)this).Logger.LogInfo(data);
}
public void LogWarning(object data)
{
((BaseUnityPlugin)this).Logger.LogWarning(data);
}
public void LogDebug(object data)
{
((BaseUnityPlugin)this).Logger.LogDebug(data);
}
public void LogFatal(object data)
{
((BaseUnityPlugin)this).Logger.LogFatal(data);
}
public void LogMessage(object data)
{
((BaseUnityPlugin)this).Logger.LogMessage(data);
}
public void LogError(object data)
{
((BaseUnityPlugin)this).Logger.LogError(data);
}
}
public static class Resources
{
private static bool isInit = false;
public const int WilhelmAudioClipsCount = 6;
public static List<AudioClip> WilhelmAudioClips = new List<AudioClip>();
public static AudioClip RandomWilhelmAudioClip => WilhelmAudioClips[Random.Range(1, 7)];
public static void EnsureInit()
{
if (!isInit)
{
MonoBehaviour instance = (MonoBehaviour)(object)SoundManager.Instance;
for (int i = 1; i <= 6; i++)
{
instance.StartCoroutine(InitWilhelmAudioClips(i));
}
isInit = true;
}
}
private static IEnumerator InitWilhelmAudioClips(int index)
{
string url = $"https://ia800802.us.archive.org/31/items/Wilhelm-ScreamSFX/Wilhelm%20{index}.wav";
Plugin.Instance.LogInfo("Started loading audio clip: " + url);
UnityWebRequest uwr = UnityWebRequestMultimedia.GetAudioClip(url, (AudioType)20);
try
{
yield return uwr.SendWebRequest();
if ((int)uwr.result == 2)
{
Plugin.Instance.LogError(uwr.error);
yield break;
}
AudioClip content = DownloadHandlerAudioClip.GetContent(uwr);
WilhelmAudioClips.Add(content);
Plugin.Instance.LogInfo("Finished loading audio clip: " + url);
}
finally
{
((IDisposable)uwr)?.Dispose();
}
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "WilhelmScreamOnDeath";
public const string PLUGIN_NAME = "WilhelmScreamOnDeath";
public const string PLUGIN_VERSION = "1.0.0";
}
}
namespace WilhelmScreamOnDeath.Patches
{
[HarmonyPatch(typeof(PlayerControllerB))]
public class PlayerControllerBPatch
{
[HarmonyPatch("Start")]
[HarmonyPostfix]
private static void Start()
{
Resources.EnsureInit();
}
[HarmonyPatch("SpawnDeadBody")]
[HarmonyPostfix]
private static void SpawnDeadBody(PlayerControllerB __instance)
{
__instance.deadBody.bodyAudio.PlayOneShot(Resources.RandomWilhelmAudioClip);
}
}
}