2022-08-06 03:01:59 +00:00
|
|
|
#include "PropertyVendorComponent.h"
|
2021-12-05 17:54:36 +00:00
|
|
|
|
|
|
|
#include "PropertyDataMessage.h"
|
|
|
|
#include "GameMessages.h"
|
|
|
|
#include "Character.h"
|
|
|
|
#include "EntityManager.h"
|
|
|
|
#include "dZoneManager.h"
|
|
|
|
#include "Game.h"
|
|
|
|
#include "dLogger.h"
|
|
|
|
#include "PropertyManagementComponent.h"
|
|
|
|
#include "UserManager.h"
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
PropertyVendorComponent::PropertyVendorComponent(Entity* parent) : Component(parent) {
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
void PropertyVendorComponent::OnUse(Entity* originator) {
|
2021-12-05 17:54:36 +00:00
|
|
|
if (PropertyManagementComponent::Instance() == nullptr) return;
|
|
|
|
|
|
|
|
OnQueryPropertyData(originator, originator->GetSystemAddress());
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
if (PropertyManagementComponent::Instance()->GetOwnerId() == LWOOBJID_EMPTY) {
|
2022-07-25 02:26:51 +00:00
|
|
|
Game::logger->Log("PropertyVendorComponent", "Property vendor opening!");
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2023-06-09 09:46:01 +00:00
|
|
|
GameMessages::SendOpenPropertyVendor(m_ParentEntity->GetObjectID(), originator->GetSystemAddress());
|
2021-12-05 17:54:36 +00:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
void PropertyVendorComponent::OnQueryPropertyData(Entity* originator, const SystemAddress& sysAddr) {
|
2021-12-05 17:54:36 +00:00
|
|
|
if (PropertyManagementComponent::Instance() == nullptr) return;
|
|
|
|
|
2023-06-09 09:46:01 +00:00
|
|
|
PropertyManagementComponent::Instance()->OnQueryPropertyData(originator, sysAddr, m_ParentEntity->GetObjectID());
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
void PropertyVendorComponent::OnBuyFromVendor(Entity* originator, const bool confirmed, const LOT lot, const uint32_t count) {
|
2021-12-05 17:54:36 +00:00
|
|
|
if (PropertyManagementComponent::Instance() == nullptr) return;
|
|
|
|
|
2022-03-31 04:58:59 +00:00
|
|
|
if (PropertyManagementComponent::Instance()->Claim(originator->GetObjectID()) == false) {
|
2022-07-25 02:26:51 +00:00
|
|
|
Game::logger->Log("PropertyVendorComponent", "FAILED TO CLAIM PROPERTY. PLAYER ID IS %llu", originator->GetObjectID());
|
2022-03-31 04:58:59 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-06-09 09:46:01 +00:00
|
|
|
GameMessages::SendPropertyRentalResponse(m_ParentEntity->GetObjectID(), 0, 0, 0, 0, originator->GetSystemAddress());
|
2021-12-05 17:54:36 +00:00
|
|
|
|
|
|
|
auto* controller = dZoneManager::Instance()->GetZoneControlObject();
|
|
|
|
|
2023-06-09 09:46:01 +00:00
|
|
|
controller->OnFireEventServerSide(m_ParentEntity, "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());
|
|
|
|
|
2022-07-25 02:26:51 +00:00
|
|
|
Game::logger->Log("PropertyVendorComponent", "Fired event; (%d) (%i) (%i)", confirmed, lot, count);
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|
|
|
|
|