mirror of
https://github.com/RHeavenStudioPlus/HeavenStudioPlus.git
synced 2024-11-10 03:35:10 +00:00
Stomp: Fixed issues associated with specific cue setups.
This commit is contained in:
parent
21b3f7c60c
commit
9d733b6f2f
1 changed files with 41 additions and 27 deletions
|
@ -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,20 +67,48 @@ 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;
|
||||
|
||||
var marchStarts = entities.FindAll(m => m.datamodel == "cropStomp/start marching");
|
||||
for (int i = 0; i < marchStarts.Count; i++)
|
||||
if (inactiveStart == -1f)
|
||||
{
|
||||
var sampleBeat = marchStarts[i].beat;
|
||||
if (cond.songPositionInBeats <= sampleBeat + 0.25f) // 0.25-beat buffer in case the start marching event is directly next to the game switch event.
|
||||
// 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++)
|
||||
{
|
||||
startBeat = sampleBeat;
|
||||
break;
|
||||
var sampleBeat = marchStarts[i].beat;
|
||||
if (cond.songPositionInBeats <= sampleBeat + 0.25f) // 0.25-beat buffer in case the start marching event is directly next to the game switch event.
|
||||
{
|
||||
startBeat = sampleBeat;
|
||||
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),
|
||||
|
|
Loading…
Reference in a new issue