SupaLidlGame/State/Character/CharacterStateMachine.cs

40 lines
861 B
C#
Raw Normal View History

2023-05-25 15:28:33 -07:00
using Godot;
2023-06-03 18:21:46 -07:00
namespace SupaLidlGame.State.Character;
public partial class CharacterStateMachine : StateMachine<CharacterState>
2023-05-25 15:28:33 -07:00
{
2023-06-03 18:21:46 -07:00
[Export]
public override CharacterState InitialState { get; set; }
2023-05-25 15:28:33 -07:00
2023-06-03 18:21:46 -07:00
[Export]
public Characters.Character Character { get; set; }
2023-05-25 15:28:33 -07:00
2023-06-03 18:21:46 -07:00
public void Process(double delta)
{
var state = CurrentState.Process(delta);
if (state is CharacterState)
2023-05-25 15:28:33 -07:00
{
2023-06-03 18:21:46 -07:00
ChangeState(state);
2023-05-25 15:28:33 -07:00
}
2023-06-03 18:21:46 -07:00
}
2023-05-25 15:28:33 -07:00
2023-06-03 18:21:46 -07:00
public void PhysicsProcess(double delta)
{
var state = CurrentState.PhysicsProcess(delta);
if (state is CharacterState)
2023-05-25 15:28:33 -07:00
{
2023-06-03 18:21:46 -07:00
ChangeState(state);
2023-05-25 15:28:33 -07:00
}
2023-06-03 18:21:46 -07:00
}
2023-05-25 15:28:33 -07:00
2023-06-03 18:21:46 -07:00
public void Input(InputEvent @event)
{
var state = CurrentState.Input(@event);
if (state is CharacterState)
2023-05-25 15:28:33 -07:00
{
2023-06-03 18:21:46 -07:00
ChangeState(state);
2023-05-25 15:28:33 -07:00
}
}
}