Class: Zyps::PushAction

Inherits:
TimedAction show all
Defined in:
lib/zyps/actions.rb

Overview

Pushes target away.

Instance Attribute Summary collapse

Attributes inherited from TimedAction

#clock

Instance Method Summary collapse

Methods inherited from TimedAction

#copy, #delta, #initialize, #start, #stop

Constructor Details

This class inherits a constructor from Zyps::TimedAction

Instance Attribute Details

#rateObject

Units/second to accelerate targets by.



198
199
200
# File 'lib/zyps/actions.rb', line 198

def rate
  @rate
end

Instance Method Details

#do(actor, targets) ⇒ Object

Push the targets away from the actor, with force limited by elapsed time.



200
201
202
203
204
205
206
207
208
209
# File 'lib/zyps/actions.rb', line 200

def do(actor, targets)
	#Acceleration will be limited by elapsed time.
	push_force = delta
	targets.each do |target|
		#Angle to target is also angle of push force.
		push_angle = Utility.find_angle(actor.location, target.location)
		#Apply the force to the creature's movement vector.
		target.vector += Vector.new(push_force, push_angle)
	end
end