2021-12-05 17:54:36 +00:00
|
|
|
#include "PropertyVendorComponent.h"
|
|
|
|
|
|
|
|
#include "PropertyDataMessage.h"
|
|
|
|
#include "GameMessages.h"
|
|
|
|
#include "Character.h"
|
|
|
|
#include "EntityManager.h"
|
|
|
|
#include "dZoneManager.h"
|
|
|
|
#include "Game.h"
|
2023-10-21 23:31:55 +00:00
|
|
|
#include "Logger.h"
|
2021-12-05 17:54:36 +00:00
|
|
|
#include "PropertyManagementComponent.h"
|
|
|
|
#include "UserManager.h"
|
|
|
|
|
|
|
|
PropertyVendorComponent::PropertyVendorComponent(Entity* parent) : Component(parent) {
|
|
|
|
}
|
|
|
|
|
|
|
|
void PropertyVendorComponent::OnUse(Entity* originator) {
|
|
|
|
if (PropertyManagementComponent::Instance() == nullptr) return;
|
|
|
|
|
|
|
|
OnQueryPropertyData(originator, originator->GetSystemAddress());
|
|
|
|
|
|
|
|
if (PropertyManagementComponent::Instance()->GetOwnerId() == LWOOBJID_EMPTY) {
|
2024-03-14 01:47:41 +00:00
|
|
|
Log::Info("Property vendor opening!");
|
2021-12-05 17:54:36 +00:00
|
|
|
|
|
|
|
GameMessages::SendOpenPropertyVendor(m_Parent->GetObjectID(), originator->GetSystemAddress());
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void PropertyVendorComponent::OnQueryPropertyData(Entity* originator, const SystemAddress& sysAddr) {
|
|
|
|
if (PropertyManagementComponent::Instance() == nullptr) return;
|
|
|
|
|
|
|
|
PropertyManagementComponent::Instance()->OnQueryPropertyData(originator, sysAddr, m_Parent->GetObjectID());
|
|
|
|
}
|
|
|
|
|
|
|
|
void PropertyVendorComponent::OnBuyFromVendor(Entity* originator, const bool confirmed, const LOT lot, const uint32_t count) {
|
|
|
|
if (PropertyManagementComponent::Instance() == nullptr) return;
|
|
|
|
|
2022-03-31 04:58:59 +00:00
|
|
|
if (PropertyManagementComponent::Instance()->Claim(originator->GetObjectID()) == false) {
|
2024-03-14 01:47:41 +00:00
|
|
|
Log::Warn("FAILED TO CLAIM PROPERTY. PLAYER ID IS {}", originator->GetObjectID());
|
2022-03-31 04:58:59 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
GameMessages::SendPropertyRentalResponse(m_Parent->GetObjectID(), 0, 0, 0, 0, originator->GetSystemAddress());
|
|
|
|
|
2023-07-17 22:55:33 +00:00
|
|
|
auto* controller = Game::zoneManager->GetZoneControlObject();
|
2021-12-05 17:54:36 +00:00
|
|
|
|
|
|
|
controller->OnFireEventServerSide(m_Parent, "propertyRented");
|
2022-07-25 02:26:51 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
PropertyManagementComponent::Instance()->SetOwner(originator);
|
2022-07-25 02:26:51 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
PropertyManagementComponent::Instance()->OnQueryPropertyData(originator, originator->GetSystemAddress());
|
|
|
|
|
2024-03-14 01:47:41 +00:00
|
|
|
Log::Info("Fired event; ({}) ({}) ({})", confirmed, lot, count);
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|