1
This commit is contained in:
@@ -14,14 +14,15 @@ namespace BITKit.StateMachine
|
||||
public interface IStateMachine<T> where T : IState
|
||||
{
|
||||
T CurrentState { get; set; }
|
||||
IDictionary<Type, T> StateDictonary { get; }
|
||||
IDictionary<Type, T> StateDictionary { get; }
|
||||
void TransitionState<State>() where State : T
|
||||
{
|
||||
var nextState = StateDictonary.GetOrCreate(typeof(State));
|
||||
var nextState = StateDictionary.GetOrCreate(typeof(State));
|
||||
TransitionState(nextState);
|
||||
}
|
||||
void TransitionState<State>(State nextState) where State : T
|
||||
{
|
||||
if (nextState.Equals(CurrentState)) return;
|
||||
var currentState = CurrentState;
|
||||
currentState?.OnStateExit(currentState, nextState);
|
||||
nextState?.OnStateEnter(currentState);
|
||||
|
Reference in New Issue
Block a user