I am building a StateMachine. For my States I use an interface:
public interface IState
{
void Enter();
void Execute();
void Exit();
}
I always have a IState currentState
active, I would like to check which type of State it is. Lets say I have WalkingState
and RunningState
, I would like to check which one is currently Active.
I tried something like:
public bool IsCurrentState<T>()
{
return (Type)currentState == typeof(T);
}
But It does not allow me to cast currentState to a Type, and nothing else I've tried has worker either.