Stomp: Fixed issues associated with specific cue setups.

This commit is contained in:
Jenny Crowe 2022-03-13 03:25:41 -07:00
parent 5a9cf5507a
commit 3a6df6035b

View file

@ -24,6 +24,7 @@ namespace RhythmHeavenMania.Games
private int currentMarchBeat;
private int stepCount;
private bool isStepping;
private static float inactiveStart = -1f;
public bool isMarching => marchStartBeat != -1f;
@ -66,10 +67,11 @@ namespace RhythmHeavenMania.Games
var cond = Conductor.instance;
var entities = GameManager.instance.Beatmap.entities;
// Find the beat of the closest "start marching" event.
// If not found, default to current beat.
float startBeat = cond.songPositionInBeats;
if (inactiveStart == -1f)
{
// Find the beat of the closest "start marching" event.
var marchStarts = entities.FindAll(m => m.datamodel == "cropStomp/start marching");
for (int i = 0; i < marchStarts.Count; i++)
{
@ -80,6 +82,33 @@ namespace RhythmHeavenMania.Games
break;
}
}
}
else
{
// Find the beat of the next step, assuming marching started at inactiveStart.
int stepsPassed = 0;
while (inactiveStart + (stepsPassed * 2f) < cond.songPositionInBeats)
{
stepsPassed++;
if (stepsPassed > 1000)
{
Debug.Log("Loop broke!");
return;
}
}
startBeat = inactiveStart + (stepsPassed * 2f);
// Cue the marching proper to begin when applicable.
BeatAction.New(gameObject, new List<BeatAction.Action>()
{
new BeatAction.Action(startBeat, delegate { StartMarching(startBeat); })
});
inactiveStart = -1f;
}
// Veggie and mole events.
var vegEvents = entities.FindAll(v => v.datamodel == "cropStomp/veggies");
@ -92,14 +121,14 @@ namespace RhythmHeavenMania.Games
var vegLength = vegEvents[i].length;
// Only consider veggie events that aren't past the start point.
if (startBeat < vegBeat + vegLength)
if (startBeat <= vegBeat + vegLength)
{
int veggiesInEvent = Mathf.CeilToInt(vegLength + 1) / 2;
for (int b = 0; b < veggiesInEvent; b++)
{
var targetVeggieBeat = vegBeat + 2f * b;
if (startBeat < targetVeggieBeat)
if (startBeat <= targetVeggieBeat)
{
SpawnVeggie(targetVeggieBeat, startBeat, false);
}
@ -112,28 +141,13 @@ namespace RhythmHeavenMania.Games
{
var moleBeat = moleEvents[i].beat;
if (startBeat < moleBeat)
if (startBeat <= moleBeat)
{
SpawnVeggie(moleBeat, startBeat, true);
}
}
}
public override void OnGameSwitch(float beat)
{
if(inactiveStart != -1f)
{
StartMarching(inactiveStart);
float diff = beat - marchStartBeat;
newBeat = (Mathf.Ceil(diff) + marchStartBeat-1)*Conductor.instance.secPerBeat;
currentMarchBeat = Mathf.CeilToInt(diff);
stepCount = currentMarchBeat / 2;
farmer.nextStompBeat = newBeat/Conductor.instance.secPerBeat;
inactiveStart = -1f;
PlayAnims();
}
}
List<Beatmap.Entity> cuedMoleSounds = new List<Beatmap.Entity>();
private void Update()
{
@ -148,7 +162,7 @@ namespace RhythmHeavenMania.Games
{
var moleEvent = moleEvents[i];
var timeToEvent = moleEvent.beat - cond.songPositionInBeats;
if (timeToEvent <= 3f && timeToEvent > 0f && !cuedMoleSounds.Contains(moleEvent))
if (timeToEvent <= 4f && timeToEvent > 2f && !cuedMoleSounds.Contains(moleEvent))
{
cuedMoleSounds.Add(moleEvent);
MultiSound.Play(new MultiSound.Sound[] { new MultiSound.Sound("cropStomp/moleNyeh", (moleEvent.beat - 2f) - moleSoundOffsets[0] * Conductor.instance.songBpm / 60f),