private void UpdateNextElement() { for (int i = 0; i < 1; i++) { GuiElement current = Stack[i]; GuiElement next = current.GetNextElement(AllElements); if (Stack.CanPush(next)) { // Only call OnExit() if this is the first new element. bool invokeExit = Stack.Count == 1; Stack.Push(next); Console.WriteLine("Stack is now length " + Stack.Count); if (invokeExit) { Stack.Current.OnExit(); } } } }
/// <summary> /// Returns true if given element can be pushed onto stack. /// </summary> public bool CanPush(GuiElement element) { return(element != null && !List.Contains(element)); }
/// <summary> /// This function is called sequentially on every element in the containing state manager. /// <para>Return true to set the given element as the next element.</para> /// </summary> protected abstract bool NextElementSelector(GuiElement element);
/// <summary> /// Returns true if stack contains element. /// </summary> public bool Contains(GuiElement element) => List.Contains(element);