diff --git a/src/TableData.cpp b/src/TableData.cpp index 0a8b1d3..5139404 100644 --- a/src/TableData.cpp +++ b/src/TableData.cpp @@ -13,6 +13,7 @@ #include std::map> TableData::RunningSkywayRoutes; +std::map TableData::RunningNPCRotations; void TableData::init() { int32_t nextId = 0; @@ -364,6 +365,17 @@ void TableData::loadGruntwork() { RunningSkywayRoutes[(int)route["iRouteID"]] = points; } + // npc rotations + auto npcRot = gruntwork["rotations"]; + for (auto _rot = npcRot.begin(); _rot != npcRot.end(); _rot++) { + int32_t npcID = _rot.value()["iNPCID"]; + int angle = _rot.value()["iAngle"]; + if (NPCManager::NPCs.find(npcID) == NPCManager::NPCs.end()) + continue; // NPC not found + BaseNPC* npc = NPCManager::NPCs[npcID]; + npc->appearanceData.iAngle = angle; + } + std::cout << "[INFO] Loaded gruntwork.json" << std::endl; } catch (const std::exception& err) { @@ -396,5 +408,14 @@ void TableData::flush() { gruntwork["skyway"].push_back(route); } + for (auto& pair : RunningNPCRotations) { + nlohmann::json rotation; + + rotation["iNPCID"] = (int)pair.first; + rotation["iAngle"] = pair.second; + + gruntwork["rotations"].push_back(rotation); + } + file << gruntwork << std::endl; } diff --git a/src/TableData.hpp b/src/TableData.hpp index 2913f87..09f2ccf 100644 --- a/src/TableData.hpp +++ b/src/TableData.hpp @@ -6,6 +6,7 @@ namespace TableData { extern std::map> RunningSkywayRoutes; + extern std::map RunningNPCRotations; void init(); void cleanup();