public Manager(params State[] states) { for (int i = states.Length - 1; i >= 0; i--) { ManagedStack.Push(states[i]); } }
public override void Update(double dt) { base.Update(dt); while (ManagedStack.Count != 0) { if (ManagedStack.Peek() == null || ManagedStack.Peek().Closed) { ManagedStack.Pop(); } else if (ManagedStack.Peek().NextState != null) { ManagedStack.Push(ManagedStack.Pop().NextState); } else { break; } } CurrentState = ManagedStack.Count == 0 ? null : ManagedStack.Peek(); if (CurrentState != null) { CurrentState.Update(dt); while (CurrentState.StateStack.Count != 0) { PushState(CurrentState.StateStack.Pop()); } } else { Close(); } if (CurrentState != prevState) { StateChanged(); prevState = CurrentState; } }
public new void PushState(State state) { ManagedStack.Push(state); }