diff --git a/.gitignore b/.gitignore index 97f732be..b489031a 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ documentation/ *swp *.user* .DS_Store +.vscode/ diff --git a/rwengine/CMakeLists.txt b/rwengine/CMakeLists.txt index efc6fc59..fb60d181 100644 --- a/rwengine/CMakeLists.txt +++ b/rwengine/CMakeLists.txt @@ -61,8 +61,8 @@ set(RWENGINE_SOURCES src/engine/GameState.hpp src/engine/GameWorld.cpp src/engine/GameWorld.hpp - src/engine/GarageController.cpp - src/engine/GarageController.hpp + src/engine/Garage.cpp + src/engine/Garage.hpp src/engine/Payphone.cpp src/engine/Payphone.hpp src/engine/SaveGame.cpp diff --git a/rwengine/src/engine/GameState.hpp b/rwengine/src/engine/GameState.hpp index 077cbe96..c29ceeb6 100644 --- a/rwengine/src/engine/GameState.hpp +++ b/rwengine/src/engine/GameState.hpp @@ -211,56 +211,6 @@ struct BlipData { } }; -enum class GarageType { - Mission = 1, - BombShop1 = 2, - BombShop2 = 3, - BombShop3 = 4, - Respray = 5, - CollectCars1 = 8, - CollectCars2 = 9, - MissionForCarToComeOut = 11, - Crusher = 13, - MissionKeepCar = 14, - Hideout1 = 16, - Hideout2 = 17, - Hideout3 = 18, - MissionToOpenAndClose = 19, - MissionForSpecificCar = 20, - MissionKeepCarAndRemainClosed = 21, -}; - -enum class GarageState { Closed, Closing, Opening, Opened }; - -/** - * Data for garages - */ -struct GarageInfo { - GarageType type; - - int id; - glm::vec3 min; - glm::vec3 max; - - GameObject* target; - - GarageState state; - - GarageInfo(int id_, const glm::vec3 min_, const glm::vec3 max_, - GarageType type_) - : type(type_) - , id(id_) - , min(min_) - , max(max_) - , target(nullptr) - , state(GarageState::Closed) { - } - - int getScriptObjectID() const { - return id; - } -}; - enum class HudFlash { Disabled = -1, FlashArmor = 3, @@ -406,8 +356,6 @@ public: std::map radarBlips; - std::vector garages; - /** * Bitsets for the car import / export list mission */ diff --git a/rwengine/src/engine/GameWorld.cpp b/rwengine/src/engine/GameWorld.cpp index 288ad22d..5c6d77d8 100644 --- a/rwengine/src/engine/GameWorld.cpp +++ b/rwengine/src/engine/GameWorld.cpp @@ -386,77 +386,11 @@ PickupObject* GameWorld::createPickup(const glm::vec3& pos, int id, int type) { return pickup; } -GarageInfo* GameWorld::createGarage(const glm::vec3 coord0, - const glm::vec3 coord1, const int type) { - glm::vec3 min; - glm::vec3 max; - glm::vec3 midpoint; - - min.x = std::min(coord0.x, coord1.x); - min.y = std::min(coord0.y, coord1.y); - min.z = std::min(coord0.z, coord1.z); - - max.x = std::max(coord0.x, coord1.x); - max.y = std::max(coord0.y, coord1.y); - max.z = std::max(coord0.z, coord1.z); - - midpoint.x = (min.x + max.x) / 2; - midpoint.y = (min.y + max.y) / 2; - midpoint.z = (min.z + max.z) / 2; - - // Find door object for this garage - InstanceObject* door = nullptr; - - for (auto p : instancePool.objects) { - auto o = p.second; - if (!o->getModel()) continue; - if (!SimpleModelInfo::isDoorModel( - o->getModelInfo()->name)) - continue; - - // Is this how the game finds door object? - if (glm::distance(midpoint, o->getPosition()) < 20.f) { - door = static_cast(o); - } - } - - // Create garage - int id = state->garages.size(); - GarageInfo* info = - new GarageInfo{id, min, max, static_cast(type)}; - state->garages.push_back(*info); - - switch (static_cast(type)) { - case GarageType::Mission: - case GarageType::CollectCars1: - case GarageType::CollectCars2: - case GarageType::MissionForCarToComeOut: - case GarageType::MissionKeepCar: - case GarageType::Hideout1: - case GarageType::Hideout2: - case GarageType::Hideout3: - case GarageType::MissionToOpenAndClose: - case GarageType::MissionForSpecificCar: - case GarageType::MissionKeepCarAndRemainClosed: { - info->state = GarageState::Closed; - break; - } - - case GarageType::BombShop1: - case GarageType::BombShop2: - case GarageType::BombShop3: - case GarageType::Respray: - case GarageType::Crusher: { - info->state = GarageState::Opened; - break; - } - } - - // Create controller - garageControllers.push_back( - std::make_unique(GarageController(this, info, door))); - - return info; +Garage* GameWorld::createGarage(const glm::vec3 coord0, const glm::vec3 coord1, + Garage::Type type) { + const int id = garages.size(); + garages.emplace_back(std::make_unique(this, id, coord0, coord1, type)); + return garages.back().get(); } Payphone* GameWorld::createPayphone(const glm::vec2 coord) { diff --git a/rwengine/src/engine/GameWorld.hpp b/rwengine/src/engine/GameWorld.hpp index 41e144f7..d3bbc941 100644 --- a/rwengine/src/engine/GameWorld.hpp +++ b/rwengine/src/engine/GameWorld.hpp @@ -17,7 +17,7 @@ #include #include