From ea16cff14ff4faf5782da8ff684a6ec412b7b6ac Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Sun, 12 May 2024 17:48:02 -0400 Subject: Started making subway map --- src/game_data.cpp | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 61 insertions(+), 1 deletion(-) (limited to 'src/game_data.cpp') diff --git a/src/game_data.cpp b/src/game_data.cpp index c98f532..4348967 100644 --- a/src/game_data.cpp +++ b/src/game_data.cpp @@ -44,6 +44,7 @@ struct GameData { std::vector doors_; std::vector panels_; std::vector map_areas_; + std::vector subway_items_; std::map room_by_id_; std::map door_by_id_; @@ -606,6 +607,56 @@ struct GameData { errstr << "Area data not found for: " << area; TrackerLog(errstr.str()); } + + // Read in subway items. + YAML::Node subway_config = + YAML::LoadFile(GetAbsolutePath("assets/subway.yaml")); + for (const auto &subway_it : subway_config) { + SubwayItem subway_item; + subway_item.id = subway_items_.size(); + subway_item.x = subway_it["pos"][0].as(); + subway_item.y = subway_it["pos"][1].as(); + + if (subway_it["door"]) { + subway_item.door = AddOrGetDoor(subway_it["room"].as(), + subway_it["door"].as()); + } + + if (subway_it["paintings"]) { + for (const auto &painting_it : subway_it["paintings"]) { + subway_item.paintings.push_back(painting_it.as()); + } + } + + if (subway_it["tags"]) { + for (const auto &tag_it : subway_it["tags"]) { + subway_item.tags.push_back(tag_it.as()); + } + } + + if (subway_it["sunwarp"]) { + SubwaySunwarp sunwarp; + sunwarp.dots = subway_it["sunwarp"]["dots"].as(); + + std::string sunwarp_type = + subway_it["sunwarp"]["type"].as(); + if (sunwarp_type == "final") { + sunwarp.type = SubwaySunwarpType::kFinal; + } else if (sunwarp_type == "exit") { + sunwarp.type = SubwaySunwarpType::kExit; + } else { + sunwarp.type = SubwaySunwarpType::kEnter; + } + + subway_item.sunwarp = sunwarp; + } + + if (subway_it["special"]) { + subway_item.special = subway_it["special"].as(); + } + + subway_items_.push_back(subway_item); + } } int AddOrGetRoom(std::string room) { @@ -621,8 +672,9 @@ struct GameData { std::string full_name = room + " - " + door; if (!door_by_id_.count(full_name)) { + int door_id = doors_.size(); door_by_id_[full_name] = doors_.size(); - doors_.push_back({.room = AddOrGetRoom(room), .name = door}); + doors_.push_back({.id = door_id, .room = AddOrGetRoom(room), .name = door}); } return door_by_id_[full_name]; @@ -704,3 +756,11 @@ const std::vector &GD_GetSunwarpDoors() { int GD_GetRoomForSunwarp(int index) { return GetState().room_by_sunwarp_.at(index); } + +const std::vector &GD_GetSubwayItems() { + return GetState().subway_items_; +} + +const SubwayItem &GD_GetSubwayItem(int id) { + return GetState().subway_items_.at(id); +} -- cgit 1.4.1