public void Tick() { CallOnEnterOnQueuedNodes(); var index = traversal.Peek(); var node = tree.Nodes[index]; var status = node.Run(); LastExecutedStatus = status; #if UNITY_EDITOR node.StatusEditorResult = (BTNode.EStatusEditor)status; #endif if (status != BTNode.EStatus.Running) { PopNode(); OnChildExit(node, status); } if (traversal.Count == 0) { onDone?.Invoke(); __debug("iterator done!"); } }
public void FixedSizeStack_CanPeek() { FixedSizeStack<int> stack = new FixedSizeStack<int>(1); stack.Push(1); Assert.AreEqual(1, stack.Count); int peeked = stack.Peek(); Assert.AreEqual(1, peeked); Assert.AreEqual(1, stack.Count); }
public static void Redo() { if (m_redoStack.Count > 0) { BTUndoState undoState = m_redoStack.Pop(); if (undoState.CanRedo) { undoState.Redo(); if (undoState.CanUndo) { m_undoStack.Push(undoState); } } while (m_redoStack.Count > 0 && !m_redoStack.Peek().CanRedo) { m_redoStack.Pop(); } } }
public void FixedSizeStack_PeekThrowsWhenEmpty() { FixedSizeStack<int> stack = new FixedSizeStack<int>(1); try { stack.Peek(); Assert.Fail("Peeking did not throw an exception when the stack was empty."); } catch (InvalidOperationException) { // expected } }
public static void BeginUndoGroup(string title) { if (m_undoStack.Count > 0) { BTUndoGroup oldGroup = m_undoStack.Peek() as BTUndoGroup; if (oldGroup != null && oldGroup.IsOpen) { Debug.LogWarningFormat("You have to call BTUndoSystem.EndUndoGroup before begining a new group. Old group is '{0}', new group is '{1}'", oldGroup.Title, title); if (oldGroup.IsEmpty) { m_undoStack.Pop(); } else { oldGroup.Close(); } } } BTUndoGroup group = new BTUndoGroup(title); m_undoStack.Push(group); }
public void TestInitialization() { Assert.That(_stack.Count, Is.EqualTo(0)); Assert.That(_stack.Capacity, Is.EqualTo(5)); Assert.That(_stack.Peek(), Is.Null); }