Module: BehaviorTree::NodeIterators::PrioritizeRunning

Included in:
ControlNodeBase
Defined in:
lib/behavior_tree/concerns/node_iterators/prioritize_running.rb

Overview

If there’s at least one node with ‘running’ status, then iterate starting from there, in order. Else, iterate all nodes.

Instance Method Summary collapse

Instance Method Details

#prioritize_runningObject



8
9
10
11
12
13
14
15
16
# File 'lib/behavior_tree/concerns/node_iterators/prioritize_running.rb', line 8

def prioritize_running
  idx = @children.find_index { |child| child.status.running? }.to_i

  Enumerator.new do |y|
    @children[idx..].each do |child|
      y << child
    end
  end
end