public void RegisterState(MousToken token, MousState[] fromStates, MousState toState, Action @event) { if (!mTokenActions.ContainsKey(token)) { mTokenActions.Add(token, new Dictionary <MousState, Action>()); } foreach (MousState item in fromStates) { mTokenActions[token].Add(item, delegate { CurrentState = toState; @event?.Invoke(); Lock(); }); } }
public bool SetToken(MousToken token) { try { mCurrentToken = token; if (mLocked.Contains(token)) { return(false); } mTokenActions[token][CurrentState](); return(true); } catch { Debug.Log(String.Format("Invalid Change from {0} with {1}", CurrentState, token)); return(false); } }