mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-23 22:17:31 +00:00
de5d9182eb
* 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.
75 lines
1.8 KiB
C++
75 lines
1.8 KiB
C++
#include "BuildBorderComponent.h"
|
|
|
|
#include "EntityManager.h"
|
|
#include "GameMessages.h"
|
|
#include "Entity.h"
|
|
#include "Game.h"
|
|
#include "dLogger.h"
|
|
#include "InventoryComponent.h"
|
|
#include "Item.h"
|
|
#include "PropertyManagementComponent.h"
|
|
|
|
BuildBorderComponent::BuildBorderComponent(Entity* parent) : Component(parent)
|
|
{
|
|
}
|
|
|
|
BuildBorderComponent::~BuildBorderComponent()
|
|
{
|
|
}
|
|
|
|
void BuildBorderComponent::OnUse(Entity* originator) {
|
|
if (originator->GetCharacter()) {
|
|
const auto& entities = EntityManager::Instance()->GetEntitiesInGroup("PropertyPlaque");
|
|
|
|
auto buildArea = m_Parent->GetObjectID();
|
|
|
|
if (!entities.empty())
|
|
{
|
|
buildArea = entities[0]->GetObjectID();
|
|
|
|
Game::logger->Log("BuildBorderComponent", "Using PropertyPlaque\n");
|
|
}
|
|
|
|
auto* inventoryComponent = originator->GetComponent<InventoryComponent>();
|
|
|
|
if (inventoryComponent == nullptr) {
|
|
return;
|
|
}
|
|
|
|
auto* thinkingHat = inventoryComponent->FindItemByLot(6086);
|
|
|
|
if (thinkingHat == nullptr) {
|
|
return;
|
|
}
|
|
|
|
inventoryComponent->PushEquippedItems();
|
|
|
|
Game::logger->Log("BuildBorderComponent", "Starting with %llu\n", buildArea);
|
|
|
|
if (PropertyManagementComponent::Instance() != nullptr) {
|
|
GameMessages::SendStartArrangingWithItem(
|
|
originator,
|
|
originator->GetSystemAddress(),
|
|
true,
|
|
buildArea,
|
|
originator->GetPosition(),
|
|
0,
|
|
thinkingHat->GetId(),
|
|
thinkingHat->GetLot(),
|
|
4,
|
|
0,
|
|
-1,
|
|
NiPoint3::ZERO,
|
|
0
|
|
);
|
|
}
|
|
else {
|
|
GameMessages::SendStartArrangingWithItem(originator, originator->GetSystemAddress(), true, buildArea, originator->GetPosition());
|
|
}
|
|
|
|
InventoryComponent* inv = m_Parent->GetComponent<InventoryComponent>();
|
|
if (!inv) return;
|
|
inv->PushEquippedItems(); // technically this is supposed to happen automatically... but it doesnt? so just keep this here
|
|
}
|
|
}
|