lib/demiurge/tmx.rb
def finished_init
      super
      exits = []
      return unless @state["tile_layout_type"] == "manasource"

      # Go through the contents looking for locations
      zone_contents = self.zone.contents

      # ManaSource locations often store exits as objects in an
      # object layer.  They don't cope with multiple locations that
      # use the same TMX file since they identify the destination by
      # the TMX filename.  In Demiurge, we don't let them cross zone
      # boundaries to avoid unexpected behavior in other folks'
      # zones.
      tile_cache_entry["objects"].select { |obj| obj["type"].downcase == "warp" }.each do |obj|
        next unless obj["properties"]
        dest_map_name = obj["properties"]["dest_map"]
        dest_location = zone_contents.detect { |loc| loc.is_a?(::Demiurge::Tmx::TmxLocation) && loc.tile_cache_entry["tmx_name"] == dest_map_name }
        if dest_location
          dest_position = "#{dest_location.name}##{obj["properties"]["dest_x"]},#{obj["properties"]["dest_y"]}"
          src_x_coord = obj["x"] / tile_cache_entry["tilewidth"]
          src_y_coord = obj["y"] / tile_cache_entry["tileheight"]
          src_position = "#{name}##{src_x_coord},#{src_y_coord}"
          raise("Exit destination position #{dest_position.inspect} loaded from TMX location #{name.inspect} (TMX: #{tile_cache_entry["filename"]}) is not valid!") unless dest_location.valid_position?(dest_position)
          exits.push({ src_loc: self, src_pos: src_position, dest_pos: dest_position })
        else
          @engine.admin_warning "Unresolved TMX exit in #{name.inspect}: #{obj["properties"].inspect}!",
                                "location" => name, "properties" => obj["properties"]
        end
      end

      exits.each do |exit|
        exit[:src_loc].add_exit(from: exit[:src_pos], to: exit[:dest_pos])
      end
    end
# Let's resolve any exits that go to other TMX locations.
#
# @since 0.3.0
Let's resolve any exits that go to other TMX locations.
Let ' s resolve any exits that go to other TMX locations .
def finished_init
      super
      exits = []
      return unless @state["tile_layout_type"] == "manasource"
      zone_contents = self.zone.contents
      tile_cache_entry["objects"].select { |obj| obj["type"].downcase == "warp" }.each do |obj|
        next unless obj["properties"]
        dest_map_name = obj["properties"]["dest_map"]
        dest_location = zone_contents.detect { |loc| loc.is_a?(::Demiurge::Tmx::TmxLocation) && loc.tile_cache_entry["tmx_name"] == dest_map_name }
        if dest_location
          dest_position = "#{dest_location.name}##{obj["properties"]["dest_x"]},#{obj["properties"]["dest_y"]}"
          src_x_coord = obj["x"] / tile_cache_entry["tilewidth"]
          src_y_coord = obj["y"] / tile_cache_entry["tileheight"]
          src_position = "#{name}##{src_x_coord},#{src_y_coord}"
          raise("Exit destination position #{dest_position.inspect} loaded from TMX location #{name.inspect} (TMX: #{tile_cache_entry["filename"]}) is not valid!") unless dest_location.valid_position?(dest_position)
          exits.push({ src_loc: self, src_pos: src_position, dest_pos: dest_position })
        else
          @engine.admin_warning "Unresolved TMX exit in #{name.inspect}: #{obj["properties"].inspect}!",
                                "location" => name, "properties" => obj["properties"]
        end
      end
      exits.each do |exit|
        exit[:src_loc].add_exit(from: exit[:src_pos], to: exit[:dest_pos])
      end
    end
def finished_init super exits = [ ] return unless @state [ "tile_layout_type" ] == "manasource" zone_contents = self . zone . contents tile_cache_entry [ "objects" ] . select { | obj | obj [ "type" ] . downcase == "warp" } . each do | obj | next unless obj [ "properties" ] dest_map_name = obj [ "properties" ] [ "dest_map" ] dest_location = zone_contents . detect { | loc | loc . is_a? ( :: Demiurge :: Tmx :: TmxLocation ) && loc . tile_cache_entry [ "tmx_name" ] == dest_map_name } if dest_location dest_position = "#{dest_location.name}##{obj["properties"]["dest_x"]},#{obj["properties"]["dest_y"]}" src_x_coord = obj [ "x" ] / tile_cache_entry [ "tilewidth" ] src_y_coord = obj [ "y" ] / tile_cache_entry [ "tileheight" ] src_position = "#{name}##{src_x_coord},#{src_y_coord}" raise ( "Exit destination position #{dest_position.inspect} loaded from TMX location #{name.inspect} (TMX: #{tile_cache_entry["filename"]}) is not valid!" ) unless dest_location . valid_position? ( dest_position ) exits . push ( { src_loc : self , src_pos : src_position , dest_pos : dest_position } ) else @engine . admin_warning "Unresolved TMX exit in #{name.inspect}: #{obj["properties"].inspect}!" , "location" => name , "properties" => obj [ "properties" ] end end exits . each do | exit | exit [ :src_loc ] . add_exit ( from : exit [ :src_pos ] , to : exit [ :dest_pos ] ) end end
Let's resolve any exits that go to other TMX locations.
Let ' s resolve any exits that go to other TMX locations .
# Go through the contents looking for locations # ManaSource locations often store exits as objects in an # object layer.  They don't cope with multiple locations that # use the same TMX file since they identify the destination by # the TMX filename.  In Demiurge, we don't let them cross zone # boundaries to avoid unexpected behavior in other folks' # zones.
since
None