protected void setNewState(System.Type stateType)
        {
            if (mainMovementState == null || stateType != mainMovementState.GetType())
            {
                System.Type        prevStateType = null;
                CharacterStateBase prevState     = mainMovementState;

                if (mainMovementState != null)
                {
                    prevStateType = mainMovementState.GetType();
                }

                Component newState = GetComponent(stateType);

                if (newState != null)
                {
                    if (mainMovementState != null)
                    {
                        exitState(mainMovementState);
                    }

                    mainMovementState = (CharacterStateBase)newState;
                    enterState(mainMovementState, prevStateType);

                    //Debug.Log ("new state: " + newState.GetType ().ToString ());
                    OnStateChanged?.Invoke(mainMovementState, prevState);
                }
            }
        }
        protected void setNewState <T> () where T : CharacterStateBase
        {
            if (mainMovementState == null || typeof(T) != mainMovementState.GetType())
            {
                System.Type previousStateType = null;

                if (mainMovementState != null)
                {
                    previousStateType = mainMovementState.GetType();
                }

                T newState = GetComponent <T> ();

                if (newState != null)
                {
                    if (mainMovementState != null)
                    {
                        exitState(mainMovementState);
                    }

                    mainMovementState = newState;
                    enterState(newState, previousStateType);

                    //Debug.Log ("new state: " + newState.GetType ().ToString ());
                }
            }
        }
 protected void exitState(CharacterStateBase state)
 {
     state.Exit();
 }
 protected virtual void enterState(CharacterStateBase state, System.Type previousStateType)
 {
     state.Enter(previousStateType);
 }