2021-12-05 17:54:36 +00:00
|
|
|
#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"
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
BuildBorderComponent::BuildBorderComponent(Entity* parent) : Component(parent) {
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
BuildBorderComponent::~BuildBorderComponent() {
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void BuildBorderComponent::OnUse(Entity* originator) {
|
|
|
|
if (originator->GetCharacter()) {
|
|
|
|
const auto& entities = EntityManager::Instance()->GetEntitiesInGroup("PropertyPlaque");
|
|
|
|
|
2023-06-09 09:46:01 +00:00
|
|
|
auto buildArea = m_ParentEntity->GetObjectID();
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
if (!entities.empty()) {
|
2021-12-05 17:54:36 +00:00
|
|
|
buildArea = entities[0]->GetObjectID();
|
2022-07-25 02:26:51 +00:00
|
|
|
|
|
|
|
Game::logger->Log("BuildBorderComponent", "Using PropertyPlaque");
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|
|
|
|
|
2023-06-09 08:27:05 +00:00
|
|
|
auto* inventoryComponent = originator->GetComponent<InventoryComponent>();
|
2021-12-05 17:54:36 +00:00
|
|
|
|
|
|
|
if (inventoryComponent == nullptr) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto* thinkingHat = inventoryComponent->FindItemByLot(6086);
|
|
|
|
|
|
|
|
if (thinkingHat == nullptr) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-07-06 08:30:13 +00:00
|
|
|
inventoryComponent->PushEquippedItems();
|
|
|
|
|
2022-07-25 02:26:51 +00:00
|
|
|
Game::logger->Log("BuildBorderComponent", "Starting with %llu", buildArea);
|
2021-12-05 17:54:36 +00:00
|
|
|
|
|
|
|
if (PropertyManagementComponent::Instance() != nullptr) {
|
|
|
|
GameMessages::SendStartArrangingWithItem(
|
|
|
|
originator,
|
|
|
|
originator->GetSystemAddress(),
|
|
|
|
true,
|
|
|
|
buildArea,
|
|
|
|
originator->GetPosition(),
|
|
|
|
0,
|
|
|
|
thinkingHat->GetId(),
|
|
|
|
thinkingHat->GetLot(),
|
|
|
|
4,
|
|
|
|
0,
|
|
|
|
-1,
|
|
|
|
NiPoint3::ZERO,
|
|
|
|
0
|
|
|
|
);
|
2022-07-28 13:39:57 +00:00
|
|
|
} else {
|
2021-12-05 17:54:36 +00:00
|
|
|
GameMessages::SendStartArrangingWithItem(originator, originator->GetSystemAddress(), true, buildArea, originator->GetPosition());
|
|
|
|
}
|
|
|
|
|
2023-06-09 09:46:01 +00:00
|
|
|
auto* inv = m_ParentEntity->GetComponent<InventoryComponent>();
|
2021-12-05 17:54:36 +00:00
|
|
|
if (!inv) return;
|
|
|
|
inv->PushEquippedItems(); // technically this is supposed to happen automatically... but it doesnt? so just keep this here
|
|
|
|
}
|
|
|
|
}
|