37 lines
908 B
C#
37 lines
908 B
C#
namespace Code.Infrastructure.StateMachine
|
|
{
|
|
public abstract class BaseState<TEnum, TStateMachineContext>
|
|
{
|
|
public abstract TEnum myState { get; }
|
|
|
|
protected BaseState(TStateMachineContext context, EventBus.EventBus eventBus)
|
|
{
|
|
Context = context;
|
|
EventBus = eventBus;
|
|
}
|
|
|
|
protected EventBus.EventBus EventBus;
|
|
protected TStateMachineContext Context { get; }
|
|
|
|
protected virtual void _fireEnterState()
|
|
{
|
|
}
|
|
|
|
protected virtual void _fireExitState()
|
|
{
|
|
}
|
|
|
|
protected abstract void OnEnterState();
|
|
protected abstract void OnExitState();
|
|
public void EnterState()
|
|
{
|
|
OnEnterState();
|
|
_fireEnterState();
|
|
}
|
|
public void ExitState()
|
|
{
|
|
OnExitState();
|
|
_fireExitState();
|
|
}
|
|
}
|
|
} |