/// <summary> /// Gets the state on the stack below the provided state. /// </summary> /// <param name="esi">State to look below.</param> /// <returns>State below esi on the stack.</returns> public static IEngineState peekBelowState(IEngineState esi) { List<IEngineState> list = m_stateStack.ToList(); int loc = list.FindIndex(i => i == esi); if (loc > -1 && loc < list.Count - 1) { return list[loc + 1]; } throw new Exception("Tried to peek below a state which isn't on the stack or is on the bottom"); }
/// <summary> /// Adds a state to the top of the stack. /// </summary> /// <param name="esi">State to push to the top.</param> public static void pushState(IEngineState esi) { m_stateStack.Push(esi); }
/// <summary> /// Removes the current top of the state stack and adds a new state. /// </summary> /// <param name="esi">State which replaces the top of the stack.</param> public static void replaceCurrentState(IEngineState esi) { m_stateStack.Pop(); m_stateStack.Push(esi); }