Module: DebugHelpers
- Defined in:
- lib/gamebox/core/debug_helpers.rb
Class Method Summary collapse
- .actors(type = nil) ⇒ Object
- .load_actor(actor_type) ⇒ Object
- .reload_behavior(behavior_name) ⇒ Object
Instance Method Summary collapse
Class Method Details
.actors(type = nil) ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 13 |
# File 'lib/gamebox/core/debug_helpers.rb', line 2 def actors(type=nil) matching_actors = [] ObjectSpace.each_object do |obj| if obj.class == Actor if type.nil? || obj.actor_type == type matching_actors << obj end end end log "found #{matching_actors.size} actors" matching_actors end |
.load_actor(actor_type) ⇒ Object
38 39 40 41 42 |
# File 'lib/gamebox/core/debug_helpers.rb', line 38 def load_actor(actor_type) type = actor_type.to_sym log "loading actor: [#{type}]" load "actors/#{type}.rb" end |
.reload_behavior(behavior_name) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/gamebox/core/debug_helpers.rb', line 19 def reload_behavior(behavior_name) behavior = behavior_name.to_sym log "reloading behavior: [#{behavior}]" load "behaviors/#{behavior}.rb" actors.each do |act| if act.has_behavior?(behavior) behaviors = act.instance_variable_get('@behaviors') beh_opts = behaviors[behavior].opts factory = act.this_object_context[:behavior_factory] act.remove_behavior behavior factory.add_behavior(act, behavior, beh_opts) end end end |
Instance Method Details
#current_stage ⇒ Object
15 16 17 |
# File 'lib/gamebox/core/debug_helpers.rb', line 15 def current_stage game.stage_manager.current_stage end |