Rhythm tweezers pass turn now works like working dough

This commit is contained in:
Rapandrasmus 2023-06-13 16:03:08 +02:00
parent 2109c99a95
commit d770266d81

View file

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