using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; 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("TacoDeathBell")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("TacoDeathBell")] [assembly: AssemblyTitle("TacoDeathBell")] [assembly: AssemblyVersion("1.0.0.0")] [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 TacoDeathBell { [HarmonyPatch(typeof(Character), "RPCA_Die")] public static class PatchCharacterDie { private static void Postfix() { //IL_0074: Unknown result type (might be due to invalid IL or missing references) try { if ((Object)(object)Plugin.DeathBell == (Object)null || Plugin.DeathBell.clips == null || Plugin.DeathBell.clips.Length == 0) { return; } float time = Time.time; if (time - Plugin.lastPlayTime < Plugin.BoundConfig.MinRepeatGap.Value) { return; } Plugin.lastPlayTime = time; Plugin.DeathBell.settings.volume = Plugin.BoundConfig.SFXVolume.Value; Plugin.DeathBell.Play(Vector3.zero); if (Plugin.BoundConfig.DebugLogging.Value) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogInfo((object)"Death bell triggered"); } } } catch (Exception arg) { ManualLogSource log2 = Plugin.Log; if (log2 != null) { log2.LogError((object)$"TacoDeathBell patch error: {arg}"); } } } } public class ModConfig { public readonly ConfigEntry SFXVolume; public readonly ConfigEntry MinRepeatGap; public readonly ConfigEntry DebugLogging; public ModConfig(ConfigFile cfg) { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Expected O, but got Unknown //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Expected O, but got Unknown cfg.SaveOnConfigSet = false; SFXVolume = cfg.Bind("General", "Death Bell Volume", 1f, new ConfigDescription("Volume of the death bell sound.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 1f), Array.Empty())); MinRepeatGap = cfg.Bind("General", "Min Repeat Gap", 1f, new ConfigDescription("Minimum seconds between death bell sounds.", (AcceptableValueBase)(object)new AcceptableValueRange(0.1f, 20f), Array.Empty())); DebugLogging = cfg.Bind("Debug", "Debug Logging", false, "Enable extra log messages."); ClearOrphanedEntries(cfg); cfg.Save(); cfg.SaveOnConfigSet = true; } private static void ClearOrphanedEntries(ConfigFile cfg) { ((Dictionary)AccessTools.Property(typeof(ConfigFile), "OrphanedEntries").GetValue(cfg)).Clear(); } } [BepInPlugin("TacoDeathBell", "TacoDeathBell", "1.0.0")] public class Plugin : BaseUnityPlugin { public const string Id = "TacoDeathBell"; internal static SFX_Instance DeathBell; internal static float lastPlayTime = -999f; private readonly Harmony harmony = new Harmony("TacoDeathBell"); private const int SFXLimit = 10; internal static ManualLogSource Log { get; private set; } internal static Plugin Instance { get; private set; } internal static ModConfig BoundConfig { get; private set; } private void Awake() { if ((Object)(object)Instance != (Object)null && (Object)(object)Instance != (Object)(object)this) { Object.Destroy((Object)(object)this); return; } Instance = this; Log = ((BaseUnityPlugin)this).Logger; BoundConfig = new ModConfig(((BaseUnityPlugin)this).Config); LoadDeathBell(); harmony.PatchAll(); Log.LogInfo((object)"TacoDeathBell loaded."); } private void LoadDeathBell() { //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Expected O, but got Unknown string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); List list = Directory.GetFiles(directoryName, "*.wav").Take(10).ToList(); if (list.Count == 0) { Log.LogWarning((object)("No .wav files found in " + directoryName)); return; } List list2 = new List(); foreach (string item in list) { try { AudioClip val = LoadAudioClip(item); if ((Object)(object)val != (Object)null) { list2.Add(val); if (BoundConfig.DebugLogging.Value) { Log.LogInfo((object)("Loaded death bell clip: " + Path.GetFileName(item))); } } } catch (Exception ex) { Log.LogError((object)("Failed to load sound file " + item + ": " + ex.Message)); } } if (list2.Count == 0) { Log.LogError((object)"No death bell audio clips were loaded."); return; } DeathBell = ScriptableObject.CreateInstance(); DeathBell.clips = list2.ToArray(); DeathBell.settings = new SFX_Settings { volume = BoundConfig.SFXVolume.Value, spatialBlend = 0f }; Log.LogInfo((object)$"Created death bell SFX with {list2.Count} clip(s)."); } private AudioClip LoadAudioClip(string filePath) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Invalid comparison between Unknown and I4 //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Invalid comparison between Unknown and I4 UnityWebRequest audioClip = UnityWebRequestMultimedia.GetAudioClip(new Uri(filePath).AbsoluteUri, (AudioType)20); try { UnityWebRequestAsyncOperation val = audioClip.SendWebRequest(); while (!((AsyncOperation)val).isDone) { } if ((int)audioClip.result == 2 || (int)audioClip.result == 3) { Log.LogError((object)("Error loading " + filePath + ": " + audioClip.error)); return null; } return DownloadHandlerAudioClip.GetContent(audioClip); } finally { ((IDisposable)audioClip)?.Dispose(); } } } }