Rhythm tweezers pass turn now works like working dough

This commit is contained in:
Rapandrasmus 2023-06-13 16:03:08 +02:00
parent 6eac745eae
commit 0debf55391

View file

@ -37,8 +37,7 @@ namespace HeavenStudio.Games.Loaders
},
new GameAction("passTurn", "Pass Turn")
{
function = delegate { var e = eventCaller.currentEntity; RhythmTweezers.instance.PassTurn(e.beat); },
preFunction = delegate { var e = eventCaller.currentEntity; RhythmTweezers.PrePassTurn(e.beat, e.length); }
preFunction = delegate { var e = eventCaller.currentEntity; RhythmTweezers.PrePassTurn(e.beat); },
},
new GameAction("next vegetable", "Swap Vegetable")
{
@ -351,6 +350,10 @@ namespace HeavenStudio.Games
public void PassTurn(double beat)
{
if (crHandlerInstance.queuedEvents.Count > 0)
{
BeatAction.New(instance.gameObject, new List<BeatAction.Action>()
{
new BeatAction.Action(beat - 1, delegate
{
hairsLeft = crHandlerInstance.queuedEvents.Count;
foreach (var crEvent in crHandlerInstance.queuedEvents)
@ -358,18 +361,17 @@ namespace HeavenStudio.Games
if (crEvent.tag == "Hair")
{
Hair hairToInput = spawnedHairs.Find(x => x.createBeat == crEvent.beat);
hairToInput.StartInput(beat + 1, crEvent.relativeBeat);
hairToInput.StartInput(beat, crEvent.relativeBeat);
}
else if (crEvent.tag == "Long")
{
LongHair hairToInput = spawnedLongs.Find(x => x.createBeat == crEvent.beat);
hairToInput.StartInput(beat + 1, crEvent.relativeBeat);
hairToInput.StartInput(beat, crEvent.relativeBeat);
}
}
crHandlerInstance.queuedEvents.Clear();
BeatAction.New(instance.gameObject, new List<BeatAction.Action>()
{
new BeatAction.Action(beat + 1, delegate
}),
new BeatAction.Action(beat, delegate
{
if (crHandlerInstance.queuedEvents.Count > 0)
{
@ -379,12 +381,12 @@ namespace HeavenStudio.Games
if (crEvent.tag == "Hair")
{
Hair hairToInput = spawnedHairs.Find(x => x.createBeat == crEvent.beat);
hairToInput.StartInput(beat + 1, crEvent.relativeBeat);
hairToInput.StartInput(beat, crEvent.relativeBeat);
}
else if (crEvent.tag == "Long")
{
LongHair hairToInput = spawnedLongs.Find(x => x.createBeat == crEvent.beat);
hairToInput.StartInput(beat + 1, crEvent.relativeBeat);
hairToInput.StartInput(beat, crEvent.relativeBeat);
}
}
crHandlerInstance.queuedEvents.Clear();
@ -394,22 +396,23 @@ namespace HeavenStudio.Games
}
}
public static void PrePassTurn(double beat, float length)
public static void PrePassTurn(double beat)
{
if (GameManager.instance.currentGame == "rhythmTweezers")
{
instance.SetPassTurnValues(beat + length);
instance.SetPassTurnValues(beat);
instance.PassTurn(beat);
}
else
{
passedTurns.Add(beat + length);
passedTurns.Add(beat);
}
}
private void SetPassTurnValues(double startBeat)
{
if (crHandlerInstance.intervalLength <= 0) return;
passTurnBeat = startBeat - 1f;
passTurnBeat = startBeat - 1;
passTurnEndBeat = startBeat + crHandlerInstance.intervalLength;
}
@ -512,6 +515,7 @@ namespace HeavenStudio.Games
foreach (var turn in passedTurns)
{
SetPassTurnValues(turn);
PassTurn(turn);
}
passedTurns.Clear();
}