From de5d9182eb8daeb69c9e2a4a7dff907a06a1c7d2 Mon Sep 17 00:00:00 2001 From: David Markowitz <39972741+EmosewaMC@users.noreply.github.com> Date: Wed, 6 Jul 2022 01:30:13 -0700 Subject: [PATCH] Address items not re-equipping upon exiting build mode (#615) * Implement Precompiled Headers * fix cmake * Fix modular builds not returning parts Modular builds would not search inventory A for their corresponding item and by default would only look in the models bag. This PR forces the item to be looked for in the inventory its coming from (inventoryA) as a second resort before doing the final search in the default inventory of the item. Tested modular building a car and a rocket and when replacing parts the part that was already placed was returned to the inventory correctly. * Push equipped items upon entering build mode Fixes an issue where leaving build mode anywhere would not re-equip your items. This also implements the feature to set your stats back to full, as was done in the live game. Tested exiting build mode on a property with full venture gear and all gear was re-equipped and stats were set to the expected values. --- dGame/dComponents/BuildBorderComponent.cpp | 2 ++ dGame/dComponents/InventoryComponent.cpp | 12 ++++++++++++ dGame/dComponents/PropertyManagementComponent.cpp | 4 ++++ 3 files changed, 18 insertions(+) diff --git a/dGame/dComponents/BuildBorderComponent.cpp b/dGame/dComponents/BuildBorderComponent.cpp index ed2fe2d2..1747f0ed 100644 --- a/dGame/dComponents/BuildBorderComponent.cpp +++ b/dGame/dComponents/BuildBorderComponent.cpp @@ -42,6 +42,8 @@ void BuildBorderComponent::OnUse(Entity* originator) { return; } + inventoryComponent->PushEquippedItems(); + Game::logger->Log("BuildBorderComponent", "Starting with %llu\n", buildArea); if (PropertyManagementComponent::Instance() != nullptr) { diff --git a/dGame/dComponents/InventoryComponent.cpp b/dGame/dComponents/InventoryComponent.cpp index 950536ab..8ae6e93f 100644 --- a/dGame/dComponents/InventoryComponent.cpp +++ b/dGame/dComponents/InventoryComponent.cpp @@ -1158,6 +1158,18 @@ void InventoryComponent::PopEquippedItems() item->Equip(); } + m_Pushed.clear(); + + auto destroyableComponent = m_Parent->GetComponent(); + + // Reset stats to full + if (destroyableComponent) { + destroyableComponent->SetHealth(static_cast(destroyableComponent->GetMaxHealth())); + destroyableComponent->SetArmor(static_cast(destroyableComponent->GetMaxArmor())); + destroyableComponent->SetImagination(static_cast(destroyableComponent->GetMaxImagination())); + EntityManager::Instance()->SerializeEntity(m_Parent); + } + m_Dirty = true; } diff --git a/dGame/dComponents/PropertyManagementComponent.cpp b/dGame/dComponents/PropertyManagementComponent.cpp index 04e2f633..f27ea283 100644 --- a/dGame/dComponents/PropertyManagementComponent.cpp +++ b/dGame/dComponents/PropertyManagementComponent.cpp @@ -286,6 +286,10 @@ void PropertyManagementComponent::OnStartBuilding() player->SendToZone(zoneId); } + auto inventoryComponent = ownerEntity->GetComponent(); + + // Push equipped items + if (inventoryComponent) inventoryComponent->PushEquippedItems(); } void PropertyManagementComponent::OnFinishBuilding()