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.
This commit is contained in:
wookywok 2024-05-11 21:17:46 -05:00 committed by minenice55
parent ce64c769df
commit c735ae79c0
6 changed files with 63 additions and 50 deletions

View file

@ -73,10 +73,10 @@ namespace HeavenStudio.Games.Scripts_LaunchParty
{ {
new MultiSound.Sound("launchParty/rocket_prepare", beat), new MultiSound.Sound("launchParty/rocket_prepare", beat),
new MultiSound.Sound("launchParty/popper_note", beat, pitches[0]), 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 + 0.66f, pitches[1], ignoreSwing: true),
new MultiSound.Sound("launchParty/popper_note", beat + 1, pitches[2]), new MultiSound.Sound("launchParty/popper_note", beat + 1, pitches[2], ignoreSwing: true),
new MultiSound.Sound("launchParty/popper_note", beat + 1.33f, pitches[3]), new MultiSound.Sound("launchParty/popper_note", beat + 1.33f, pitches[3], ignoreSwing: true),
new MultiSound.Sound("launchParty/popper_note", beat + 1.66f, pitches[4]), new MultiSound.Sound("launchParty/popper_note", beat + 1.66f, pitches[4], ignoreSwing: true),
}, forcePlay: true); }, forcePlay: true);
BeatAction.New(this, new List<BeatAction.Action>() BeatAction.New(this, new List<BeatAction.Action>()
@ -86,10 +86,10 @@ namespace HeavenStudio.Games.Scripts_LaunchParty
number.SetActive(true); number.SetActive(true);
numberAnim.Play("CountFive", 0, 0); numberAnim.Play("CountFive", 0, 0);
}), }),
new BeatAction.Action(beat + 0.66f, delegate { numberAnim.Play("CountFour", 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); }), 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); }), 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); }), 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/rocket_prepare", beat),
new MultiSound.Sound("launchParty/bell_note", beat, pitches[0]), 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 + 1f, pitches[1], ignoreSwing: true),
new MultiSound.Sound("launchParty/bell_short", beat + 1.16f, pitches[2]), new MultiSound.Sound("launchParty/bell_short", beat + 1.16f, pitches[2], ignoreSwing: true),
new MultiSound.Sound("launchParty/bell_short", beat + 1.33f, pitches[3]), new MultiSound.Sound("launchParty/bell_short", beat + 1.33f, pitches[3], ignoreSwing: true),
new MultiSound.Sound("launchParty/bell_short", beat + 1.5f, pitches[4]), new MultiSound.Sound("launchParty/bell_short", beat + 1.5f, pitches[4], ignoreSwing: true),
new MultiSound.Sound("launchParty/bell_short", beat + 1.66f, pitches[5]), new MultiSound.Sound("launchParty/bell_short", beat + 1.66f, pitches[5], ignoreSwing: true),
new MultiSound.Sound("launchParty/bell_short", beat + 1.83f, pitches[6]), new MultiSound.Sound("launchParty/bell_short", beat + 1.83f, pitches[6], ignoreSwing: true),
}, forcePlay: true); }, forcePlay: true);
BeatAction.New(this, new List<BeatAction.Action>() BeatAction.New(this, new List<BeatAction.Action>()
@ -117,11 +117,11 @@ namespace HeavenStudio.Games.Scripts_LaunchParty
numberAnim.Play("CountSeven", 0, 0); numberAnim.Play("CountSeven", 0, 0);
}), }),
new BeatAction.Action(beat + 1f, delegate { numberAnim.Play("CountSix", 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.16f, delegate { numberAnim.Play("CountFive", 0, 0); }, ignoreSwing: true),
new BeatAction.Action(beat + 1.33f, delegate { numberAnim.Play("CountFour", 0, 0); }), 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); }), 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); }), 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); }), 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/rocket_pin_prepare", beat),
new MultiSound.Sound("launchParty/pin", beat, pitches[0]), new MultiSound.Sound("launchParty/pin", beat, pitches[0]),
new MultiSound.Sound("launchParty/flute", beat, pitches[1], 0.02f), new MultiSound.Sound("launchParty/flute", beat, pitches[1], 0.02f, ignoreSwing: true),
new MultiSound.Sound("launchParty/flute", beat + 0.16f, pitches[2], 0.02f), 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), 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), 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), 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), 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), 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), 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), 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), 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), new MultiSound.Sound("launchParty/flute", beat + 1.66f, pitches[11], 0.89f, ignoreSwing: true),
new MultiSound.Sound("launchParty/flute", beat + 1.83f, pitches[12]), new MultiSound.Sound("launchParty/flute", beat + 1.83f, pitches[12], ignoreSwing: true),
}, forcePlay: true); }, forcePlay: true);
BeatAction.New(this, new List<BeatAction.Action>() BeatAction.New(this, new List<BeatAction.Action>()

View file

@ -124,6 +124,7 @@ namespace HeavenStudio.Games
/// <param name="OnHit">Method to run if the Input has been Hit</param> /// <param name="OnHit">Method to run if the Input has been Hit</param>
/// <param name="OnMiss">Method to run if the Input has been Missed</param> /// <param name="OnMiss">Method to run if the Input has been Missed</param>
/// <param name="OnBlank">Method to run whenever there's an Input while this is Scheduled (Shouldn't be used too much)</param> /// <param name="OnBlank">Method to run whenever there's an Input while this is Scheduled (Shouldn't be used too much)</param>
/// <param name="ignoreSwing">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</param>
/// <returns></returns> /// <returns></returns>
public PlayerActionEvent ScheduleInput( public PlayerActionEvent ScheduleInput(
double startBeat, double startBeat,
@ -132,7 +133,8 @@ namespace HeavenStudio.Games
PlayerActionEvent.ActionEventCallbackState OnHit, PlayerActionEvent.ActionEventCallbackState OnHit,
PlayerActionEvent.ActionEventCallback OnMiss, PlayerActionEvent.ActionEventCallback OnMiss,
PlayerActionEvent.ActionEventCallback OnBlank, PlayerActionEvent.ActionEventCallback OnBlank,
PlayerActionEvent.ActionEventHittableQuery HittableQuery = null PlayerActionEvent.ActionEventHittableQuery HittableQuery = null,
bool ignoreSwing = false
) )
{ {
// List<RiqEntity> gameSwitches = GameManager.instance.Beatmap.Entities.FindAll(c => c.beat <= startBeat + timer && c.datamodel.Split("/")[0] == "switchGame"); // List<RiqEntity> 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<PlayerActionEvent>(); PlayerActionEvent evt = evtObj.AddComponent<PlayerActionEvent>();
evt.startBeat = startBeat; if (ignoreSwing) evt.startBeat = Conductor.instance.GetSwungBeat(startBeat);
else evt.startBeat = startBeat;
evt.timer = timer; evt.timer = timer;
evt.InputAction = inputAction; evt.InputAction = inputAction;
evt.OnHit = OnHit; evt.OnHit = OnHit;

View file

@ -15,9 +15,10 @@ namespace HeavenStudio.Util
public double beat { get; set; } public double beat { get; set; }
public EventCallback function { 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; this.function = function;
} }
} }

View file

@ -23,24 +23,27 @@ namespace HeavenStudio.Util
public float volume { get; set; } public float volume { get; set; }
public bool looping { get; set; } public bool looping { get; set; }
public double offset { 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.name = name;
this.beat = beat;
this.pitch = pitch; this.pitch = pitch;
this.volume = volume; this.volume = volume;
this.looping = looping; this.looping = looping;
this.offset = offset; 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<Sound> sounds, bool game = true, bool forcePlay = false) public static MultiSound Play(List<Sound> sounds, bool game = true, bool forcePlay = false, bool ignoreSwing = false)
{ {
if (Conductor.instance == null || sounds.Count < 1) return null; if (Conductor.instance == null || sounds.Count < 1) return null;
@ -48,10 +51,12 @@ namespace HeavenStudio.Util
MultiSound ms = go.AddComponent<MultiSound>(); MultiSound ms = go.AddComponent<MultiSound>();
ms.sounds = sounds; ms.sounds = sounds;
ms.startBeat = sounds[0].beat;
ms.game = game; ms.game = game;
ms.forcePlay = forcePlay; ms.forcePlay = forcePlay;
ms.commited = false; ms.commited = false;
if (ignoreSwing) ms.startBeat = Conductor.instance.GetSwungBeat(sounds[0].beat);
else ms.startBeat = sounds[0].beat;
if (Conductor.instance.WaitingForDsp) if (Conductor.instance.WaitingForDsp)
{ {

View file

@ -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. /// 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. /// Looped sounds return their created Sound object so they can be canceled after creation.
/// </summary> /// </summary>
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; AudioClip clip = null;
string soundName = name.Split('/')[^1]; string soundName = name.Split('/')[^1];
@ -329,13 +329,14 @@ namespace HeavenStudio.Util
{ {
Sound snd = GetAvailableScheduledSound(); Sound snd = GetAvailableScheduledSound();
snd.clip = clip; snd.clip = clip;
snd.beat = beat;
snd.pitch = pitch; snd.pitch = pitch;
snd.volume = volume; snd.volume = volume;
snd.looping = looping; snd.looping = looping;
snd.offset = offset; snd.offset = offset;
snd.ignoreConductorPause = ignoreConductorPause; snd.ignoreConductorPause = ignoreConductorPause;
if (ignoreSwing) snd.beat = Conductor.instance.GetSwungBeat(beat);
else snd.beat = beat;
snd.Play(); snd.Play();
return snd; return snd;
@ -357,7 +358,7 @@ namespace HeavenStudio.Util
/// <summary> /// <summary>
/// Schedules a sound to be played at a specific time in seconds. /// Schedules a sound to be played at a specific time in seconds.
/// </summary> /// </summary>
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(); Sound snd = GetAvailableScheduledSound();
AudioClip clip = null; AudioClip clip = null;
@ -406,7 +407,8 @@ namespace HeavenStudio.Util
snd.looping = looping; snd.looping = looping;
snd.scheduled = true; snd.scheduled = true;
snd.scheduledTime = targetTime; if (ignoreSwing) snd.scheduledTime = Conductor.instance.GetSwungBeat(targetTime);
else snd.scheduledTime = targetTime;
snd.ignoreConductorPause = ignoreConductorPause; snd.ignoreConductorPause = ignoreConductorPause;
snd.Play(); 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. /// 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. /// Looped sounds return their created Sound object so they can be canceled after creation.
/// </summary> /// </summary>
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]; string gameName = name.Split('/')[0];
var inf = GameManager.instance.GetGameInfo(gameName); var inf = GameManager.instance.GetGameInfo(gameName);
if (GameManager.instance.currentGame == gameName || forcePlay) 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; return null;
@ -434,13 +436,13 @@ namespace HeavenStudio.Util
/// Schedules a sound to be played at a specific time in seconds. /// Schedules a sound to be played at a specific time in seconds.
/// Audio clip is fetched from minigame resources /// Audio clip is fetched from minigame resources
/// </summary> /// </summary>
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]; string gameName = name.Split('/')[0];
var inf = GameManager.instance.GetGameInfo(gameName); var inf = GameManager.instance.GetGameInfo(gameName);
if (GameManager.instance.currentGame == gameName || forcePlay) 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; return null;

View file

@ -400,5 +400,7 @@ MonoBehaviour:
- Assets/Scripts/Games/LoveLab/LoveLab.cs - Assets/Scripts/Games/LoveLab/LoveLab.cs
- Assets/Scripts/Games/LoveLab/LoveLabFlask.cs - Assets/Scripts/Games/LoveLab/LoveLabFlask.cs
- Assets/Scripts/Games/LoveLab/LoveLabHeartMisc.cs - Assets/Scripts/Games/LoveLab/LoveLabHeartMisc.cs
- Assets/Scripts/Games/LaunchParty/LaunchPartyRocket.cs
- Assets/Scripts/Util/BeatAction.cs
PathsToSkipImportEvent: [] PathsToSkipImportEvent: []
PathsToIgnoreOverwriteSettingOnAttribute: [] PathsToIgnoreOverwriteSettingOnAttribute: []