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 GachiSnailMusic v1.0.1
plugins/GachiSnailMusic/GachiSnailMusic.dll
Decompiled a year agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.ExceptionServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Threading.Tasks; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using GachiSnailMusic; using HarmonyLib; using LCSoundTool; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETFramework,Version=v4.7.1", FrameworkDisplayName = ".NET Framework 4.7.1")] [assembly: AssemblyCompany("GachiSnailMusic")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("Gachi Snail Music")] [assembly: AssemblyTitle("GachiSnailMusic")] [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 GachiSnailMusic { [BepInPlugin("GachiSnailMusic", "Gachi Snail Music", "1.0.0")] public class Plugin : BaseUnityPlugin { private readonly Harmony harmony = new Harmony("Snowlance.SoThisIsImmortalSnail"); public static string ProjectNamespace = "GachiSnailMusic"; public static ConfigEntry<float> configVolume; public static ConfigEntry<int> configDistance; public static List<AudioClip> LoadedMusic = new List<AudioClip>(); public static Plugin PluginInstance { get; private set; } public static ManualLogSource LoggerInstance { get; private set; } private async Task WaitForLcSound() { while (!Chainloader.PluginInfos.ContainsKey("LCSoundTool")) { await Task.Delay(1000); } LoggerInstance.LogInfo((object)"LCSoundTool found!"); } [HandleProcessCorruptedStateExceptions] private async void Awake() { if ((Object)(object)PluginInstance == (Object)null) { PluginInstance = this; } LoggerInstance = ((BaseUnityPlugin)PluginInstance).Logger; await WaitForLcSound(); LoggerInstance.LogInfo((object)"Plugin SoThisIsImmortalSnail loaded successfully."); configVolume = ((BaseUnityPlugin)this).Config.Bind<float>("Volume", "MusicVolume", 0.3f, "Volume of the music. Must be between 0 and 1."); LoggerInstance.LogInfo((object)"configVolume"); configDistance = ((BaseUnityPlugin)this).Config.Bind<int>("Sound Mechanic", "Distance", 30, "Play the music only when the player is looking at a certain distance of the snail."); LoggerInstance.LogInfo((object)"configDistance"); string MusicDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); LoggerInstance.LogInfo((object)("Target Music Directory : " + MusicDirectory)); string[] files = Directory.GetFiles(MusicDirectory); foreach (string filepath in files) { if (filepath.EndsWith(".mp3")) { string soundname = filepath.Split(new char[1] { '\\' })[^1]; LoggerInstance.LogInfo((object)("Loading Music :" + soundname)); LoadedMusic.Add(SoundTool.GetAudioClip(MusicDirectory, soundname)); LoggerInstance.LogInfo((object)("Music Loaded :" + soundname)); } } LoggerInstance.LogDebug((object)"Pre PATCH"); harmony.PatchAll(); LoggerInstance.LogInfo((object)"Snowlance.SoThisIsImmortalSnail v1.0.0 has loaded!"); } } public static class MyPluginInfo { public const string PLUGIN_GUID = "GachiSnailMusic"; public const string PLUGIN_NAME = "Gachi Snail Music"; public const string PLUGIN_VERSION = "1.0.0"; } } namespace SoThisIsImmortalSnail.Patches { [HarmonyPatch] internal class SnailAIPatch { private static Type targetType = AccessTools.TypeByName("ImmortalSnail.SnailAI"); private static ManualLogSource LoggerInstance = Plugin.LoggerInstance; [HarmonyPatch(typeof(EnemyAI), "Start")] [HarmonyPostfix] private static void StartPatch(object __instance) { if (!(__instance.GetType() != targetType)) { GameObject value = Traverse.Create(__instance).Property("gameObject", (object[])null).GetValue<GameObject>(); if ((Object)(object)value == (Object)null) { LoggerInstance.LogError((object)"SnailAI::Start -> gameObject is null!"); } else if (!((Object)(object)value == (Object)null)) { AudioSource val = value.AddComponent<AudioSource>(); Random random = new Random(); val.clip = Plugin.LoadedMusic[random.Next(Plugin.LoadedMusic.Count)]; val.loop = true; val.volume = Plugin.configVolume.Value; val.spatialBlend = 1f; val.minDistance = 1f; val.maxDistance = Plugin.configDistance.Value; val.rolloffMode = (AudioRolloffMode)1; val.Play(); } } } } }