Class: Zyps::PullAction
- Inherits:
-
TimedAction
- Object
- Action
- TimedAction
- Zyps::PullAction
- Defined in:
- lib/zyps/actions.rb
Overview
Pulls target toward actor.
Instance Attribute Summary collapse
-
#rate ⇒ Object
Units/second to accelerate target by.
Attributes inherited from TimedAction
Instance Method Summary collapse
-
#do(actor, targets) ⇒ Object
Pull the targets toward the actor, with force limited by elapsed time.
Methods inherited from TimedAction
#copy, #delta, #initialize, #start, #stop
Constructor Details
This class inherits a constructor from Zyps::TimedAction
Instance Attribute Details
#rate ⇒ Object
Units/second to accelerate target by.
216 217 218 |
# File 'lib/zyps/actions.rb', line 216 def rate @rate end |
Instance Method Details
#do(actor, targets) ⇒ Object
Pull the targets toward the actor, with force limited by elapsed time.
218 219 220 221 222 223 224 225 226 227 |
# File 'lib/zyps/actions.rb', line 218 def do(actor, targets) #Acceleration will be limited by elapsed time. pull_force = delta targets.each do |target| #Angle from target to actor is also angle of pull force (opposite of that for push). pull_angle = Utility.find_angle(target.location, actor.location) #Apply the force to the creature's movement vector. target.vector += Vector.new(pull_force, pull_angle) end end |