forked from nikita/muzika-gromche
Add debug-only synced config option to skip wind-up phase
This commit is contained in:
parent
b15e93ac34
commit
829c44e347
|
@ -304,10 +304,29 @@ namespace MuzikaGromche
|
||||||
readonly public int TotalWeights { get; }
|
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<T>(this SyncedEntry<T> entry)
|
||||||
|
{
|
||||||
|
entry.Changed += (sender, args) =>
|
||||||
|
{
|
||||||
|
args.ChangedEntry.LocalValue = args.NewValue;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public class Config : SyncedConfig2<Config>
|
public class Config : SyncedConfig2<Config>
|
||||||
{
|
{
|
||||||
|
public static bool ShouldSkipWindingPhase { get; private set; } = false;
|
||||||
|
|
||||||
public Config(ConfigFile configFile) : base(PluginInfo.PLUGIN_GUID)
|
public Config(ConfigFile configFile) : base(PluginInfo.PLUGIN_GUID)
|
||||||
{
|
{
|
||||||
|
#if DEBUG
|
||||||
|
SetupEntriesToSkipWinding(configFile);
|
||||||
|
#endif
|
||||||
|
|
||||||
var chanceRange = new AcceptableValueRange<int>(0, 100);
|
var chanceRange = new AcceptableValueRange<int>(0, 100);
|
||||||
var languageSectionButtonExists = new HashSet<Language>();
|
var languageSectionButtonExists = new HashSet<Language>();
|
||||||
|
|
||||||
|
@ -368,6 +387,20 @@ namespace MuzikaGromche
|
||||||
EntryContainer.Add(entryBase.BoxedEntry.ToSyncedEntryIdentifier(), entryBase);
|
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()
|
public static CanModifyResult CanModifyWeightsNow()
|
||||||
{
|
{
|
||||||
var startOfRound = StartOfRound.Instance;
|
var startOfRound = StartOfRound.Instance;
|
||||||
|
@ -385,6 +418,26 @@ namespace MuzikaGromche
|
||||||
}
|
}
|
||||||
return CanModifyResult.True();
|
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
|
// farAudio is during windup, Start overrides popGoesTheWeaselTheme
|
||||||
|
@ -442,6 +495,17 @@ namespace MuzikaGromche
|
||||||
__instance.farAudio.maxDistance = 150;
|
__instance.farAudio.maxDistance = 150;
|
||||||
__instance.farAudio.clip = Plugin.CurrentTrack.LoadedStart;
|
__instance.farAudio.clip = Plugin.CurrentTrack.LoadedStart;
|
||||||
__instance.farAudio.loop = false;
|
__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();
|
__instance.farAudio.Play();
|
||||||
|
|
||||||
Debug.Log($"Playing start music: maxDistance: {__instance.farAudio.maxDistance}, minDistance: {__instance.farAudio.minDistance}, volume: {__instance.farAudio.volume}, spread: {__instance.farAudio.spread}");
|
Debug.Log($"Playing start music: maxDistance: {__instance.farAudio.maxDistance}, minDistance: {__instance.farAudio.minDistance}, volume: {__instance.farAudio.volume}, spread: {__instance.farAudio.spread}");
|
||||||
|
|
Loading…
Reference in New Issue