From 829c44e347a527520ae407b7bbf3d0d05ca5b4bf Mon Sep 17 00:00:00 2001 From: ivan tkachenko Date: Wed, 16 Jul 2025 03:06:42 +0300 Subject: [PATCH] Add debug-only synced config option to skip wind-up phase --- MuzikaGromche/Plugin.cs | 64 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/MuzikaGromche/Plugin.cs b/MuzikaGromche/Plugin.cs index a7c81e6..8656e96 100644 --- a/MuzikaGromche/Plugin.cs +++ b/MuzikaGromche/Plugin.cs @@ -304,10 +304,29 @@ namespace MuzikaGromche readonly public int TotalWeights { get; } } + public static class SyncedEntryExtensions + { + // Update local values on clients. Even though the clients couldn't + // edit them, they could at least see the new values. + public static void SyncHostToLocal(this SyncedEntry entry) + { + entry.Changed += (sender, args) => + { + args.ChangedEntry.LocalValue = args.NewValue; + }; + } + } + public class Config : SyncedConfig2 { + public static bool ShouldSkipWindingPhase { get; private set; } = false; + public Config(ConfigFile configFile) : base(PluginInfo.PLUGIN_GUID) { +#if DEBUG + SetupEntriesToSkipWinding(configFile); +#endif + var chanceRange = new AcceptableValueRange(0, 100); var languageSectionButtonExists = new HashSet(); @@ -368,6 +387,20 @@ namespace MuzikaGromche EntryContainer.Add(entryBase.BoxedEntry.ToSyncedEntryIdentifier(), entryBase); } + public static CanModifyResult CanModifyIfHost() + { + var startOfRound = StartOfRound.Instance; + if (!startOfRound) + { + return CanModifyResult.True(); // Main menu + } + if (!startOfRound.IsHost) + { + return CanModifyResult.False("Only for host"); + } + return CanModifyResult.True(); + } + public static CanModifyResult CanModifyWeightsNow() { var startOfRound = StartOfRound.Instance; @@ -385,6 +418,26 @@ namespace MuzikaGromche } return CanModifyResult.True(); } + + private void SetupEntriesToSkipWinding(ConfigFile configFile) + { + var syncedEntry = configFile.BindSyncedEntry("General", "Skip Winding Phase", false, + new ConfigDescription("Skip most of the wind-up/intro/start music.\n\nUse this option to test your Loop audio segment.")); + LethalConfigManager.AddConfigItem(new BoolCheckBoxConfigItem(syncedEntry.Entry, new BoolCheckBoxOptions + { + RequiresRestart = false, + CanModifyCallback = CanModifyIfHost, + })); + CSyncHackAddSyncedEntry(syncedEntry); + syncedEntry.Changed += (sender, args) => apply(); + syncedEntry.SyncHostToLocal(); + apply(); + + void apply() + { + ShouldSkipWindingPhase = syncedEntry.Value; + } + } } // farAudio is during windup, Start overrides popGoesTheWeaselTheme @@ -442,6 +495,17 @@ namespace MuzikaGromche __instance.farAudio.maxDistance = 150; __instance.farAudio.clip = Plugin.CurrentTrack.LoadedStart; __instance.farAudio.loop = false; + if (Config.ShouldSkipWindingPhase) + { + var rewind = 5f; + __instance.popUpTimer = rewind; + __instance.farAudio.time = Plugin.CurrentTrack.WindUpTimer - rewind; + } + else + { + // reset if previously skipped winding by assigning different starting time. + __instance.farAudio.time = 0; + } __instance.farAudio.Play(); Debug.Log($"Playing start music: maxDistance: {__instance.farAudio.maxDistance}, minDistance: {__instance.farAudio.minDistance}, volume: {__instance.farAudio.volume}, spread: {__instance.farAudio.spread}");