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.
This commit is contained in:
David Markowitz 2022-07-06 01:30:13 -07:00 committed by GitHub
parent 3cf243b1d7
commit de5d9182eb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 0 deletions

View File

@ -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) {

View File

@ -1158,6 +1158,18 @@ void InventoryComponent::PopEquippedItems()
item->Equip();
}
m_Pushed.clear();
auto destroyableComponent = m_Parent->GetComponent<DestroyableComponent>();
// Reset stats to full
if (destroyableComponent) {
destroyableComponent->SetHealth(static_cast<int32_t>(destroyableComponent->GetMaxHealth()));
destroyableComponent->SetArmor(static_cast<int32_t>(destroyableComponent->GetMaxArmor()));
destroyableComponent->SetImagination(static_cast<int32_t>(destroyableComponent->GetMaxImagination()));
EntityManager::Instance()->SerializeEntity(m_Parent);
}
m_Dirty = true;
}

View File

@ -286,6 +286,10 @@ void PropertyManagementComponent::OnStartBuilding()
player->SendToZone(zoneId);
}
auto inventoryComponent = ownerEntity->GetComponent<InventoryComponent>();
// Push equipped items
if (inventoryComponent) inventoryComponent->PushEquippedItems();
}
void PropertyManagementComponent::OnFinishBuilding()