Initial Checkin of Code

This commit is contained in:
Mario Steele 2025-04-11 13:35:55 -05:00
parent 19b557ee9b
commit 0bee2ee47b
44 changed files with 7965 additions and 0 deletions

View file

@ -0,0 +1,20 @@
using Godot;
using PokemonLike.Library.Support;
namespace PokemonLike.Library.Utilities;
[GlobalClass]
public abstract partial class State : Node
{
[Export] public Node StateOwner;
public virtual void EnterState()
{
Logger.Info($"Entering {GetType().Name} state ...");
}
public virtual void ExitState()
{
Logger.Info($"Exiting {GetType().Name} state ...");
}
}

View file

@ -0,0 +1 @@
uid://drebiluk2m8ft

View file

@ -0,0 +1,37 @@
using Godot;
using PokemonLike.Library.Support;
namespace PokemonLike.Library.Utilities;
[GlobalClass]
public partial class StateMachine : Node
{
[ExportCategory("State Machine Vars")]
[Export] public Node Customer;
[Export] public State CurrentState;
public override void _Ready()
{
Logger.Info("Loading state machine...");
foreach (Node child in GetChildren())
{
if (child is State state)
{
state.StateOwner = Customer;
state.SetProcess(false);
}
}
}
public string GetCurrentState() => CurrentState.Name.ToString();
public void ChangeState(State newState)
{
CurrentState?.ExitState();
CurrentState = newState;
CurrentState?.EnterState();
foreach (Node child in GetChildren())
if (child is State state)
state.SetProcess(state == CurrentState);
}
}

View file

@ -0,0 +1 @@
uid://dxo0eunwolubm