lib/gamebox/core/actor_definition.rb
# Setup default behaviors for this Actor
# 
#  # takes a block with method missing magic
#  has_behaviors do
#    shooter range: 12
#  end
#
#  # takes a list of optionless behaviors
#  has_behaviors :jumper, :shielded
#
#  # takes a hash of behavior name to options
#  has_behaviors shooter: {range: 12}
Setup default behaviors for this Actor
takes a block with method missing magic
has_behaviors do
shooter range: 12
end

takes a list of optionless behaviors
has_behaviors :jumper, :shielded

takes a hash of behavior name to options
has_behaviors shooter: {range: 12}
Setup default behaviors for this Actor takes a block with method missing magic has_behaviors do shooter range : 12 end takes a list of optionless behaviors has_behaviors : jumper : shielded takes a hash of behavior name to options has_behaviors shooter : { range : 12 }
def has_behaviors(*behaviors, &blk)
    if block_given?
      collector = MethodMissingCollector.new
      collector.instance_eval &blk
      collector.calls.each do |name, args|
        if args.empty?
          @behaviors << name
        else
          @behaviors << {name => args.first}
        end
      end
    end
    behaviors.each do |beh|
      @behaviors << beh
    end
  end
def has_behaviors ( * behaviors , & blk ) if block_given? collector = MethodMissingCollector . new collector . instance_eval & blk collector . calls . each do | name , args | if args . empty? @behaviors << name else @behaviors << { name => args . first } end end end behaviors . each do | beh | @behaviors << beh end end
Setup default behaviors for this Actor
 takes a block with method missing magic
has_behaviors do
shooter range: 12
end
Setup default behaviors for this Actor takes a block with method missing magic has_behaviors do shooter range : 12 end
behaviors
<not_specific>
blk
<not_specific>