module BehaviorTree::NodeIterators::PrioritizeRunning
If there's at least one node with 'running' status, then iterate starting from there, in order. Else, iterate all nodes.
Private Instance Methods
must_recompute_idx?()
click to toggle source
# File lib/behavior_tree/concerns/node_iterators/prioritize_running.rb, line 20 def must_recompute_idx? !@first_running_idx || !children[@first_running_idx].status.running? end
prioritize_running()
click to toggle source
# File lib/behavior_tree/concerns/node_iterators/prioritize_running.rb, line 10 def prioritize_running @first_running_idx = children.find_index { |child| child.status.running? }.to_i if must_recompute_idx? Enumerator.new do |y| children[@first_running_idx..].each do |child| y << child end end end