DarkflameServer/dGame/dComponents/BuildBorderComponent.cpp

49 lines
1.3 KiB
C++
Raw Normal View History

#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"
void BuildBorderComponent::OnUse(Entity* originator) {
2023-06-27 04:58:56 +00:00
if (!originator->GetCharacter()) return;
2023-06-27 04:58:56 +00:00
const auto& entities = EntityManager::Instance()->GetEntitiesInGroup("PropertyPlaque");
2023-06-27 04:58:56 +00:00
auto buildArea = entities.empty() ? m_ParentEntity->GetObjectID() : entities.front()->GetObjectID();
2023-06-27 04:58:56 +00:00
auto* inventoryComponent = originator->GetComponent<InventoryComponent>();
2023-06-27 04:58:56 +00:00
if (!inventoryComponent) return;
2023-06-27 04:58:56 +00:00
auto* thinkingHat = inventoryComponent->FindItemByLot(LOT_THINKING_CAP);
2023-06-27 04:58:56 +00:00
if (!thinkingHat) return;
2023-06-27 04:58:56 +00:00
Game::logger->Log("BuildBorderComponent", "Using BuildArea %llu for player %llu", buildArea, originator->GetObjectID());
2023-06-27 04:58:56 +00:00
inventoryComponent->PushEquippedItems();
2023-06-27 04:58:56 +00:00
if (PropertyManagementComponent::Instance()) {
GameMessages::SendStartArrangingWithItem(
originator,
originator->GetSystemAddress(),
true,
buildArea,
originator->GetPosition(),
0,
thinkingHat->GetId(),
thinkingHat->GetLot(),
4,
0,
-1
);
} else {
GameMessages::SendStartArrangingWithItem(originator, originator->GetSystemAddress(), true, buildArea, originator->GetPosition());
}
}