internal void Remove(Command command) { if (command == null || !m_commandTable.ContainsKey(command)) { return; } LinkedListElement e = m_commandTable[command]; m_commandTable.Remove(command); if (e.Equals(m_lastCommand)) { m_lastCommand = e.GetPrevious(); } if (e.Equals(m_firstCommand)) { m_firstCommand = e.GetNext(); } e.Remove(); var requirements = command.GetRequirements(); foreach (var requirement in requirements) { requirement.SetCurrentCommand(null); } command.Removed(); }
private void CancelConflicts(Command command) { for (int i = 0; i < m_children.Count; i++) { Command child = m_children[i].command; foreach (var requirement in command.GetRequirements()) { if (child.DoesRequire(requirement)) { child._Cancel(); child.Removed(); m_children.RemoveAt(i--); } } } }
/// <inheritdoc/> protected internal override void _End() { if (m_currentCommandIndex != -1 && m_currentCommandIndex < m_commands.Count) { Command cmd = m_commands[m_currentCommandIndex].command; cmd._Cancel(); cmd.Removed(); } foreach (var s in m_children) { Command cmd = s.command; cmd._Cancel(); cmd.Removed(); } m_children.Clear(); }
internal void Remove(Command command) { if (command == null || !m_activeCommands.Contains(command)) { return; } m_activeCommands.Remove(command); foreach (var requirement in command.GetRequirements()) { requirement.SetCurrentCommand(null); } command.Removed(); }
/// <inheritdoc/> internal override void _Execute() { Entry entry = null; Command cmd = null; bool firstRun = false; if (m_currentCommandIndex == -1) { firstRun = true; m_currentCommandIndex = 0; } while (m_currentCommandIndex < m_commands.Count()) { if (cmd != null) { if (entry.IsTimedOut()) { cmd._Cancel(); } if (cmd.Run()) { break; } else { cmd.Removed(); m_currentCommandIndex++; firstRun = true; cmd = null; continue; } } entry = m_commands[m_currentCommandIndex]; cmd = null; switch (entry.state) { case Entry.IN_SEQUENCE: cmd = entry.command; if (firstRun) { cmd.StartRunning(); CancelConflicts(cmd); } firstRun = false; break; case Entry.BRANCH_PEER: m_currentCommandIndex++; entry.command.Start(); break; case Entry.BRANCH_CHILD: m_currentCommandIndex++; CancelConflicts(entry.command); entry.command.StartRunning(); m_children.Add(entry); break; } } for (int i = 0; i < m_children.Count; i++) { entry = m_children[i]; Command child = entry.command; if (entry.IsTimedOut()) { child._Cancel(); } if (!child.Run()) { child.Removed(); m_children.RemoveAt(i--); } } }