Class: Zyps::ExplodeAction
- Inherits:
-
SpawnAction
- Object
- Action
- SpawnAction
- Zyps::ExplodeAction
- Defined in:
- lib/zyps/actions.rb
Overview
Copies the given GameObject prototypes into the environment and destroys actor. Shrapnel’s original vector will be added to actor’s vector. Shrapnel’s size will be actor’s size divided by number of shrapnel pieces.
Instance Attribute Summary
Attributes inherited from SpawnAction
Instance Method Summary collapse
-
#do(actor, targets) ⇒ Object
Calls super method.
-
#generate_child(actor, prototype) ⇒ Object
Calls super method.
Methods inherited from SpawnAction
Constructor Details
This class inherits a constructor from Zyps::SpawnAction
Instance Method Details
#do(actor, targets) ⇒ Object
Calls super method. Also removes actor from environment.
305 306 307 308 |
# File 'lib/zyps/actions.rb', line 305 def do(actor, targets) super environment.objects.delete(actor) end |
#generate_child(actor, prototype) ⇒ Object
Calls super method. Also adds actor’s vector to child’s. Finally, reduces child’s size to actor’s size divided by number of shrapnel pieces.
312 313 314 315 316 317 |
# File 'lib/zyps/actions.rb', line 312 def generate_child(actor, prototype) child = super child.vector += actor.vector child.size = actor.size / prototypes.length child end |