From e06461f3e2d06187ff78852d88a21f2ad002d9dd Mon Sep 17 00:00:00 2001 From: wookywok <62037083+wookywok@users.noreply.github.com> Date: Sat, 11 May 2024 21:17:46 -0500 Subject: [PATCH] ignoreSwing parameter for Multisound and BeatAction Adds a new optional parameter to Multisounds, Soundbytes, and BeatActions, allowing them to ignore swing. Currently the only game to use these new parameters is Launch Party, but whoever codes Donk-Donk in the future will have a small bit of the weight taken off their shoulders. --- .../Games/LaunchParty/LaunchPartyRocket.cs | 62 +++++++++---------- Assets/Scripts/Games/Minigame.cs | 7 ++- Assets/Scripts/Util/BeatAction.cs | 5 +- Assets/Scripts/Util/MultiSound.cs | 17 +++-- Assets/Scripts/Util/SoundByte.cs | 20 +++--- ...Generator.Editor.ProjectSettingsData.asset | 6 ++ 6 files changed, 67 insertions(+), 50 deletions(-) diff --git a/Assets/Scripts/Games/LaunchParty/LaunchPartyRocket.cs b/Assets/Scripts/Games/LaunchParty/LaunchPartyRocket.cs index 5bf6677c..680a3aff 100644 --- a/Assets/Scripts/Games/LaunchParty/LaunchPartyRocket.cs +++ b/Assets/Scripts/Games/LaunchParty/LaunchPartyRocket.cs @@ -73,10 +73,10 @@ namespace HeavenStudio.Games.Scripts_LaunchParty { new MultiSound.Sound("launchParty/rocket_prepare", beat), new MultiSound.Sound("launchParty/popper_note", beat, pitches[0]), - new MultiSound.Sound("launchParty/popper_note", beat + 0.66f, pitches[1]), - new MultiSound.Sound("launchParty/popper_note", beat + 1, pitches[2]), - new MultiSound.Sound("launchParty/popper_note", beat + 1.33f, pitches[3]), - new MultiSound.Sound("launchParty/popper_note", beat + 1.66f, pitches[4]), + new MultiSound.Sound("launchParty/popper_note", beat + 0.66f, pitches[1], ignoreSwing: true), + new MultiSound.Sound("launchParty/popper_note", beat + 1, pitches[2], ignoreSwing: true), + new MultiSound.Sound("launchParty/popper_note", beat + 1.33f, pitches[3], ignoreSwing: true), + new MultiSound.Sound("launchParty/popper_note", beat + 1.66f, pitches[4], ignoreSwing: true), }, forcePlay: true); BeatAction.New(this, new List() @@ -86,10 +86,10 @@ namespace HeavenStudio.Games.Scripts_LaunchParty number.SetActive(true); numberAnim.Play("CountFive", 0, 0); }), - new BeatAction.Action(beat + 0.66f, delegate { numberAnim.Play("CountFour", 0, 0); }), - new BeatAction.Action(beat + 1, delegate { numberAnim.Play("CountThree", 0, 0); }), - new BeatAction.Action(beat + 1.33f, delegate { numberAnim.Play("CountTwo", 0, 0); }), - new BeatAction.Action(beat + 1.66f, delegate { numberAnim.Play("CountOne", 0, 0); }), + new BeatAction.Action(beat + 0.66f, delegate { numberAnim.Play("CountFour", 0, 0); }, ignoreSwing: true), + new BeatAction.Action(beat + 1, delegate { numberAnim.Play("CountThree", 0, 0); }, ignoreSwing: true), + new BeatAction.Action(beat + 1.33f, delegate { numberAnim.Play("CountTwo", 0, 0); }, ignoreSwing: true), + new BeatAction.Action(beat + 1.66f, delegate { numberAnim.Play("CountOne", 0, 0); }, ignoreSwing: true), }); } @@ -101,12 +101,12 @@ namespace HeavenStudio.Games.Scripts_LaunchParty { new MultiSound.Sound("launchParty/rocket_prepare", beat), new MultiSound.Sound("launchParty/bell_note", beat, pitches[0]), - new MultiSound.Sound("launchParty/bell_short", beat + 1f, pitches[1]), - new MultiSound.Sound("launchParty/bell_short", beat + 1.16f, pitches[2]), - new MultiSound.Sound("launchParty/bell_short", beat + 1.33f, pitches[3]), - new MultiSound.Sound("launchParty/bell_short", beat + 1.5f, pitches[4]), - new MultiSound.Sound("launchParty/bell_short", beat + 1.66f, pitches[5]), - new MultiSound.Sound("launchParty/bell_short", beat + 1.83f, pitches[6]), + new MultiSound.Sound("launchParty/bell_short", beat + 1f, pitches[1], ignoreSwing: true), + new MultiSound.Sound("launchParty/bell_short", beat + 1.16f, pitches[2], ignoreSwing: true), + new MultiSound.Sound("launchParty/bell_short", beat + 1.33f, pitches[3], ignoreSwing: true), + new MultiSound.Sound("launchParty/bell_short", beat + 1.5f, pitches[4], ignoreSwing: true), + new MultiSound.Sound("launchParty/bell_short", beat + 1.66f, pitches[5], ignoreSwing: true), + new MultiSound.Sound("launchParty/bell_short", beat + 1.83f, pitches[6], ignoreSwing: true), }, forcePlay: true); BeatAction.New(this, new List() @@ -117,11 +117,11 @@ namespace HeavenStudio.Games.Scripts_LaunchParty numberAnim.Play("CountSeven", 0, 0); }), new BeatAction.Action(beat + 1f, delegate { numberAnim.Play("CountSix", 0, 0); }), - new BeatAction.Action(beat + 1.16f, delegate { numberAnim.Play("CountFive", 0, 0); }), - new BeatAction.Action(beat + 1.33f, delegate { numberAnim.Play("CountFour", 0, 0); }), - new BeatAction.Action(beat + 1.5f, delegate { numberAnim.Play("CountThree", 0, 0); }), - new BeatAction.Action(beat + 1.66f, delegate { numberAnim.Play("CountTwo", 0, 0); }), - new BeatAction.Action(beat + 1.83f, delegate { numberAnim.Play("CountOne", 0, 0); }), + new BeatAction.Action(beat + 1.16f, delegate { numberAnim.Play("CountFive", 0, 0); }, ignoreSwing: true), + new BeatAction.Action(beat + 1.33f, delegate { numberAnim.Play("CountFour", 0, 0); }, ignoreSwing: true), + new BeatAction.Action(beat + 1.5f, delegate { numberAnim.Play("CountThree", 0, 0); }, ignoreSwing: true), + new BeatAction.Action(beat + 1.66f, delegate { numberAnim.Play("CountTwo", 0, 0); }, ignoreSwing: true), + new BeatAction.Action(beat + 1.83f, delegate { numberAnim.Play("CountOne", 0, 0); }, ignoreSwing: true), }); } @@ -133,18 +133,18 @@ namespace HeavenStudio.Games.Scripts_LaunchParty { new MultiSound.Sound("launchParty/rocket_pin_prepare", beat), new MultiSound.Sound("launchParty/pin", beat, pitches[0]), - new MultiSound.Sound("launchParty/flute", beat, pitches[1], 0.02f), - new MultiSound.Sound("launchParty/flute", beat + 0.16f, pitches[2], 0.02f), - new MultiSound.Sound("launchParty/flute", beat + 0.33f, pitches[3], 0.06f), - new MultiSound.Sound("launchParty/flute", beat + 0.5f, pitches[4], 0.1f), - new MultiSound.Sound("launchParty/flute", beat + 0.66f, pitches[5], 0.16f), - new MultiSound.Sound("launchParty/flute", beat + 0.83f, pitches[6], 0.22f), - new MultiSound.Sound("launchParty/flute", beat + 1f, pitches[7], 0.3f), - new MultiSound.Sound("launchParty/flute", beat + 1.16f, pitches[8], 0.4f), - new MultiSound.Sound("launchParty/flute", beat + 1.33f, pitches[9], 0.6f), - new MultiSound.Sound("launchParty/flute", beat + 1.5f, pitches[10], 0.75f), - new MultiSound.Sound("launchParty/flute", beat + 1.66f, pitches[11], 0.89f), - new MultiSound.Sound("launchParty/flute", beat + 1.83f, pitches[12]), + new MultiSound.Sound("launchParty/flute", beat, pitches[1], 0.02f, ignoreSwing: true), + new MultiSound.Sound("launchParty/flute", beat + 0.16f, pitches[2], 0.02f, ignoreSwing: true), + new MultiSound.Sound("launchParty/flute", beat + 0.33f, pitches[3], 0.06f, ignoreSwing: true), + new MultiSound.Sound("launchParty/flute", beat + 0.5f, pitches[4], 0.1f, ignoreSwing: true), + new MultiSound.Sound("launchParty/flute", beat + 0.66f, pitches[5], 0.16f, ignoreSwing: true), + new MultiSound.Sound("launchParty/flute", beat + 0.83f, pitches[6], 0.22f, ignoreSwing: true), + new MultiSound.Sound("launchParty/flute", beat + 1f, pitches[7], 0.3f, ignoreSwing: true), + new MultiSound.Sound("launchParty/flute", beat + 1.16f, pitches[8], 0.4f, ignoreSwing: true), + new MultiSound.Sound("launchParty/flute", beat + 1.33f, pitches[9], 0.6f, ignoreSwing: true), + new MultiSound.Sound("launchParty/flute", beat + 1.5f, pitches[10], 0.75f, ignoreSwing: true), + new MultiSound.Sound("launchParty/flute", beat + 1.66f, pitches[11], 0.89f, ignoreSwing: true), + new MultiSound.Sound("launchParty/flute", beat + 1.83f, pitches[12], ignoreSwing: true), }, forcePlay: true); BeatAction.New(this, new List() diff --git a/Assets/Scripts/Games/Minigame.cs b/Assets/Scripts/Games/Minigame.cs index ebd55c3f..90c5e826 100644 --- a/Assets/Scripts/Games/Minigame.cs +++ b/Assets/Scripts/Games/Minigame.cs @@ -124,6 +124,7 @@ namespace HeavenStudio.Games /// Method to run if the Input has been Hit /// Method to run if the Input has been Missed /// Method to run whenever there's an Input while this is Scheduled (Shouldn't be used too much) + /// Pretty much what it says on the tin, ignores swing when active. This'll probably end up being used for a whole one game lmao /// public PlayerActionEvent ScheduleInput( double startBeat, @@ -132,7 +133,8 @@ namespace HeavenStudio.Games PlayerActionEvent.ActionEventCallbackState OnHit, PlayerActionEvent.ActionEventCallback OnMiss, PlayerActionEvent.ActionEventCallback OnBlank, - PlayerActionEvent.ActionEventHittableQuery HittableQuery = null + PlayerActionEvent.ActionEventHittableQuery HittableQuery = null, + bool ignoreSwing = false ) { // List gameSwitches = GameManager.instance.Beatmap.Entities.FindAll(c => c.beat <= startBeat + timer && c.datamodel.Split("/")[0] == "switchGame"); @@ -145,7 +147,8 @@ namespace HeavenStudio.Games PlayerActionEvent evt = evtObj.AddComponent(); - evt.startBeat = startBeat; + if (ignoreSwing) evt.startBeat = Conductor.instance.GetSwungBeat(startBeat); + else evt.startBeat = startBeat; evt.timer = timer; evt.InputAction = inputAction; evt.OnHit = OnHit; diff --git a/Assets/Scripts/Util/BeatAction.cs b/Assets/Scripts/Util/BeatAction.cs index 7ed80273..23069145 100644 --- a/Assets/Scripts/Util/BeatAction.cs +++ b/Assets/Scripts/Util/BeatAction.cs @@ -15,9 +15,10 @@ namespace HeavenStudio.Util public double beat { get; set; } public EventCallback function { get; set; } - public Action(double beat, EventCallback function) + public Action(double beat, EventCallback function, bool ignoreSwing = false) { - this.beat = beat; + if (ignoreSwing) this.beat = Conductor.instance.GetSwungBeat(beat); + else this.beat = beat; this.function = function; } } diff --git a/Assets/Scripts/Util/MultiSound.cs b/Assets/Scripts/Util/MultiSound.cs index d79143db..c6326c86 100644 --- a/Assets/Scripts/Util/MultiSound.cs +++ b/Assets/Scripts/Util/MultiSound.cs @@ -23,24 +23,27 @@ namespace HeavenStudio.Util public float volume { get; set; } public bool looping { get; set; } public double offset { get; set; } + public bool ignoreSwing {get; set; } - public Sound(string name, double beat, float pitch = 1f, float volume = 1f, bool looping = false, double offset = 0f) + public Sound(string name, double beat, float pitch = 1f, float volume = 1f, bool looping = false, double offset = 0f, bool ignoreSwing = false) { this.name = name; - this.beat = beat; + this.pitch = pitch; this.volume = volume; this.looping = looping; this.offset = offset; + if (ignoreSwing) this.beat = Conductor.instance.GetSwungBeat(beat); + else this.beat = beat; } } - public static MultiSound Play(Sound[] sounds, bool game = true, bool forcePlay = false) + public static MultiSound Play(Sound[] sounds, bool game = true, bool forcePlay = false, bool ignoreSwing = false) { - return Play(sounds.ToList(), game, forcePlay); + return Play(sounds.ToList(), game, forcePlay, ignoreSwing); } - public static MultiSound Play(List sounds, bool game = true, bool forcePlay = false) + public static MultiSound Play(List sounds, bool game = true, bool forcePlay = false, bool ignoreSwing = false) { if (Conductor.instance == null || sounds.Count < 1) return null; @@ -48,10 +51,12 @@ namespace HeavenStudio.Util MultiSound ms = go.AddComponent(); ms.sounds = sounds; - ms.startBeat = sounds[0].beat; + ms.game = game; ms.forcePlay = forcePlay; ms.commited = false; + if (ignoreSwing) ms.startBeat = Conductor.instance.GetSwungBeat(sounds[0].beat); + else ms.startBeat = sounds[0].beat; if (Conductor.instance.WaitingForDsp) { diff --git a/Assets/Scripts/Util/SoundByte.cs b/Assets/Scripts/Util/SoundByte.cs index 22260fa8..e59216f5 100644 --- a/Assets/Scripts/Util/SoundByte.cs +++ b/Assets/Scripts/Util/SoundByte.cs @@ -285,7 +285,7 @@ namespace HeavenStudio.Util /// Unpitched, non-scheduled, non-looping sounds are played using a global One-Shot audio source that doesn't create a Sound object. /// Looped sounds return their created Sound object so they can be canceled after creation. /// - public static Sound PlayOneShot(string name, double beat = -1, float pitch = 1f, float volume = 1f, bool looping = false, string game = null, double offset = 0f, bool ignoreConductorPause = false) + public static Sound PlayOneShot(string name, double beat = -1, float pitch = 1f, float volume = 1f, bool looping = false, string game = null, double offset = 0f, bool ignoreConductorPause = false, bool ignoreSwing = false) { AudioClip clip = null; string soundName = name.Split('/')[^1]; @@ -329,13 +329,14 @@ namespace HeavenStudio.Util { Sound snd = GetAvailableScheduledSound(); - snd.clip = clip; - snd.beat = beat; + snd.clip = clip; snd.pitch = pitch; snd.volume = volume; snd.looping = looping; snd.offset = offset; snd.ignoreConductorPause = ignoreConductorPause; + if (ignoreSwing) snd.beat = Conductor.instance.GetSwungBeat(beat); + else snd.beat = beat; snd.Play(); return snd; @@ -357,7 +358,7 @@ namespace HeavenStudio.Util /// /// Schedules a sound to be played at a specific time in seconds. /// - public static Sound PlayOneShotScheduled(string name, double targetTime, float pitch = 1f, float volume = 1f, bool looping = false, string game = null, bool ignoreConductorPause = false) + public static Sound PlayOneShotScheduled(string name, double targetTime, float pitch = 1f, float volume = 1f, bool looping = false, string game = null, bool ignoreConductorPause = false, bool ignoreSwing = false) { Sound snd = GetAvailableScheduledSound(); AudioClip clip = null; @@ -406,7 +407,8 @@ namespace HeavenStudio.Util snd.looping = looping; snd.scheduled = true; - snd.scheduledTime = targetTime; + if (ignoreSwing) snd.scheduledTime = Conductor.instance.GetSwungBeat(targetTime); + else snd.scheduledTime = targetTime; snd.ignoreConductorPause = ignoreConductorPause; snd.Play(); @@ -418,13 +420,13 @@ namespace HeavenStudio.Util /// Unpitched, non-scheduled, non-looping sounds are played using a global One-Shot audio source that doesn't create a Sound object. /// Looped sounds return their created Sound object so they can be canceled after creation. /// - public static Sound PlayOneShotGame(string name, double beat = -1, float pitch = 1f, float volume = 1f, bool looping = false, bool forcePlay = false, double offset = 0f, bool ignoreConductorPause = false) + public static Sound PlayOneShotGame(string name, double beat = -1, float pitch = 1f, float volume = 1f, bool looping = false, bool forcePlay = false, double offset = 0f, bool ignoreConductorPause = false, bool ignoreSwing = false) { string gameName = name.Split('/')[0]; var inf = GameManager.instance.GetGameInfo(gameName); if (GameManager.instance.currentGame == gameName || forcePlay) { - return PlayOneShot($"games/{name}", beat, pitch, volume, looping, inf.UsesAssetBundle ? gameName : null, offset, ignoreConductorPause); + return PlayOneShot($"games/{name}", beat, pitch, volume, looping, inf.UsesAssetBundle ? gameName : null, offset, ignoreConductorPause, ignoreSwing); } return null; @@ -434,13 +436,13 @@ namespace HeavenStudio.Util /// Schedules a sound to be played at a specific time in seconds. /// Audio clip is fetched from minigame resources /// - public static Sound PlayOneShotScheduledGame(string name, double targetTime, float pitch = 1f, float volume = 1f, bool looping = false, bool forcePlay = false, bool ignoreConductorPause = false) + public static Sound PlayOneShotScheduledGame(string name, double targetTime, float pitch = 1f, float volume = 1f, bool looping = false, bool forcePlay = false, bool ignoreConductorPause = false, bool ignoreSwing = false) { string gameName = name.Split('/')[0]; var inf = GameManager.instance.GetGameInfo(gameName); if (GameManager.instance.currentGame == gameName || forcePlay) { - return PlayOneShotScheduled($"games/{name}", targetTime, pitch, volume, looping, inf.UsesAssetBundle ? gameName : null, ignoreConductorPause); + return PlayOneShotScheduled($"games/{name}", targetTime, pitch, volume, looping, inf.UsesAssetBundle ? gameName : null, ignoreConductorPause, ignoreSwing); } return null; diff --git a/ProjectSettings/SatorImaging.UnitySourceGenerator.Editor.ProjectSettingsData.asset b/ProjectSettings/SatorImaging.UnitySourceGenerator.Editor.ProjectSettingsData.asset index 8a999069..0fb321ea 100644 --- a/ProjectSettings/SatorImaging.UnitySourceGenerator.Editor.ProjectSettingsData.asset +++ b/ProjectSettings/SatorImaging.UnitySourceGenerator.Editor.ProjectSettingsData.asset @@ -396,5 +396,11 @@ MonoBehaviour: - Assets/Scripts/Games/Fireworks/Fireworks.cs - Assets/X-PostProcessing/Effects/ColorAdjustmentHue/Editor/ColorAdjustmentHueEditor.cs - Assets/Scripts/Games/FlipperFlop/FlipperFlop.cs + - Assets/Scripts/Games/LoveLab/LoveLabHearts.cs + - Assets/Scripts/Games/LoveLab/LoveLab.cs + - Assets/Scripts/Games/LoveLab/LoveLabFlask.cs + - Assets/Scripts/Games/LoveLab/LoveLabHeartMisc.cs + - Assets/Scripts/Games/LaunchParty/LaunchPartyRocket.cs + - Assets/Scripts/Util/BeatAction.cs PathsToSkipImportEvent: [] PathsToIgnoreOverwriteSettingOnAttribute: []