/// <summary> /// Pushes a state onto the specified stack. /// </summary> /// <param name="stackName">The stack on which to place the state.</param> /// <param name="newState">The state to add to the specified stack.</param> public void PushState(String stackName, AbstractState newState) { String s = stackName.ToLower(); if (stackDictionary.ContainsKey(s) == false) { throw new ArgumentException("Stack '" + s + "' does not exist in the state machine."); } if (s != "main" || this.stackDictionary["main"].Count > 0) { newState.Parent = this.stackDictionary[s].Peek(); newState.Parent.StatePaused(); } this.stackDictionary[s].Push(newState); newState.StateMachine = this; newState.StateStarted(); }
/// <summary> /// Pushes a state onto the specified stack. /// </summary> /// <param name="stackName">The stack on which to place the state.</param> /// <param name="newState">The state to add to the specified stack.</param> public void PushState(String stackName, AbstractState newState) { String s = stackName.ToLower(); if (stackDictionary.ContainsKey(s) == false) throw new ArgumentException("Stack '" + s + "' does not exist in the state machine."); if (s != "main" || this.stackDictionary["main"].Count > 0) { newState.Parent = this.stackDictionary[s].Peek(); newState.Parent.StatePaused(); } this.stackDictionary[s].Push(newState); newState.StateMachine = this; newState.StateStarted(); }