Files
MojSadUnity/Assets/Code/Infrastructure/StateMachine/BaseState.cs
T
2026-02-26 11:21:27 +03:00

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();
}
}
}