Sha256: 013ed6a32ea71f205ba61701a3cdc76d88a0f963ed23ac886ddf3986ae1190cf
Contents?: true
Size: 539 Bytes
Versions: 15
Compression:
Stored size: 539 Bytes
Contents
# Use this if you need a closest targeting mechanism. # module Targeting module Closest # 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
15 entries across 15 versions & 1 rubygems