Class: BehaviorTree::Decorators::Condition

Inherits:
DecoratorBase
  • Object
show all
Includes:
Validations::ProcOrBlock
Defined in:
lib/behavior_tree/decorator_nodes/condition.rb

Overview

Applies a condition that will decide whether to tick the decorated node or not.

Instance Method Summary collapse

Methods inherited from DecoratorBase

#ensure_after_tick, #halt!, #on_tick

Methods included from TreeStructure::Algorithms

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

Constructor Details

#initialize(child, procedure = nil, &block) ⇒ Condition

Returns a new instance of Condition.



11
12
13
14
15
16
17
# File 'lib/behavior_tree/decorator_nodes/condition.rb', line 11

def initialize(child, procedure = nil, &block)
  validate_proc!(procedure, block)

  super(child)

  @conditional_block = block_given? ? block : procedure
end