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 DarkSoulsSnailStandalone v1.0.0
DarkSoulsSnailStandalone.dll
Decompiled 9 hours agousing System; 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 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("DarkSoulsSnailStandalone")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("DarkSoulsSnailStandalone")] [assembly: AssemblyTitle("DarkSoulsSnailStandalone")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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 DarkSoulsSnailStandalone { internal static class AudioLoader { public static AudioClip Load(string path) { //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Invalid comparison between Unknown and I4 if (!File.Exists(path)) { Plugin.Log.LogError((object)("Audio file not found: " + path)); return null; } AudioType val = (AudioType)(Path.GetExtension(path).ToLowerInvariant() switch { ".wav" => 20, ".ogg" => 14, ".mp3" => 13, _ => 0, }); UnityWebRequest audioClip = UnityWebRequestMultimedia.GetAudioClip("file:///" + path.Replace('\\', '/'), val); try { ((DownloadHandlerAudioClip)audioClip.downloadHandler).streamAudio = false; UnityWebRequestAsyncOperation val2 = audioClip.SendWebRequest(); while (!((AsyncOperation)val2).isDone) { } if ((int)audioClip.result != 1) { Plugin.Log.LogError((object)("Failed to load " + path + ": " + audioClip.error)); return null; } AudioClip content = DownloadHandlerAudioClip.GetContent(audioClip); ((Object)content).name = Path.GetFileNameWithoutExtension(path); return content; } finally { ((IDisposable)audioClip)?.Dispose(); } } } [BepInPlugin("com.darksoulssnail.standalone", "DarkSoulsSnailStandalone", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { internal static ManualLogSource Log; internal static ConfigEntry<string> AudioFilePath; internal static ConfigEntry<bool> PlayWhenSnailSeesTarget; internal static ConfigEntry<bool> PlayWhenLookingAtSnail; internal static ConfigEntry<float> Distance; internal static ConfigEntry<bool> PauseWhenNotLooking; internal static ConfigEntry<float> MusicVolume; internal static AudioClip BossMusic; private void Awake() { //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Expected O, but got Unknown //IL_014d: Unknown result type (might be due to invalid IL or missing references) Log = ((BaseUnityPlugin)this).Logger; AudioFilePath = ((BaseUnityPlugin)this).Config.Bind<string>("General", "AudioFilePath", "bossMusic.wav", "Audio file to play (.wav, .ogg or .mp3). Relative paths are resolved from this mod's folder."); PlayWhenSnailSeesTarget = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "PlayWhenSnailSeeTargetedPlayer", false, "Play when the snail is targeting you and can see you."); PlayWhenLookingAtSnail = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "PlayWhenLookingAtSnail", true, "Play when you can see the snail."); Distance = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Distance", 20f, "Maximum distance between you and the snail for the music to play."); PauseWhenNotLooking = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "PauseWhenNotLooking", true, "true = pause the music when the conditions stop being met, false = stop it and restart next time."); MusicVolume = ((BaseUnityPlugin)this).Config.Bind<float>("General", "MusicVolume", 1f, new ConfigDescription("Music volume.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>())); string fullPath = Path.GetFullPath(Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), AudioFilePath.Value)); BossMusic = AudioLoader.Load(fullPath); if ((Object)(object)BossMusic == (Object)null) { Log.LogError((object)("Could not load boss music from '" + fullPath + "'. The snail will be silent.")); return; } new Harmony("com.darksoulssnail.standalone").PatchAll(typeof(Plugin).Assembly); Log.LogInfo((object)$"Loaded '{Path.GetFileName(fullPath)}' ({BossMusic.length:0.0}s)."); } } internal class SnailMusicController : MonoBehaviour { private EnemyAI snail; private AudioSource source; private bool paused; private void Start() { snail = ((Component)this).GetComponent<EnemyAI>(); source = ((Component)this).gameObject.AddComponent<AudioSource>(); source.clip = Plugin.BossMusic; source.loop = true; source.playOnAwake = false; source.spatialBlend = 0f; source.volume = Plugin.MusicVolume.Value; } private void Update() { if (ShouldPlay()) { if (paused) { source.UnPause(); paused = false; } else if (!source.isPlaying) { source.Play(); } } else if (source.isPlaying) { if (Plugin.PauseWhenNotLooking.Value) { source.Pause(); paused = true; } else { source.Stop(); } } } private bool ShouldPlay() { //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) PlayerControllerB val = GameNetworkManager.Instance?.localPlayerController; if ((Object)(object)val == (Object)null || val.isPlayerDead || (Object)(object)snail == (Object)null || snail.isEnemyDead) { return false; } float value = Plugin.Distance.Value; Vector3 val2 = ((Component)snail).transform.position + Vector3.up * 0.5f; if (Vector3.Distance(((Component)val).transform.position, val2) > value) { return false; } if (Plugin.PlayWhenLookingAtSnail.Value && val.HasLineOfSightToPosition(val2, 45f, (int)value, -1f, -1)) { return true; } if (Plugin.PlayWhenSnailSeesTarget.Value && (Object)(object)snail.targetPlayer == (Object)(object)val && !Physics.Linecast(val2, ((Component)val.gameplayCamera).transform.position, StartOfRound.Instance.collidersAndRoomMaskAndDefault)) { return true; } return false; } } [HarmonyPatch(typeof(EnemyAI), "Start")] internal static class SnailPatch { private const string SnailTypeName = "ImmortalSnail.SnailAI"; [HarmonyPostfix] private static void AttachMusic(EnemyAI __instance) { if (((object)__instance).GetType().FullName == "ImmortalSnail.SnailAI" && (Object)(object)((Component)__instance).GetComponent<SnailMusicController>() == (Object)null) { ((Component)__instance).gameObject.AddComponent<SnailMusicController>(); } } } public static class MyPluginInfo { public const string PLUGIN_GUID = "com.darksoulssnail.standalone"; public const string PLUGIN_NAME = "DarkSoulsSnailStandalone"; public const string PLUGIN_VERSION = "1.0.0"; } }