diff options
Diffstat (limited to 'src/game_data.cpp')
| -rw-r--r-- | src/game_data.cpp | 62 |
1 files changed, 61 insertions, 1 deletions
| 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 { | |||
| 44 | std::vector<Door> doors_; | 44 | std::vector<Door> doors_; |
| 45 | std::vector<Panel> panels_; | 45 | std::vector<Panel> panels_; |
| 46 | std::vector<MapArea> map_areas_; | 46 | std::vector<MapArea> map_areas_; |
| 47 | std::vector<SubwayItem> subway_items_; | ||
| 47 | 48 | ||
| 48 | std::map<std::string, int> room_by_id_; | 49 | std::map<std::string, int> room_by_id_; |
| 49 | std::map<std::string, int> door_by_id_; | 50 | std::map<std::string, int> door_by_id_; |
| @@ -606,6 +607,56 @@ struct GameData { | |||
| 606 | errstr << "Area data not found for: " << area; | 607 | errstr << "Area data not found for: " << area; |
| 607 | TrackerLog(errstr.str()); | 608 | TrackerLog(errstr.str()); |
| 608 | } | 609 | } |
| 610 | |||
| 611 | // Read in subway items. | ||
| 612 | YAML::Node subway_config = | ||
| 613 | YAML::LoadFile(GetAbsolutePath("assets/subway.yaml")); | ||
| 614 | for (const auto &subway_it : subway_config) { | ||
| 615 | SubwayItem subway_item; | ||
| 616 | subway_item.id = subway_items_.size(); | ||
| 617 | subway_item.x = subway_it["pos"][0].as<int>(); | ||
| 618 | subway_item.y = subway_it["pos"][1].as<int>(); | ||
| 619 | |||
| 620 | if (subway_it["door"]) { | ||
| 621 | subway_item.door = AddOrGetDoor(subway_it["room"].as<std::string>(), | ||
| 622 | subway_it["door"].as<std::string>()); | ||
| 623 | } | ||
| 624 | |||
| 625 | if (subway_it["paintings"]) { | ||
| 626 | for (const auto &painting_it : subway_it["paintings"]) { | ||
| 627 | subway_item.paintings.push_back(painting_it.as<std::string>()); | ||
| 628 | } | ||
| 629 | } | ||
| 630 | |||
| 631 | if (subway_it["tags"]) { | ||
| 632 | for (const auto &tag_it : subway_it["tags"]) { | ||
| 633 | subway_item.tags.push_back(tag_it.as<std::string>()); | ||
| 634 | } | ||
| 635 | } | ||
| 636 | |||
| 637 | if (subway_it["sunwarp"]) { | ||
| 638 | SubwaySunwarp sunwarp; | ||
| 639 | sunwarp.dots = subway_it["sunwarp"]["dots"].as<int>(); | ||
| 640 | |||
| 641 | std::string sunwarp_type = | ||
| 642 | subway_it["sunwarp"]["type"].as<std::string>(); | ||
| 643 | if (sunwarp_type == "final") { | ||
| 644 | sunwarp.type = SubwaySunwarpType::kFinal; | ||
| 645 | } else if (sunwarp_type == "exit") { | ||
| 646 | sunwarp.type = SubwaySunwarpType::kExit; | ||
| 647 | } else { | ||
| 648 | sunwarp.type = SubwaySunwarpType::kEnter; | ||
| 649 | } | ||
| 650 | |||
| 651 | subway_item.sunwarp = sunwarp; | ||
| 652 | } | ||
| 653 | |||
| 654 | if (subway_it["special"]) { | ||
| 655 | subway_item.special = subway_it["special"].as<std::string>(); | ||
| 656 | } | ||
| 657 | |||
| 658 | subway_items_.push_back(subway_item); | ||
| 659 | } | ||
| 609 | } | 660 | } |
| 610 | 661 | ||
| 611 | int AddOrGetRoom(std::string room) { | 662 | int AddOrGetRoom(std::string room) { |
| @@ -621,8 +672,9 @@ struct GameData { | |||
| 621 | std::string full_name = room + " - " + door; | 672 | std::string full_name = room + " - " + door; |
| 622 | 673 | ||
| 623 | if (!door_by_id_.count(full_name)) { | 674 | if (!door_by_id_.count(full_name)) { |
| 675 | int door_id = doors_.size(); | ||
| 624 | door_by_id_[full_name] = doors_.size(); | 676 | door_by_id_[full_name] = doors_.size(); |
| 625 | doors_.push_back({.room = AddOrGetRoom(room), .name = door}); | 677 | doors_.push_back({.id = door_id, .room = AddOrGetRoom(room), .name = door}); |
| 626 | } | 678 | } |
| 627 | 679 | ||
| 628 | return door_by_id_[full_name]; | 680 | return door_by_id_[full_name]; |
| @@ -704,3 +756,11 @@ const std::vector<int> &GD_GetSunwarpDoors() { | |||
| 704 | int GD_GetRoomForSunwarp(int index) { | 756 | int GD_GetRoomForSunwarp(int index) { |
| 705 | return GetState().room_by_sunwarp_.at(index); | 757 | return GetState().room_by_sunwarp_.at(index); |
| 706 | } | 758 | } |
| 759 | |||
| 760 | const std::vector<SubwayItem> &GD_GetSubwayItems() { | ||
| 761 | return GetState().subway_items_; | ||
| 762 | } | ||
| 763 | |||
| 764 | const SubwayItem &GD_GetSubwayItem(int id) { | ||
| 765 | return GetState().subway_items_.at(id); | ||
| 766 | } | ||
