Пример #1
0
    public virtual void ChangeState(S newState, C newController, bool checkIfSameState = true)
    {
        if (ActiveState != null)
        {
            if (ActiveState.GetType() == newState.GetType() && checkIfSameState)
            {
                return;
            }
        }

        if (newState.Controller == null)
        {
            newState.Controller = newController;
        }

        if (ActiveState != null)
        {
            ActiveState.OnStateExit();
        }

        ActiveState = newState;

        ActiveState.OnStateEnter();
    }