using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.Networking;
using UnityEngine.SceneManagement;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("BananaSlip")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("BananaSlip")]
[assembly: AssemblyCopyright("Copyright © 2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("762b84c5-2944-4cd0-9056-c0ba62e6e831")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")]
[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.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace BananaSlip
{
[BepInPlugin("doomahreal.ultrakill.BananaSlip", "BananaSlip", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
[HarmonyPatch(typeof(EnemyIdentifier), "Death")]
[HarmonyPatch(new Type[] { typeof(bool) })]
public static class DeathPatch
{
public static List<EnemyIdentifier> alreadyDead = new List<EnemyIdentifier>();
[HarmonyPostfix]
public static void Postfix(EnemyIdentifier __instance, bool fromExplosion)
{
if (!alreadyDead.Contains(__instance))
{
alreadyDead.Add(__instance);
PlayCustomDeathSound(__instance);
}
}
private static void PlayCustomDeathSound(EnemyIdentifier enemy)
{
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Expected O, but got Unknown
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
if (audioClips.Count != 0)
{
int index = Random.Range(0, audioClips.Count);
AudioClip val = audioClips[index];
if (!((Object)(object)val == (Object)null))
{
GameObject val2 = new GameObject(((Object)enemy).name + " CUSTOM DEATH SFX");
AudioSource val3 = val2.AddComponent<AudioSource>();
val3.clip = val;
val2.AddComponent<RemoveOnTime>().useAudioLength = true;
val3.Play();
val2.transform.position = ((Component)enemy).transform.position;
val3.spatialBlend = 1f;
val3.rolloffMode = (AudioRolloffMode)1;
val3.minDistance = 1024f;
val3.maxDistance *= 8f;
val3.volume = 0.45f;
val2.transform.parent = ((Component)enemy).transform;
}
}
}
}
private const string modGUID = "doomahreal.ultrakill.BananaSlip";
private const string modName = "BananaSlip";
private const string modVersion = "1.0.0";
private static readonly Harmony Harmony = new Harmony("doomahreal.ultrakill.BananaSlip");
private static List<AudioClip> audioClips = new List<AudioClip>();
private void Awake()
{
Harmony.PatchAll();
LoadAudioClips();
SceneManager.sceneLoaded += OnSceneLoaded;
}
private void LoadAudioClips()
{
string path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location));
if (!Directory.Exists(path))
{
return;
}
string[] files = Directory.GetFiles(path);
string[] array = files;
foreach (string path2 in array)
{
AudioClip val = LoadClipFromPath(path2);
if (!((Object)(object)val == (Object)null))
{
audioClips.Add(val);
}
}
Debug.Log((object)$"Loaded {audioClips.Count} audio clips.");
}
private static AudioClip LoadClipFromPath(string path)
{
if (!File.Exists(path))
{
return null;
}
string text = Path.GetExtension(path).ToLower();
if (text != ".wav" && text != ".mp3" && text != ".ogg")
{
return null;
}
UnityWebRequest audioClip = UnityWebRequestMultimedia.GetAudioClip("file://" + path, (AudioType)0);
audioClip.SendWebRequest();
while (!audioClip.isDone)
{
}
AudioClip content = DownloadHandlerAudioClip.GetContent(audioClip);
if ((Object)(object)content == (Object)null)
{
return null;
}
((Object)content).name = "CUSTOMSFX " + Path.GetFileNameWithoutExtension(path);
return content;
}
private static void OnSceneLoaded(Scene scene, LoadSceneMode mode)
{
DeathPatch.alreadyDead.Clear();
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "BananaSlip";
public const string PLUGIN_NAME = "BananaSlip";
public const string PLUGIN_VERSION = "1.0.0";
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
internal IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}