Class: Zyps::ProximityCondition

Inherits:
Condition show all
Defined in:
lib/zyps/conditions.rb

Overview

Select objects that are closer than the given distance.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Condition

#copy

Constructor Details

#initialize(distance) ⇒ ProximityCondition

Returns a new instance of ProximityCondition.



56
57
58
# File 'lib/zyps/conditions.rb', line 56

def initialize(distance)
	self.distance = distance
end

Instance Attribute Details

#distanceObject

The maximum number of units away the target can be.



55
56
57
# File 'lib/zyps/conditions.rb', line 55

def distance
  @distance
end

Instance Method Details

#select(actor, targets) ⇒ Object

Returns an array of targets that are at the given distance or closer.



60
61
62
# File 'lib/zyps/conditions.rb', line 60

def select(actor, targets)
	targets.find_all {|target| Utility.find_distance(actor.location, target.location) <= @distance}
end