public void AddState(string name, XState <T> state, bool initState = false) { if (m_dictStates.ContainsKey(name)) { return; } state.SetMachine(this); m_dictStates.Add(name, state); if (initState) { m_default = name; } }
protected void _ChangeState(T obj, string state) { if (!m_dictStates.ContainsKey(state)) { return; } var oldState = m_curState; var newState = m_dictStates[state]; if (oldState != null) { oldState.OnLeave(obj); } if (newState != null) { newState.OnEnter(obj); } m_curr = state; m_curState = newState; }