Please disclose if your mod was created primarily 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 SevenNationLoudHorn v1.0.2
SevenNationArmyLoudHorn.dll
Decompiled 2 years agousing System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Logging; using HarmonyLib; using SevenNationArmyLoudHorn.Patches; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("SevenNationArmyLoudHorn")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("SevenNationArmyLoudHorn")] [assembly: AssemblyCopyright("Copyright © 2023")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("98dad24a-bb0f-47b4-ac67-7cea4290aa6a")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyVersion("1.0.0.0")] namespace SevenNationArmyLoudHorn { [BepInPlugin("AA24.LoudHorn", "SNA Loud Horn", "1.0.1")] public class Base : BaseUnityPlugin { private const string modGUID = "AA24.LoudHorn"; private const string modName = "SNA Loud Horn"; private const string modVersion = "1.0.1"; private readonly Harmony harmony = new Harmony("AA24.LoudHorn"); public static Base Instance; internal ManualLogSource mls; public float lastBlaringTime = 0f; public static float songTime = 0f; public float dontChangeNoteDelay = 2f; public static float currentNote = 1f; public static float targetNote = 0f; public static float lerpPerSecond = 1.75f; private void Awake() { if ((Object)(object)Instance == (Object)null) { Instance = this; } mls = Logger.CreateLogSource("AA24.LoudHorn"); mls.LogMessage((object)"Initiialized SNArmy mod"); harmony.PatchAll(typeof(Base)); harmony.PatchAll(typeof(PitchShiftPatch)); } } } namespace SevenNationArmyLoudHorn.Patches { [HarmonyPatch(typeof(ShipAlarmCord))] internal class PitchShiftPatch { [HarmonyPatch("Update")] [HarmonyPostfix] private static void patchUpdate(ref AudioSource ___hornClose, ref AudioSource ___hornFar, ref bool ___hornBlaring) { Base.songTime += Time.deltaTime; ___hornClose.pitch = Base.targetNote; ___hornFar.pitch = Base.targetNote; if (___hornBlaring) { Base instance = Base.Instance; if (Time.time - instance.lastBlaringTime > instance.dontChangeNoteDelay || Base.songTime > 7.5f) { Base.songTime = 0f; } Base.targetNote = Mathf.Pow(2f, GetNote(Base.songTime) / 12f); Base.currentNote = GetNote(Base.songTime); Base.Instance.mls.LogInfo((object)("Current song time is " + Base.songTime)); Base.Instance.mls.LogInfo((object)("Changing pitch to " + Base.currentNote)); instance.lastBlaringTime = Time.time; } } private static float GetNote(float time) { if (time < 1.5f) { return -4f; } if (1.5f <= time && time < 2.25f) { return -1f; } if (2.25f <= time && time < 3f) { return -4f; } if (3f <= time && time < 3.5f) { return -6f; } if (3.5f <= time && time < 5.5f) { return -8f; } if (5.5f <= time) { return -9f; } Base.Instance.mls.LogError((object)"Time is out of range"); return 0f; } private static float LerpNotes() { if (Mathf.Abs(Base.targetNote - Base.currentNote) < Base.lerpPerSecond * Time.deltaTime) { return Base.targetNote; } if (Base.currentNote < Base.targetNote) { return Base.currentNote + Base.lerpPerSecond * Time.deltaTime; } if (Base.currentNote > Base.targetNote) { return Base.currentNote - Base.lerpPerSecond * Time.deltaTime; } return Base.targetNote; } } }