Turned Town Map PBS data into a GameData class

This commit is contained in:
Maruno17
2022-11-20 21:44:53 +00:00
parent f33eb4d896
commit 4d147a7bf7
27 changed files with 127 additions and 205 deletions

View File

@@ -246,6 +246,7 @@ module GameData
# A bulk loader method for all data stored in .dat files in the Data folder.
#=============================================================================
def self.load_all
TownMap.load
Type.load
Ability.load
Move.load

View File

@@ -2,7 +2,6 @@
# Data caches.
#===============================================================================
class Game_Temp
attr_accessor :town_map_data
attr_accessor :regional_dexes_data
attr_accessor :battle_animations_data
attr_accessor :move_to_battle_animation_data
@@ -11,7 +10,6 @@ end
def pbClearData
if $game_temp
$game_temp.town_map_data = nil
$game_temp.regional_dexes_data = nil
$game_temp.battle_animations_data = nil
$game_temp.move_to_battle_animation_data = nil
@@ -24,17 +22,6 @@ def pbClearData
end
end
#===============================================================================
# Method to get Town Map data.
#===============================================================================
def pbLoadTownMapData
$game_temp = Game_Temp.new if !$game_temp
if !$game_temp.town_map_data
$game_temp.town_map_data = load_data("Data/town_map.dat")
end
return $game_temp.town_map_data
end
#===============================================================================
# Method to get Regional Dexes data.
#===============================================================================

View File

@@ -0,0 +1,40 @@
module GameData
class TownMap
attr_reader :id
attr_reader :real_name
attr_reader :filename
attr_reader :point
attr_reader :flags
DATA = {}
DATA_FILENAME = "town_map.dat"
SCHEMA = {
"SectionName" => [:id, "u"],
"Name" => [:real_name, "s"],
"Filename" => [:filename, "s"],
"Point" => [:point, "^uussUUUU"],
"Flags" => [:flags, "*s"]
}
extend ClassMethodsIDNumbers
include InstanceMethods
def initialize(hash)
@id = hash[:id]
@real_name = hash[:real_name] || "???"
@filename = hash[:filename]
@point = hash[:point] || []
@flags = hash[:flags] || []
end
# @return [String] the translated name of this region
def name
return pbGetMessage(MessageTypes::RegionNames, @id)
end
def has_flag?(flag)
return @flags.any? { |f| f.downcase == flag.downcase }
end
end
end