class RPG::Map

Public Class Methods

new(hash) click to toggle source
# File lib/rmxp_extractor/classnames.rb, line 399
def initialize(hash)
  @tileset_id = hash["tileset_id"]
  @width = hash["width"]
  @height = hash["height"]
  @autoplay_bgm = hash["autoplay_bgm"]
  @autoplay_bgs = hash["autoplay_bgs"]
  @bgm = RPG::AudioFile.new hash["bgm"]
  @bgs = RPG::AudioFile.new hash["bgs"]
  @encounter_list = hash["encounter_list"]
  @encounter_step = hash["encounter_step"]
  @data = Table.new(hash["data"], false)
  @events = {}
  events = hash["events"].sort_by { |key| key }.to_h
  events.each do |key, value|
    @events[key.to_i] = RPG::Event.new value
  end
end

Public Instance Methods

hash() click to toggle source
# File lib/rmxp_extractor/classnames.rb, line 417
def hash
  dump = {
    tileset_id: @tileset_id,
    width: @width,
    height: @height,
    autoplay_bgm: @autoplay_bgm,
    bgm: @bgm.hash,
    autoplay_bgs: @autoplay_bgs,
    bgs: @bgs.hash,
    encounter_list: @encounter_list,
    encounter_step: @encounter_step,
    events: {},
    data: @data.hash,
  }
  events = @events.sort_by { |key| key }.to_h
  events.each do |key, value|
    dump[:events][key] = value.hash
  end
  dump
end