Class: BehaviorTree::Sequence

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

Overview

A sequence 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



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

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

    if child.status.failure?
      halt!

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

  # Both self and children have the status set to success.
  halt!
end