Class: Metro::EventStateManager

Inherits:
Object
  • Object
show all
Defined in:
lib/metro/events/event_state_manager.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeEventStateManager

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_stateObject (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

#windowObject

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



59
60
61
62
63
64
65
66
67
# File 'lib/metro/events/event_state_manager.rb', line 59

def add_events_for_target(target,events)
  relay = EventRelay.new(target,window)

  events.each do |target_event|
    relay.send target_event.event, *target_event.buttons, &target_event.block
  end

  current_state.push relay
end

#clearObject

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



45
46
47
# File 'lib/metro/events/event_state_manager.rb', line 45

def fire_button_down(id)
  current_state.each {|cs| cs.fire_button_down(id) }
end

#fire_button_up(id) ⇒ Object

Fire events for button up for the current game state



38
39
40
# File 'lib/metro/events/event_state_manager.rb', line 38

def fire_button_up(id)
  current_state.each {|cs| cs.fire_button_up(id) }
end

#fire_events_for_held_buttonsObject

Fire events for held buttons within the current game state



24
25
26
# File 'lib/metro/events/event_state_manager.rb', line 24

def fire_events_for_held_buttons
  current_state.each {|cs| cs.fire_events_for_held_buttons }
end

#fire_events_for_mouse_movementObject

Fire events for mouse events within the current game state



31
32
33
# File 'lib/metro/events/event_state_manager.rb', line 31

def fire_events_for_mouse_movement
  current_state.each {|cs| cs.fire_events_for_mouse_movement }
end

#fire_events_for_notification(event, sender) ⇒ Object

Fire notification events within the current game state



52
53
54
# File 'lib/metro/events/event_state_manager.rb', line 52

def fire_events_for_notification(event,sender)
  current_state.each {|cs| cs.fire_events_for_notification(event,sender) }
end