diff options
author | Star Rauchenberger <fefferburbia@gmail.com> | 2023-05-02 10:07:25 -0400 |
---|---|---|
committer | Star Rauchenberger <fefferburbia@gmail.com> | 2023-05-02 10:07:25 -0400 |
commit | 9f25878acfe1c7281a96f83742349516510c5b6d (patch) | |
tree | d68daca94d65ac97fe9ac0a87fb0a3f95f4b6fea /game_data.cpp | |
parent | 531898b0fef9f81e82ad5d5f38d2c627a0c10e56 (diff) | |
download | lingo-ap-tracker-9f25878acfe1c7281a96f83742349516510c5b6d.tar.gz lingo-ap-tracker-9f25878acfe1c7281a96f83742349516510c5b6d.tar.bz2 lingo-ap-tracker-9f25878acfe1c7281a96f83742349516510c5b6d.zip |
Added areas to map
Diffstat (limited to 'game_data.cpp')
-rw-r--r-- | game_data.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/game_data.cpp b/game_data.cpp index 0ae5468..f377e0b 100644 --- a/game_data.cpp +++ b/game_data.cpp | |||
@@ -217,6 +217,21 @@ GameData::GameData() { | |||
217 | } | 217 | } |
218 | } | 218 | } |
219 | } | 219 | } |
220 | |||
221 | map_areas_.reserve(areas_config.size()); | ||
222 | |||
223 | std::map<std::string, int> fold_areas; | ||
224 | for (const auto &area_it : areas_config) { | ||
225 | if (area_it.second["map"]) { | ||
226 | int area_id = AddOrGetArea(area_it.first.as<std::string>()); | ||
227 | MapArea &area_obj = map_areas_[area_id]; | ||
228 | area_obj.map_x = area_it.second["map"][0].as<int>(); | ||
229 | area_obj.map_y = area_it.second["map"][1].as<int>(); | ||
230 | } else if (area_it.second["fold_into"]) { | ||
231 | fold_areas[area_it.first.as<std::string>()] = | ||
232 | AddOrGetArea(area_it.second["fold_into"].as<std::string>()); | ||
233 | } | ||
234 | } | ||
220 | } | 235 | } |
221 | 236 | ||
222 | int GameData::AddOrGetRoom(std::string room) { | 237 | int GameData::AddOrGetRoom(std::string room) { |
@@ -250,6 +265,16 @@ int GameData::AddOrGetPanel(std::string room, std::string panel) { | |||
250 | return panel_by_id_[full_name]; | 265 | return panel_by_id_[full_name]; |
251 | } | 266 | } |
252 | 267 | ||
268 | int GameData::AddOrGetArea(std::string area) { | ||
269 | if (!area_by_id_.count(area)) { | ||
270 | area_by_id_[area] = map_areas_.size(); | ||
271 | map_areas_.push_back( | ||
272 | {.id = static_cast<int>(map_areas_.size()), .name = area}); | ||
273 | } | ||
274 | |||
275 | return area_by_id_[area]; | ||
276 | } | ||
277 | |||
253 | const GameData &GetGameData() { | 278 | const GameData &GetGameData() { |
254 | static GameData *instance = new GameData(); | 279 | static GameData *instance = new GameData(); |
255 | return *instance; | 280 | return *instance; |