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 NutcrackerSoundDistanceIncreaser v1.1.0
NutcrackerSoundRange.dll
Decompiled 3 hours agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using HarmonyLib; 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(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("NutcrackerSoundRange")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("NutcrackerSoundRange")] [assembly: AssemblyTitle("NutcrackerSoundRange")] [assembly: AssemblyVersion("1.0.0.0")] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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] [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; } } } namespace NutcrackerSoundRange { [BepInPlugin("gungabunga.nutcrackersounddistanceincreaser", "Nutcracker sound distance increaser", "1.1.0")] public class NutcrackerSoundRangePlugin : BaseUnityPlugin { internal static NutcrackerSoundRangePlugin? Instance; private ConfigEntry<float> MusicMultiplier = null; private ConfigEntry<float> GunMultiplier = null; private ConfigEntry<bool> DebugLogging = null; private Harmony harmony = null; private readonly Dictionary<AudioSource, float> originalDistances = new Dictionary<AudioSource, float>(); private void Awake() { //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Expected O, but got Unknown Instance = this; MusicMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Sound Distances", "Music Multiplier", 3f, "Distance multiplier for music that plays when nutcracker chases you aka the music all the nutcracker audio mods change."); GunMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Sound Distances", "Shotgun Sound Multiplier", 3f, "Distance multiplier for nutcracker shotgun sound. Important if you want to also hear shotgun when running away (which you do)."); DebugLogging = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "DebugLogging", false, "Enable logging when Nutcracker audio distances are changed."); harmony = new Harmony("gungabunga.nutcrackersounddistanceincreaser"); harmony.PatchAll(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Nutcracker Sound Range 1.1.0 loaded."); } internal void ApplyDistance(AudioSource source, float multiplier, string category) { if (!((Object)(object)source == (Object)null)) { if (!originalDistances.ContainsKey(source)) { originalDistances[source] = source.maxDistance; } float num = originalDistances[source]; multiplier = Mathf.Max(0f, multiplier); source.maxDistance = num * multiplier; if (DebugLogging.Value) { ((BaseUnityPlugin)this).Logger.LogInfo((object)(category + " distance updated. Original: " + num + ", New: " + source.maxDistance)); } } } internal void ApplyMusic(AudioSource source) { ApplyDistance(source, MusicMultiplier.Value, "Nutcracker music"); } internal void ApplyGun(AudioSource source) { ApplyDistance(source, GunMultiplier.Value, "Nutcracker shotgun"); } private void OnDestroy() { foreach (KeyValuePair<AudioSource, float> originalDistance in originalDistances) { if ((Object)(object)originalDistance.Key != (Object)null) { originalDistance.Key.maxDistance = originalDistance.Value; } } originalDistances.Clear(); if (harmony != null) { Harmony obj = harmony; if (obj != null) { obj.UnpatchSelf(); } } Instance = null; ((BaseUnityPlugin)this).Logger.LogInfo((object)"Nutcracker Sound Range unloaded. Original distances restored."); } } [HarmonyPatch(typeof(NutcrackerEnemyAI), "Start")] internal static class NutcrackerStartPatch { private static void Postfix(NutcrackerEnemyAI __instance) { if (!((Object)(object)__instance == (Object)null) && !((Object)(object)NutcrackerSoundRangePlugin.Instance == (Object)null)) { NutcrackerSoundRangePlugin.Instance.ApplyMusic(((EnemyAI)__instance).creatureVoice); } } } [HarmonyPatch(typeof(ShotgunItem), "GrabItemFromEnemy")] internal static class NutcrackerShotgunPatch { private static void Postfix(ShotgunItem __instance, EnemyAI __0) { if (!((Object)(object)__instance == (Object)null) && !((Object)(object)__0 == (Object)null) && __0 is NutcrackerEnemyAI && !((Object)(object)NutcrackerSoundRangePlugin.Instance == (Object)null)) { NutcrackerSoundRangePlugin.Instance.ApplyGun(__instance.gunShootAudio); } } } }