PropertyVendorComponent pass

This commit is contained in:
David Markowitz 2023-07-11 00:07:08 -07:00
parent a37ec326b9
commit c204ea4009
2 changed files with 11 additions and 15 deletions

View File

@ -10,34 +10,30 @@
#include "PropertyManagementComponent.h"
#include "UserManager.h"
PropertyVendorComponent::PropertyVendorComponent(Entity* parent) : Component(parent) {
}
PropertyVendorComponent::PropertyVendorComponent(Entity* parent) : Component(parent) { }
void PropertyVendorComponent::OnUse(Entity* originator) {
if (PropertyManagementComponent::Instance() == nullptr) return;
if (!PropertyManagementComponent::Instance()) return;
OnQueryPropertyData(originator, originator->GetSystemAddress());
if (PropertyManagementComponent::Instance()->GetOwnerId() == LWOOBJID_EMPTY) {
if (PropertyManagementComponent::Instance()->GetOwnerId() != LWOOBJID_EMPTY) return;
Game::logger->Log("PropertyVendorComponent", "Property vendor opening!");
GameMessages::SendOpenPropertyVendor(m_ParentEntity->GetObjectID(), originator->GetSystemAddress());
return;
}
}
void PropertyVendorComponent::OnQueryPropertyData(Entity* originator, const SystemAddress& sysAddr) {
if (PropertyManagementComponent::Instance() == nullptr) return;
if (!PropertyManagementComponent::Instance()) return;
PropertyManagementComponent::Instance()->OnQueryPropertyData(originator, sysAddr, m_ParentEntity->GetObjectID());
}
void PropertyVendorComponent::OnBuyFromVendor(Entity* originator, const bool confirmed, const LOT lot, const uint32_t count) {
if (PropertyManagementComponent::Instance() == nullptr) return;
if (!PropertyManagementComponent::Instance()) return;
if (PropertyManagementComponent::Instance()->Claim(originator->GetObjectID()) == false) {
Game::logger->Log("PropertyVendorComponent", "FAILED TO CLAIM PROPERTY. PLAYER ID IS %llu", originator->GetObjectID());
if (!PropertyManagementComponent::Instance()->Claim(originator->GetObjectID())) {
Game::logger->Log("PropertyVendorComponent", "Player %llu attempted to claim a property that did not belong to them.", originator->GetObjectID());
return;
}
@ -51,6 +47,6 @@ void PropertyVendorComponent::OnBuyFromVendor(Entity* originator, const bool con
PropertyManagementComponent::Instance()->OnQueryPropertyData(originator, originator->GetSystemAddress());
Game::logger->Log("PropertyVendorComponent", "Fired event; (%d) (%i) (%i)", confirmed, lot, count);
Game::logger->Log("PropertyVendorComponent", "Fired event, (%d) (%i) (%i)", confirmed, lot, count);
}

View File

@ -7,7 +7,7 @@
/**
* The property guard that stands on a property before it's claimed, allows entities to attempt claiming this property.
*/
class PropertyVendorComponent : public Component
class PropertyVendorComponent final : public Component
{
public:
inline static const eReplicaComponentType ComponentType = eReplicaComponentType::PROPERTY_VENDOR;