void ChangeState(FiniteState newState)
 {
     if (currentState != null){
         currentState.OnExit(target);
     }
     currentState = newState;
     // TODO Assert(currentState != null);
     currentState.OnEnter(target);
 }
 void SetDefaultToCurrent()
 {
     currentState = defaultState;
 }
 protected void AddState(FiniteState state)
 {
     // not allow same-name state
     // Assert(!allStates.ContainsKey(state.Name));
     allStates.Add(state.Name, state);
 }
 protected void RemoveState(FiniteState state)
 {
     allStates.Remove(state.Name);
 }
 bool TryGetNextStateByEventName(FiniteStateTransition transation, string eventName, out FiniteState state)
 {
     state = null;
     if (currentState == null || !currentState.Name.Equals(transation.LastStateName)) return false;
     if (!eventName.Equals(transation.EventName)) return false;
     return (allStates.TryGetValue(transation.NextStateName, out state));
 }