/// <summary>
    /// This method places new _States inside the FSM,
    /// or prints an ERROR message if the state was already inside the List.
    /// First state added is also the initial state.
    /// </summary>
    public void AddState(BehaviourState s)
    {
        if (s == null)
        {
            Debug.LogError("FSM ERROR: Null reference is not allowed");
        }

        // First State inserted is also the Initial state,
        // the state the machine is in when the simulation begins
        if (_States.Count == 0)
        {
            _States.Add(s);
            _CurState   = s;
            _CurStateID = s.ID;
            _CurState.OnEnter();
            return;
        }

        // Add the state to the List if it's not inside it
        foreach (BehaviourState state in _States)
        {
            if (state.ID == s.ID)
            {
                Debug.LogError("FSM ERROR: Impossible to add state " + s.ID.ToString() +
                               " because state has already been added");
                return;
            }
        }
        _States.Add(s);
    }
    /// <summary>
    /// 执行转换,外部调用关键方法。
    /// </summary>
    /// <param name="trans">Trans.</param>
    public void PerformTransition(EBehaviourTransition trans, object param = null)
    {
        if (!CanTransition(trans))
        {
            return;
        }

        _CurStateID = _CurState.GetOutputState(trans);
        foreach (BehaviourState state in _States)
        {
            if (state.ID == _CurStateID)
            {
                _CurState.OnExit();
                _CurState = state;
                _CurState.OnEnterBefore();
                _CurState.OnEnter(param);
                break;
            }
        }
    }