Crop Stomp Fix + Fork Lifter Animation Tweak (#588)

* fork lifter weird reset thingy fixed

* crop stomp code review

im gonna be fixing that weird bug where inputs aren't scheduled if crop stomp is the first game (or if you start on it) but first
some of the code in this is nearly two years old. it needed a lot of check-ups.

* oh okay that bug was really easy to fix

* convert animation playing to beat scaled playing

* crop stomp fix
This commit is contained in:
AstrlJelly
2023-12-05 17:38:55 -05:00
committed by GitHub
parent 3eac52f38d
commit 8fb01142db
5 changed files with 152 additions and 278 deletions

View File

@ -39,7 +39,7 @@ namespace HeavenStudio.Games.Scripts_CropStomp
{
game = CropStomp.instance;
if (Conductor.instance.isPlaying)
// if (Conductor.instance.isPlaying)
game.ScheduleInput(targetBeat - 1, 1f, CropStomp.InputAction_BasicPress, StompJust, StompMiss, Out);
if (!isMole)
@ -56,38 +56,23 @@ namespace HeavenStudio.Games.Scripts_CropStomp
private bool gotStomped; // Safeguard in case nested Update() call breaks.
private void Update()
{
if (!game.isMarching)
return;
if (!game.isMarching) return;
// Veggie missed. Handle missed state.
if (veggieState == -1)
switch (veggieState)
{
MissedUpdate();
return;
}
case -1: MissedUpdate(); return;
// case 0:
case 2: PickedUpdate(); return;
case 1:
float airPosition = Conductor.instance.GetPositionFromBeat(stompedBeat, landBeat - stompedBeat);
veggieTrans.position = curve.GetPoint(Mathf.Clamp(airPosition, 0, 1));
// Veggie picked. Handle picked state.
if (veggieState == 2)
{
PickedUpdate();
return;
}
var cond = Conductor.instance;
// In ground.
if (veggieState == 0)
{
}
// In air.
else if (veggieState == 1)
{
float airPosition = cond.GetPositionFromBeat(stompedBeat, landBeat - stompedBeat);
veggieTrans.position = curve.GetPoint(Mathf.Clamp(airPosition, 0, 1));
if (PlayerInput.GetIsAction(CropStomp.InputAction_FlickRelease) && !game.IsExpectingInputNow(CropStomp.InputAction_FlickRelease))
{
pickEligible = false;
}
if (PlayerInput.GetIsAction(CropStomp.InputAction_FlickRelease) && !game.IsExpectingInputNow(CropStomp.InputAction_FlickRelease))
{
pickEligible = false;
}
break;
// default:
}
}
@ -105,17 +90,17 @@ namespace HeavenStudio.Games.Scripts_CropStomp
StompVeggie(false);
}
private void StompMiss(PlayerActionEvent caller)
private void StompMiss(PlayerActionEvent caller)
{
veggieState = -1;
caller.Disable();
}
private void Out(PlayerActionEvent caller) {}
private void Out(PlayerActionEvent caller) { }
private void PickJust(PlayerActionEvent caller, float state)
{
game.bodyAnim.Play("Pick", 0, 0);
game.bodyAnim.DoScaledAnimationAsync("Pick", 0.5f);
game.isFlicking = true;
if (!pickEligible) return;
if (GameManager.instance.autoplay)
@ -131,13 +116,20 @@ namespace HeavenStudio.Games.Scripts_CropStomp
curve.transform.localScale = Vector3.one; // Return curve to normal size in the case of mole curves.
var key1 = curve.KeyPoints[0];
var key1Pos = key1.Position;
key1.Position = new Vector3(key1Pos.x, veggieTrans.position.y, key1Pos.z);
for (int i = 0; i < 2; i++)
{
var key = curve.KeyPoints[i];
var keyPos = key.Position;
key.Position = new Vector3(keyPos.x, veggieTrans.position.y + (i * 2), keyPos.z);
}
var key2 = curve.KeyPoints[1];
var key2Pos = key2.Position;
key2.Position = new Vector3(key2Pos.x, veggieTrans.position.y + 2f, key2Pos.z);
// var key1 = curve.KeyPoints[0];
// var key1Pos = key1.Position;
// key1.Position = new Vector3(key1Pos.x, veggieTrans.position.y, key1Pos.z);
// var key2 = curve.KeyPoints[1];
// var key2Pos = key2.Position;
// key2.Position = new Vector3(key2Pos.x, veggieTrans.position.y + 2f, key2Pos.z);
pickedBeat = Conductor.instance.songPositionInBeatsAsDouble;
@ -154,9 +146,8 @@ namespace HeavenStudio.Games.Scripts_CropStomp
private void PickMiss(PlayerActionEvent caller)
{
veggieState = -1;
if (!isMole)
SoundByte.PlayOneShotGame("cropStomp/veggieMiss");
if (!isMole) SoundByte.PlayOneShotGame("cropStomp/veggieMiss");
caller.Disable();
}
@ -186,7 +177,7 @@ namespace HeavenStudio.Games.Scripts_CropStomp
var distDiff = transform.position.x - game.farmerTrans.position.x;
if (distDiff > 1.5f)
{
moleAnim.Play("Chuckle", 0, 0);
moleAnim.DoScaledAnimationAsync("Chuckle", 0.5f);
moleLaughing = true;
}
}
@ -223,6 +214,8 @@ namespace HeavenStudio.Games.Scripts_CropStomp
}
gotStomped = true;
Debug.Log("Stomped!");
var cond = Conductor.instance;
ParticleSystem spawnedHit = Instantiate(game.hitParticle, game.hitParticle.transform.parent);
@ -235,12 +228,12 @@ namespace HeavenStudio.Games.Scripts_CropStomp
stompedBeat = cond.songPositionInBeatsAsDouble;
landBeat = targetBeat + (float)cond.SecsToBeats(Minigame.NgLateTime()-1, cond.GetBpmAtBeat(targetBeat));
landBeat = targetBeat + (float)cond.SecsToBeats(Minigame.NgLateTime() - 1, cond.GetBpmAtBeat(targetBeat));
if (autoTriggered)
{
game.Stomp();
game.bodyAnim.Play("Stomp", 0, 0);
game.bodyAnim.DoScaledAnimationAsync("Stomp", 0.5f);
}
if (!isMole)
@ -251,7 +244,7 @@ namespace HeavenStudio.Games.Scripts_CropStomp
}
else
{
moleAnim.Play("Idle", 0, 0);
moleAnim.DoScaledAnimationAsync("Idle", 0.5f);
}
var veggieScale = veggieTrans.localScale;
@ -267,7 +260,7 @@ namespace HeavenStudio.Games.Scripts_CropStomp
if (autoTriggered)
{
game.bodyAnim.Play("Pick", 0, 0);
game.bodyAnim.DoScaledAnimationAsync("Pick", 0.5f);
game.isFlicking = true;
}