lib/game_machine/grid.rb in game_machine-0.0.11 vs lib/game_machine/grid.rb in game_machine-1.0.2

- old
+ new

@@ -14,11 +14,12 @@ def update_frequency_for(name) config.fetch(name)[:update_frequency] end def load_from_config - Application.config.grids.each do |name,value| + ['default','local_chat','aoe'].each do |name| + value = Application.config.grids.send(name.to_sym) grid_size,cell_size,update_frequency = value.split(',') config[name] = { :grid_size => grid_size.to_i, :cell_size => cell_size.to_i, :update_frequency => update_frequency.to_i @@ -26,34 +27,20 @@ find_or_create(name) end end def reset_grids - @grids = java.util.concurrent.ConcurrentHashMap.new + JavaLib::Grid.reset_grids end - def grids - if @grids - return @grids - else - reset_grids - end - end - def default_grid find_or_create('default') end def find_or_create(name) - unless grids.containsKey(name) - GameMachine.logger.info "CREATING GRID #{name}" - grid_config = config.fetch(name) - grid = JavaLib::Grid.new(grid_config.fetch(:grid_size), + grid_config = config.fetch(name) + JavaLib::Grid.find_or_create(name,grid_config.fetch(:grid_size), grid_config.fetch(:cell_size)) - grids.put(name,grid) - end - - grids.fetch(name) end end end end