/// <summary> /// Pushes the action to the stack and immediently calls <see cref="ActionBase.Run(TimeSpan)"/>. /// </summary> /// <param name="action"></param> /// <param name="timeElapsed"></param> public void PushAndRun(Actions.ActionBase action, TimeSpan timeElapsed = default) { if (!action.IsFinished) { if (Count == 0 || Peek() != action) { Push(action); } action.Run(timeElapsed); } }
/// <summary> /// Pushes the action to the stack and immediently calls <see cref="ActionBase.Run(TimeSpan)"/>. Removes it if it finishes. /// </summary> /// <param name="action"></param> /// <param name="timeElapsed"></param> public void PushAndRun(Actions.ActionBase action, TimeSpan timeElapsed = default) { if (!action.IsFinished) { if (Peek() != action) { Push(action); } action.Run(timeElapsed); if (action.IsFinished && Peek() == action) { Pop(); } } }