2024-06-30 23:55:58 +00:00
|
|
|
|
using Godot;
|
|
|
|
|
|
|
|
|
|
namespace ColdMint.scripts.stateMachine;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// <para>StateProcessorTemplate</para>
|
|
|
|
|
/// <para>状态处理器模板</para>
|
|
|
|
|
/// </summary>
|
|
|
|
|
public abstract class StateProcessorTemplate : IStateProcessor
|
|
|
|
|
{
|
2024-07-06 14:55:07 +00:00
|
|
|
|
public virtual void Enter(StateContext context)
|
2024-06-30 23:55:58 +00:00
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Execute(StateContext context)
|
|
|
|
|
{
|
|
|
|
|
if (context.Owner == null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
2024-07-06 14:55:07 +00:00
|
|
|
|
|
2024-06-30 23:55:58 +00:00
|
|
|
|
OnExecute(context, context.Owner);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// <para>When executed</para>
|
|
|
|
|
/// <para>当执行时</para>
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="context"></param>
|
|
|
|
|
/// <param name="owner"></param>
|
|
|
|
|
protected abstract void OnExecute(StateContext context, Node owner);
|
|
|
|
|
|
2024-07-06 14:55:07 +00:00
|
|
|
|
public virtual void Exit(StateContext context)
|
2024-06-30 23:55:58 +00:00
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public abstract State State { get; }
|
|
|
|
|
}
|