Class: GamePlay::StateMachine
- Defined in:
- scripts/01450 Systems/00000 General/00003 GamePlay__Base/00001 GamePlay__StateMachine.rb
Overview
Parent class of State machine scenes
This class is designed to be “parent_class” of state machines scenes designed with .yml files. This class will call `update_state_machine` in update (and handle the state machine), you still have to call `initialize_state_machine` in either `create_graphics` or `initialize`.
Note: If a state sets `@sm_execute_next_state` to true, the system will not wait for the next frame to execute the next state.
This executes the next state only if it is different! Please also ensure you don't use this when displaying a message.s
Direct Known Subclasses
Constant Summary
Constants inherited from Base
Base::DEFAULT_TRANSITION, Base::DEFAULT_TRANSITION_PARAMETER
Constants included from Input
Input::ALIAS_KEYS, Input::AXIS_MAPPING, Input::AXIS_SENSITIVITY, Input::DEAD_ZONE, Input::Keyboard, Input::Keys, Input::NON_TRIGGER_ZONE, Input::REPEAT_COOLDOWN, Input::REPEAT_SPACE
Constants included from DisplayMessage
DisplayMessage::MESSAGE_ERROR, DisplayMessage::MESSAGE_PROCESS_ERROR
Instance Attribute Summary
Attributes inherited from Base
#__last_scene, #__result_process, #running, #viewport
Attributes included from DisplayMessage
Instance Method Summary collapse
-
#update
Update the scene process.
Methods inherited from Base
#add_disposable, #call_scene, #dispose, #find_parent, #initialize, #main, #return_to_scene, #snap_to_bitmap, #visible, #visible=
Methods included from Input
dir4, dir8, get_text, joy_axis_position, press?, register_events, released?, repeat?, swap_states, trigger?
Methods included from DisplayMessage
#can_display_message_be_called?, #close_message_window, #display_message, #display_message_and_wait, #message_class, #message_processing?, #message_visible, #message_visible=
Constructor Details
This class inherits a constructor from GamePlay::Base
Instance Method Details
#update
Update the scene process
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'scripts/01450 Systems/00000 General/00003 GamePlay__Base/00001 GamePlay__StateMachine.rb', line 12 def update return unless super # Set last state and execute current state last_state = @sm_state update_state_machine # Attempt to execute next state whil it's said to do so while @sm_execute_next_state # Set execute next state flag to false in order to prevent mistakes (it has to be set by the state!) @sm_execute_next_state = false # If previous is the same as current, we don't execute the next step break if last_state == @sm_state # Sets the last state to current in order to ensure next iteration won't infinite-loop last_state = @sm_state update_state_machine end end |