Module: AdventureRL::Modifiers::Pusher
- Defined in:
- lib/AdventureRL/Modifiers/Pusher.rb
Overview
A Modifiers::Pusher is a Modifers::Solid Mask, which has the ability to __push other solid Masks__ (that are _not static_) out of the way when moving with #move_by.
Instance Method Summary collapse
-
#move_by(*args) ⇒ Object
Overwrite Modifiers::Solid#move_by to add the
:pushed_by_pusheroption.
Instance Method Details
#move_by(*args) ⇒ Object
Overwrite Modifiers::Solid#move_by to add the :pushed_by_pusher option. This skips pushing the Pusher that pushed this Pusher, to avoid an endless pushing of Pushers, where one Pusher pushes the other Pusher before that Pusher pushes the first Pusher, …
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/AdventureRL/Modifiers/Pusher.rb', line 14 def move_by *args return if (is_static?) if (args.last.is_a?(Hash)) @pushed_by_pusher = [args.last[:pushed_by_pusher], self].flatten.reject { |x| !x } else @pushed_by_pusher = [self] end super @pushed_by_pusher = false end |