Sha256: ac647ca06d4fc773a095c24db5bd68133e3bef7c0739d3677101f642cbd11118

Contents?: true

Size: 570 Bytes

Versions: 6

Compression:

Stored size: 570 Bytes

Contents

module GameMachine
  module Helpers
    module StateMachine

      def load_state(id, &block)
        @actor_states[id] ||= @initial_state
        self.state = @actor_states[id]
        if block_given?
          yield
          save_state(id)
        end
      end

      def save_state(id)
        @actor_states[id] = self.state
      end

      def destroy_state(id)
        @actor_states.delete(id)
      end

      def initialize_states
        @actor_states = {}
        initialize_state_machines
        @initial_state = self.state.dup
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
game_machine-1.0.4 lib/game_machine/helpers/state_machine.rb
game_machine-1.0.2 lib/game_machine/helpers/state_machine.rb
game_machine-0.0.11 lib/game_machine/helpers/state_machine.rb
game_machine-0.0.10 lib/game_machine/helpers/state_machine.rb
game_machine-0.0.9 lib/game_machine/helpers/state_machine.rb
game_machine-0.0.8 lib/game_machine/helpers/state_machine.rb