Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of MeowF Out The Way For Bella v1.0.0
GuhBella.dll
Decompiled 5 months agousing 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.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.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("Omniscye")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("GuhBella")] [assembly: AssemblyTitle("GuhBella")] [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 GuhBella { [BepInPlugin("Empress.GuhBella", "GuhBella", "1.0.0")] public class GuhBella : BaseUnityPlugin { [CompilerGenerated] private sealed class <LoadAudioClipCoroutine>d__19 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public string fileName; public Action<AudioClip> assign; public GuhBella <>4__this; private string <fullPath>5__1; private string <uri>5__2; private AudioType <type>5__3; private UnityWebRequest <request>5__4; private AudioClip <clip>5__5; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <LoadAudioClipCoroutine>d__19(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || num == 1) { try { } finally { <>m__Finally1(); } } <fullPath>5__1 = null; <uri>5__2 = null; <request>5__4 = null; <clip>5__5 = null; <>1__state = -2; } private bool MoveNext() { //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) bool result; try { switch (<>1__state) { default: result = false; break; case 0: <>1__state = -1; if (string.IsNullOrEmpty(fileName)) { result = false; break; } <fullPath>5__1 = Path.Combine(<>4__this.pluginDirectory, fileName); if (!File.Exists(<fullPath>5__1)) { Logger.LogWarning((object)("Audio file not found: " + <fullPath>5__1)); result = false; break; } <uri>5__2 = "file://" + <fullPath>5__1.Replace("\\", "/"); <type>5__3 = <>4__this.GetAudioTypeFromExtension(Path.GetExtension(<fullPath>5__1)); <request>5__4 = UnityWebRequestMultimedia.GetAudioClip(<uri>5__2, <type>5__3); <>1__state = -3; <>2__current = <request>5__4.SendWebRequest(); <>1__state = 1; result = true; break; case 1: <>1__state = -3; if (!string.IsNullOrEmpty(<request>5__4.error)) { Logger.LogError((object)("Error loading audio " + <fullPath>5__1 + ": " + <request>5__4.error)); result = false; <>m__Finally1(); break; } <clip>5__5 = DownloadHandlerAudioClip.GetContent(<request>5__4); if ((Object)(object)<clip>5__5 != (Object)null) { ((Object)<clip>5__5).name = Path.GetFileNameWithoutExtension(<fullPath>5__1); assign(<clip>5__5); Logger.LogInfo((object)("Loaded audio clip: " + <fullPath>5__1)); } else { Logger.LogError((object)("Failed to decode audio clip: " + <fullPath>5__1)); } <clip>5__5 = null; <>m__Finally1(); <request>5__4 = null; result = false; break; } } catch { //try-fault ((IDisposable)this).Dispose(); throw; } return result; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; if (<request>5__4 != null) { ((IDisposable)<request>5__4).Dispose(); } } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private readonly List<EnemyTricycle> trackedTricycles = new List<EnemyTricycle>(); private ConfigEntry<string> localBellFile; private ConfigEntry<string> globalBellFile; private AudioClip localBellClip; private AudioClip globalBellClip; private string pluginDirectory; internal static GuhBella Instance { get; private set; } internal static ManualLogSource Logger => Instance._logger; private ManualLogSource _logger => ((BaseUnityPlugin)this).Logger; internal Harmony Harmony { get; private set; } private void Awake() { //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Expected O, but got Unknown Instance = this; ((Component)this).transform.parent = null; ((Object)((Component)this).gameObject).hideFlags = (HideFlags)61; pluginDirectory = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location) ?? Paths.PluginPath; localBellFile = ((BaseUnityPlugin)this).Config.Bind<string>("Audio", "LocalBellFile", "meow.mp3", "Local bell replacement file name"); globalBellFile = ((BaseUnityPlugin)this).Config.Bind<string>("Audio", "GlobalBellFile", "meowglobal.mp3", "Global bell replacement file name"); if (!Directory.Exists(pluginDirectory)) { Directory.CreateDirectory(pluginDirectory); } ((MonoBehaviour)this).StartCoroutine(LoadAudioClipCoroutine(localBellFile.Value, delegate(AudioClip clip) { localBellClip = clip; })); ((MonoBehaviour)this).StartCoroutine(LoadAudioClipCoroutine(globalBellFile.Value, delegate(AudioClip clip) { globalBellClip = clip; })); Harmony = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID); Harmony.PatchAll(); Logger.LogInfo((object)$"{((BaseUnityPlugin)this).Info.Metadata.GUID} v{((BaseUnityPlugin)this).Info.Metadata.Version} loaded"); } [IteratorStateMachine(typeof(<LoadAudioClipCoroutine>d__19))] private IEnumerator LoadAudioClipCoroutine(string fileName, Action<AudioClip> assign) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <LoadAudioClipCoroutine>d__19(0) { <>4__this = this, fileName = fileName, assign = assign }; } private AudioType GetAudioTypeFromExtension(string ext) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) if (string.IsNullOrEmpty(ext)) { return (AudioType)0; } ext = ext.ToLowerInvariant(); switch (ext) { case ".wav": return (AudioType)20; case ".ogg": return (AudioType)14; case ".mp3": return (AudioType)13; default: if (!(ext == ".aif")) { return (AudioType)0; } goto case ".aiff"; case ".aiff": return (AudioType)2; } } internal void RegisterTricycle(EnemyTricycle tricycle) { if (!((Object)(object)tricycle == (Object)null) && !trackedTricycles.Contains(tricycle)) { trackedTricycles.Add(tricycle); } } private void Update() { if (trackedTricycles.Count == 0) { return; } bool flag = (Object)(object)localBellClip != (Object)null; bool flag2 = (Object)(object)globalBellClip != (Object)null; for (int num = trackedTricycles.Count - 1; num >= 0; num--) { EnemyTricycle val = trackedTricycles[num]; if ((Object)(object)val == (Object)null) { trackedTricycles.RemoveAt(num); } else { if (flag && val.audioBell != null && (val.audioBell.Sounds == null || val.audioBell.Sounds.Length != 1 || (Object)(object)val.audioBell.Sounds[0] != (Object)(object)localBellClip)) { val.audioBell.Sounds = (AudioClip[])(object)new AudioClip[1] { localBellClip }; } if (flag2 && val.audioBellGlobal != null && (val.audioBellGlobal.Sounds == null || val.audioBellGlobal.Sounds.Length != 1 || (Object)(object)val.audioBellGlobal.Sounds[0] != (Object)(object)globalBellClip)) { val.audioBellGlobal.Sounds = (AudioClip[])(object)new AudioClip[1] { globalBellClip }; } } } } private void OnDestroy() { if (Harmony != null) { Harmony.UnpatchSelf(); } } } [HarmonyPatch(typeof(EnemyTricycle), "Awake")] internal static class EnemyTricycleAwakePatch { private static void Postfix(EnemyTricycle __instance) { if ((Object)(object)GuhBella.Instance != (Object)null) { GuhBella.Instance.RegisterTricycle(__instance); } } } }