diff --git a/CHANGELOG.md b/CHANGELOG.md index 3fe7d60..fd3824f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ - Show real Artist & Song info in the config. - Added a new track Yesterday. - Added lyrics to the existing track HighLow. +- New random track will be selected every time instead of having the same track all day. + - Groupped tracks (verses of the same song) are still played together in a sequence. ## MuzikaGromche 1337.9001.68 - LocalHost hotfix diff --git a/MuzikaGromche/Plugin.cs b/MuzikaGromche/Plugin.cs index 17dcce6..65fb5cf 100644 --- a/MuzikaGromche/Plugin.cs +++ b/MuzikaGromche/Plugin.cs @@ -35,12 +35,8 @@ namespace MuzikaGromche private static int GetCurrentSeed() { - var seed = 0; - var roundManager = RoundManager.Instance; - if (roundManager != null && roundManager.dungeonGenerator != null) - { - seed = roundManager.dungeonGenerator.Generator.ChosenSeed; - } + var rng = new System.Random(unchecked((int)DateTime.Now.Ticks)); + var seed = rng.Next(); return seed; } @@ -2049,11 +2045,6 @@ namespace MuzikaGromche const string IntroAudioGameObjectName = "MuzikaGromcheAudio (Intro)"; const string LoopAudioGameObjectName = "MuzikaGromcheAudio (Loop)"; - // Number of times a selected track has been played. - // Increases by 1 with each ChooseTrackOnServer call. - // Resets on SettingChanged. - private int SelectedTrackIndex = 0; - internal IAudioTrack? CurrentTrack = null; internal BeatTimeState? BeatTimeState = null; internal AudioSource IntroAudioSource = null!; @@ -2145,7 +2136,8 @@ namespace MuzikaGromche private void ChooseTrackDeferredDelegate(object sender, EventArgs e) { - SelectedTrackIndex = 0; + HostSelectableTrack = null; + HostSelectableTrackIndex = 0; ChooseTrackDeferred(); } @@ -2226,13 +2218,25 @@ namespace MuzikaGromche } } + // Host selected this group of tracks, and + private ISelectableTrack? HostSelectableTrack = null; + + // Number of times a selected track has been played. + // Increases by 1 with each ChooseTrackOnServer call. + // Resets on SettingChanged. + private int HostSelectableTrackIndex = 0; + void ChooseTrackOnServer() { - var selectableTrack = Plugin.ChooseTrack(); - var audioTrack = selectableTrack.SelectTrack(SelectedTrackIndex); - Plugin.Log.LogInfo($"ChooseTrackOnServer {selectableTrack.Name} #{SelectedTrackIndex} {audioTrack.Name}"); + if (HostSelectableTrack == null || HostSelectableTrackIndex >= HostSelectableTrack.Count()) + { + HostSelectableTrack = Plugin.ChooseTrack(); + HostSelectableTrackIndex = 0; + } + var audioTrack = HostSelectableTrack.SelectTrack(HostSelectableTrackIndex); + Plugin.Log.LogInfo($"ChooseTrackOnServer {HostSelectableTrack.Name} #{HostSelectableTrackIndex} {audioTrack.Name}"); SetTrackClientRpc(audioTrack.Name); - SelectedTrackIndex += 1; + HostSelectableTrackIndex += 1; } void ChooseTrackCompat() diff --git a/README.md b/README.md index 98082e0..b28deb7 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ _Add some content to your Inverse teleporter experience on Titan!1_ -Muzika Gromche literally means _"crank music louder"_. This mod replaces Jester's winding up and chasing sounds with **a whole library** of timed to the beat and **seamlessly looped** popular energetic songs, combined with various **visual effects**. Song choice is random each day but **synchronized** with clients: everyone in the lobby will vibe to the same tunes, however **vanilla-compatible** client-side playback is also supported. +Muzika Gromche literally means _"crank music louder"_. This mod replaces Jester's winding up and chasing sounds with **a whole library** of timed to the beat and **seamlessly looped** popular energetic songs, combined with various **visual effects**. Song choice is random each time but **synchronized** with clients: everyone in the lobby will vibe to the same tunes, however **vanilla-compatible** client-side playback is also supported. A demo video is worth a thousand words. Check out what Muzika Gromche does: