From 987fe830c3ca2c810559e381c4576a9c418b2f8c Mon Sep 17 00:00:00 2001 From: Nikita Vilunov Date: Fri, 26 Apr 2024 23:40:35 +0200 Subject: [PATCH] fix some stuff ok? --- MuzikaGromche/Plugin.cs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/MuzikaGromche/Plugin.cs b/MuzikaGromche/Plugin.cs index 05246d3..bdbd31a 100644 --- a/MuzikaGromche/Plugin.cs +++ b/MuzikaGromche/Plugin.cs @@ -16,7 +16,7 @@ namespace MuzikaGromche { Name = "MuzikaGromche", WindUpTimer = 46.3f, - Bpm = 120f, + Bpm = 130f, }, new Track { @@ -73,6 +73,12 @@ namespace MuzikaGromche { __state = new State(); __state.prevStateindex = __instance.previousState; + if (__instance.currentBehaviourStateIndex == 2 && __instance.previousBehaviourStateIndex != 2) { + // if just popped out + // then override farAudio so that vanilla logic does not stop the music + __state.farAudio = __instance.farAudio; + __instance.farAudio = __instance.creatureVoice; + } } static List colors = [Color.magenta, Color.cyan, Color.green, Color.yellow]; @@ -100,14 +106,22 @@ namespace MuzikaGromche [HarmonyPostfix] public static void DoNotStopTheMusic(JesterAI __instance, State __state) { + if (__state.farAudio != null) + { + __instance.farAudio = __state.farAudio; + } + if (__instance.currentBehaviourStateIndex is 1 && __state.prevStateindex != 1) { + // if just started winding up + // then stop the default music... __instance.farAudio.Stop(); __instance.farAudio.Pause(); } if (__instance.currentBehaviourStateIndex is 1 && !__instance.farAudio.isPlaying) { + // ...and start modded music var seed = RoundManager.Instance.dungeonGenerator.Generator.ChosenSeed; var trackId = seed % Plugin.Tracks.Length; Debug.Log($"Seed is {seed}, chosen track is {trackId} out of {Plugin.Tracks.Length} tracks"); @@ -155,6 +169,7 @@ namespace MuzikaGromche internal class State { + public AudioSource farAudio; public int prevStateindex; } }