cirnogodot/Scripts/Components/FSM/ModuleBase.cs

23 lines
837 B
C#
Raw Normal View History

2025-03-04 17:50:16 +01:00
using Godot;
namespace Cirno.Scripts.Components.FSM;
2025-06-10 16:33:43 +02:00
public abstract partial class ModuleBase<TKey, TType> : Node, IModule<TKey, TType>
2025-03-04 18:16:39 +01:00
where TKey : notnull
where TType : Node
2025-03-04 17:50:16 +01:00
{
// Provide the state machine reference for derived modules to use without repeating boilerplate
protected IStateMachine<TKey, TType> StateMachine { get; private set; }
protected TType MainObject => StateMachine.MainObject;
// Default Init behaviour sets the state machine reference. Derived classes can still override
public virtual void Init(IStateMachine<TKey, TType> machine)
{
StateMachine = machine;
}
2025-03-08 11:33:26 +01:00
public abstract void EnterState(TKey state);
public abstract void ExitState(TKey state);
2025-03-04 18:16:39 +01:00
public abstract void Process(double delta);
public abstract void PhysicsProcess(double delta);
2025-03-04 17:50:16 +01:00
}