using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.Networking;
using fallsound.Objects;
using fallsound.Patches;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: AssemblyCompany("fallsound")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("fallsound")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("fallsound")]
[assembly: AssemblyTitle("fallsound")]
[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;
}
}
}
public static class CoroutineHelper
{
private class CoroutineRunner : MonoBehaviour
{
}
private static GameObject coroutineObject;
public static void StartCoroutine(IEnumerator coroutine)
{
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Expected O, but got Unknown
if ((Object)(object)coroutineObject == (Object)null)
{
coroutineObject = new GameObject("CoroutineHelper");
Object.DontDestroyOnLoad((Object)(object)coroutineObject);
}
((MonoBehaviour)coroutineObject.AddComponent<CoroutineRunner>()).StartCoroutine(coroutine);
}
}
namespace fallsound
{
[BepInPlugin("fallsound", "fallsound", "1.0.0")]
public class fallsound : BaseUnityPlugin
{
private const string modGUID = "fallsound";
private const string modName = "fallsound";
private const string modVersion = "1.0.0";
private readonly Harmony harmony = new Harmony("fallsound");
public static fallsound instance;
internal ManualLogSource mls;
private void Awake()
{
instance = this;
Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
if ((Object)(object)instance == (Object)null)
{
instance = this;
Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
}
if ((Object)(object)instance == (Object)null)
{
}
harmony.PatchAll(typeof(fallsound));
harmony.PatchAll(typeof(FallvoidPatch));
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "fallsound";
public const string PLUGIN_NAME = "fallsound";
public const string PLUGIN_VERSION = "1.0.0";
}
}
namespace fallsound.Patches
{
[HarmonyPatch(typeof(PlayerControllerB))]
internal class FallvoidPatch : HarmonyPatch
{
public static List<PlayerSoundStatus> playerSoundStatusList = new List<PlayerSoundStatus>();
public static AudioClip newSFX;
private static ManualLogSource mls;
[HarmonyPatch("Start")]
[HarmonyPostfix]
private static void startEventListener()
{
if ((Object)(object)fallsound.instance != (Object)null)
{
string location = ((BaseUnityPlugin)fallsound.instance).Info.Location;
string text = "fallsound.dll";
string text2 = location.TrimEnd(text.ToCharArray());
string text3 = text2 + "fallsound.wav";
((MonoBehaviour)fallsound.instance).StartCoroutine(LoadAudio("file:///" + text3, delegate(AudioClip sound)
{
newSFX = sound;
}));
}
else
{
string location2 = Assembly.GetExecutingAssembly().Location;
string directoryName = Path.GetDirectoryName(location2);
string text4 = Path.Combine(directoryName, "fallsound.wav");
CoroutineHelper.StartCoroutine(LoadAudio("file:///" + text4, delegate(AudioClip sound)
{
newSFX = sound;
}));
}
}
public static IEnumerator LoadAudio(string url, Action<AudioClip> callback)
{
UnityWebRequest www = UnityWebRequestMultimedia.GetAudioClip(url, (AudioType)20);
try
{
yield return www.SendWebRequest();
if ((int)www.result != 2)
{
AudioClip clip = DownloadHandlerAudioClip.GetContent(www);
if (!((Object)(object)clip == (Object)null))
{
callback(clip);
}
}
}
finally
{
((IDisposable)www)?.Dispose();
}
}
[HarmonyPatch("Update")]
[HarmonyPostfix]
private static void SoundVoidPatch(ref PlayerControllerB __instance)
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
PlayerControllerB val = __instance;
PlayerSoundStatus item = new PlayerSoundStatus(val);
CauseOfDeath causeOfDeath = val.causeOfDeath;
if ((Object)(object)__instance == (Object)null)
{
return;
}
if (val.isPlayerDead && (int)causeOfDeath == 2)
{
if (!playerSoundStatusList.Contains(item))
{
playerSoundStatusList.Add(item);
return;
}
item = playerSoundStatusList[playerSoundStatusList.IndexOf(item)];
if (!item._status)
{
AudioSource val2 = ((Component)val).gameObject.AddComponent<AudioSource>();
val2.clip = newSFX;
((Component)val2).transform.position = ((Component)val).transform.position;
val2.rolloffMode = (AudioRolloffMode)1;
val2.maxDistance = 30f;
val2.minDistance = 1f;
val2.Play();
item._status = true;
}
}
else if (!val.isPlayerDead && playerSoundStatusList.IndexOf(item) != -1)
{
playerSoundStatusList.Remove(item);
}
}
}
}
namespace fallsound.Objects
{
internal class PlayerSoundStatus
{
public bool _status;
public PlayerControllerB _player;
public bool Status
{
get
{
return _status;
}
set
{
_status = value;
}
}
private PlayerControllerB Player
{
get
{
return _player;
}
set
{
_player = value;
}
}
public PlayerSoundStatus(PlayerControllerB player)
{
Player = player;
Status = false;
}
public override bool Equals(object obj)
{
if (obj == null || GetType() != obj.GetType())
{
return false;
}
PlayerSoundStatus playerSoundStatus = (PlayerSoundStatus)obj;
return ((object)Player).Equals((object?)playerSoundStatus.Player);
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}