Sha256: 540d147d3a1f047727f16f832516e57758b33c910bdab638864bc5e69df65fb9
Contents?: true
Size: 552 Bytes
Versions: 20
Compression:
Stored size: 552 Bytes
Contents
# Use this if you need a closest targeting mechanism. # module Targeting module Closest extend Trait # Returns the closest target of all targets in the fire arc. # # TODO fire arc # def acquire *targets closest = nil lowest_distance = nil targets.each do |target| distance = (target.position - self.position).length next if lowest_distance && distance > lowest_distance lowest_distance = distance closest = target end closest end end end
Version data entries
20 entries across 20 versions & 1 rubygems