day 1 TOTC patch

fix scheduled optic blast not working correctly
let multisound defer playback until conductor timekeeping is active
fix flipper flop end-of-roll calls
update kurokane modified
This commit is contained in:
minenice55 2024-01-13 13:31:05 -05:00
parent 2bace73c51
commit dde462caed
6 changed files with 66 additions and 19 deletions

View file

@ -50,6 +50,7 @@ namespace HeavenStudio
double dspSizeSeconds;
double dspMargin = 128 / 44100.0;
bool deferTimeKeeping = false;
public bool WaitingForDsp => deferTimeKeeping;
// the dspTime we started at
private double dspStart;
@ -163,6 +164,12 @@ namespace HeavenStudio
GameManager.instance.SetCurrentEventToClosest(beat);
}
public void PlaySetup(double beat)
{
deferTimeKeeping = true;
songPosBeat = beat;
}
public void Play(double beat)
{
if (isPlaying) return;
@ -220,7 +227,7 @@ namespace HeavenStudio
startTime = DateTime.Now;
absTimeAdjust = 0;
deferTimeKeeping = (musicSource.clip != null);
deferTimeKeeping = musicSource.clip != null;
isPlaying = true;
isPaused = false;

View file

@ -731,6 +731,7 @@ namespace HeavenStudio
if (!paused)
{
Conductor.instance.PlaySetup(beat);
Minigame miniGame = null;
if (currentGameO != null && currentGameO.TryGetComponent<Minigame>(out miniGame))
{

View file

@ -472,8 +472,6 @@ namespace HeavenStudio.Games
}
}
if (thatsIt && i + 1 == length)
{
int noiseToPlay = (flopCount == 4) ? 2 : flopCount;
@ -613,7 +611,7 @@ namespace HeavenStudio.Games
{
for (int i = 0; i < uh; i++)
{
int voiceLineIndex = i + 1;
int voiceLineIndex = 3 - uh + i + 1;
string voiceLine = $"flipperFlop/uh{voiceLineIndex}";
string failVoiceLine = $"flipperFlop/uhfail{voiceLineIndex}";

View file

@ -1,4 +1,3 @@
using DG.Tweening;
using NaughtyBezierCurves;
using System;
using System.Collections;
@ -169,7 +168,7 @@ namespace HeavenStudio.Games
void OnDestroy()
{
if (queuedInputs.Count > 0) queuedInputs.Clear();
queuedInputs.Clear();
foreach (var evt in scheduledInputs)
{
evt.Disable();
@ -194,14 +193,29 @@ namespace HeavenStudio.Games
girlAnim.DoScaledAnimationAsync("Bop");
}
private void Update()
public override void OnPlay(double beat)
{
var cond = Conductor.instance;
if (cond.isPlaying && !cond.isPaused)
queuedInputs.Clear();
}
public override void OnGameSwitch(double beat)
{
if (!Conductor.instance.isPlaying) return;
if (queuedInputs.Count > 0)
{
if (queuedInputs.Count > 0)
foreach (var input in queuedInputs)
{
foreach (var input in queuedInputs)
if (input.type is (int)TrickObjType.Blast)
{
BeatAction.New(instance, new List<BeatAction.Action>()
{
new BeatAction.Action(input.beat, delegate
{
instance.DoBlast(input.beat);
})
});
}
else
{
BeatAction.New(instance, new List<BeatAction.Action>()
{
@ -216,10 +230,13 @@ namespace HeavenStudio.Games
})
});
}
queuedInputs.Clear();
}
}
queuedInputs.Clear();
}
private void Update()
{
if (PlayerInput.GetIsAction(InputAction_TouchPressing) && (!playerReady) && (playerCanDodge <= Conductor.instance.songPositionInBeatsAsDouble))
{
playerAnim.DoScaledAnimationAsync("Prepare");
@ -392,11 +409,6 @@ namespace HeavenStudio.Games
{
girlAnim.DoScaledAnimationAsync("Charge1");
}),
new BeatAction.Action(beat + 2, delegate
{
//test
// girlAnim.DoScaledAnimationAsync("BlastDodged", 0.5f);
}),
new BeatAction.Action(beat + 4, delegate
{
girlBopEnable = true;

View file

@ -2,6 +2,8 @@ using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using Cysharp.Threading.Tasks;
using Cysharp.Threading.Tasks.Triggers;
namespace HeavenStudio.Util
{
@ -10,6 +12,7 @@ namespace HeavenStudio.Util
private double startBeat;
private bool game;
private bool forcePlay;
private bool commited;
public List<Sound> sounds = new List<Sound>();
public List<Util.Sound> playingSounds = new List<Util.Sound>();
@ -36,14 +39,33 @@ namespace HeavenStudio.Util
public static MultiSound Play(Sound[] snds, bool game = true, bool forcePlay = false)
{
if (Conductor.instance == null) return null;
List<Sound> sounds = snds.ToList();
GameObject go = new GameObject("MultiSound");
MultiSound ms = go.AddComponent<MultiSound>();
ms.sounds = sounds;
ms.startBeat = sounds[0].beat;
ms.game = game;
ms.forcePlay = forcePlay;
ms.commited = false;
if (Conductor.instance.WaitingForDsp)
{
Debug.Log("Multisound waiting for DSP, deferring play");
ms.PlayDeferred().Forget();
}
else
{
ms.CommitPlay();
}
return ms;
}
void CommitPlay()
{
for (int i = 0; i < sounds.Count; i++)
{
Util.Sound s;
@ -51,14 +73,21 @@ namespace HeavenStudio.Util
s = SoundByte.PlayOneShotGame(sounds[i].name, sounds[i].beat, sounds[i].pitch, sounds[i].volume, sounds[i].looping, forcePlay, sounds[i].offset);
else
s = SoundByte.PlayOneShot(sounds[i].name, sounds[i].beat, sounds[i].pitch, sounds[i].volume, sounds[i].looping, null, sounds[i].offset);
ms.playingSounds.Add(s);
playingSounds.Add(s);
}
commited = true;
}
return ms;
async UniTaskVoid PlayDeferred()
{
await UniTask.WaitUntil(() => !Conductor.instance.WaitingForDsp, PlayerLoopTiming.LastUpdate);
Debug.Log("Multisound DSP ready, playing");
CommitPlay();
}
private void Update()
{
if (!commited) return;
foreach (Util.Sound sound in playingSounds)
{
if (sound == null) continue;