Class: Metro::EventStateManager
- Inherits:
-
Object
- Object
- Metro::EventStateManager
- Defined in:
- lib/metro/events/event_state_manager.rb
Instance Attribute Summary collapse
-
#current_state ⇒ Object
readonly
Returns the value of attribute current_state.
-
#window ⇒ Object
Returns the value of attribute window.
Instance Method Summary collapse
-
#add_events_for_target(target, events) ⇒ Object
An an event relay to the current game state.
-
#clear ⇒ Object
Clear all the event relays of the current game state.
-
#fire_button_down(id) ⇒ Object
Fire events for button down within the current game state.
-
#fire_button_up(id) ⇒ Object
Fire events for button up for the current game state.
-
#fire_events_for_held_buttons ⇒ Object
Fire events for held buttons within the current game state.
-
#fire_events_for_notification(event, sender) ⇒ Object
Fire notification events within the current game state.
-
#initialize ⇒ EventStateManager
constructor
A new instance of EventStateManager.
Constructor Details
#initialize ⇒ EventStateManager
Returns a new instance of EventStateManager.
6 7 8 |
# File 'lib/metro/events/event_state_manager.rb', line 6 def initialize @current_state = [] end |
Instance Attribute Details
#current_state ⇒ Object (readonly)
Returns the value of attribute current_state.
12 13 14 |
# File 'lib/metro/events/event_state_manager.rb', line 12 def current_state @current_state end |
#window ⇒ Object
Returns the value of attribute window.
10 11 12 |
# File 'lib/metro/events/event_state_manager.rb', line 10 def window @window end |
Instance Method Details
#add_events_for_target(target, events) ⇒ Object
An an event relay to the current game state
52 53 54 55 56 57 58 59 60 |
# File 'lib/metro/events/event_state_manager.rb', line 52 def add_events_for_target(target,events) relay = EventRelay.new(target,window) events.each do |target_event| relay.send target_event.event, *target_event., &target_event.block end current_state.push relay end |
#clear ⇒ Object
Clear all the event relays of the current game state
17 18 19 |
# File 'lib/metro/events/event_state_manager.rb', line 17 def clear current_state.clear end |
#fire_button_down(id) ⇒ Object
Fire events for button down within the current game state
38 39 40 |
# File 'lib/metro/events/event_state_manager.rb', line 38 def (id) current_state.each {|cs| cs.(id) } end |
#fire_button_up(id) ⇒ Object
Fire events for button up for the current game state
31 32 33 |
# File 'lib/metro/events/event_state_manager.rb', line 31 def (id) current_state.each {|cs| cs.(id) } end |
#fire_events_for_held_buttons ⇒ Object
Fire events for held buttons within the current game state
24 25 26 |
# File 'lib/metro/events/event_state_manager.rb', line 24 def current_state.each {|cs| cs. } end |
#fire_events_for_notification(event, sender) ⇒ Object
Fire notification events within the current game state
45 46 47 |
# File 'lib/metro/events/event_state_manager.rb', line 45 def fire_events_for_notification(event,sender) current_state.each {|cs| cs.fire_events_for_notification(event,sender) } end |