Class: BehaviorTree::Selector

Inherits:
ControlNodeBase show all
Defined in:
lib/behavior_tree/control_nodes/selector.rb

Overview

A selector node.

Instance Method Summary collapse

Methods inherited from ControlNodeBase

#<<, #halt!, #initialize, traversal_strategy

Methods included from NodeIterators::AllNodes

#all_nodes

Methods included from TreeStructure::Algorithms

#cycle?, #each_node, #repeated_nodes, #uniq_nodes?

Constructor Details

This class inherits a constructor from BehaviorTree::ControlNodeBase

Instance Method Details

#on_tickObject



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/behavior_tree/control_nodes/selector.rb', line 8

def on_tick
  tick_each_children do |child|
    return status.running! if child.status.running?

    # Both self and children have the status set to success.
    return halt! if child.status.success?
  end

  # Halt, but set success only to children, not to self.
  # Self status must be overriden to failure.
  halt!
  status.failure!
end