This commit is contained in:
CortexCore
2023-08-11 23:57:37 +08:00
parent 936a94c84b
commit 75889ec34f
149 changed files with 6524 additions and 1043 deletions

View File

@@ -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);