Class: Zyps::ProximityCondition
- Inherits:
-
Condition
- Object
- Condition
- Zyps::ProximityCondition
- Defined in:
- lib/zyps/conditions.rb
Overview
Select objects that are closer than the given distance.
Instance Attribute Summary collapse
-
#distance ⇒ Object
The maximum number of units away the target can be.
Instance Method Summary collapse
-
#initialize(distance) ⇒ ProximityCondition
constructor
A new instance of ProximityCondition.
-
#select(actor, targets) ⇒ Object
Returns an array of targets that are at the given distance or closer.
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
#distance ⇒ Object
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 |