69 lines
1.5 KiB
C#
69 lines
1.5 KiB
C#
using System;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using Godot;
|
|
using KarrotStarterTemplate.Common.StateMachines.Custom.PlayerStateMachines;
|
|
|
|
namespace KarrotStarterTemplate.Entities.Player.States;
|
|
|
|
[GlobalClass]
|
|
public partial class RollState : RootMotionBasePlayerState
|
|
{
|
|
protected async override Task OnEnter()
|
|
{
|
|
await base.OnEnter();
|
|
checkRelevance = false;
|
|
}
|
|
|
|
protected override async Task OnExit()
|
|
{
|
|
await base.OnExit();
|
|
}
|
|
|
|
protected override void OnAnimationNotify(string name, string actionName)
|
|
{
|
|
if (name == "roll" && actionName == "finish")
|
|
{
|
|
checkRelevance = true;
|
|
}
|
|
}
|
|
|
|
|
|
protected override void OnStateProcess(double delta)
|
|
{
|
|
base.OnStateProcess(delta);
|
|
|
|
if (package.GetBool("roll") && timeElapsed > 0.4)
|
|
{
|
|
statesInQueue.Add(id == "Roll" ? "DoubleRoll" : "Roll");
|
|
}
|
|
}
|
|
|
|
protected override void OnStatePhysicsProcess(double delta)
|
|
{
|
|
if (package.GetString("roll") == "finish")
|
|
{
|
|
|
|
}
|
|
|
|
base.OnStatePhysicsProcess(delta);
|
|
}
|
|
|
|
protected override string OnCheckRelevance()
|
|
{
|
|
if (statesInQueue.Count > 0) return statesInQueue.Last();
|
|
|
|
if (!package.GetVector3("move_direction").IsZeroApprox())
|
|
{
|
|
if (package.GetBool("run"))
|
|
{
|
|
return "Run";
|
|
}
|
|
|
|
return "Walk";
|
|
}
|
|
|
|
return "Idle";
|
|
|
|
}
|
|
} |