mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-11-14 07:47:13 +00:00
Physics/, Activity/ (activity, scripted activity, shooting gallery, quickbuild, minigame control, racing control base, racing control, gate rush), Vendor/, Character/ (what the client makes with a character, plus ghost, minifig and mission), Sound/ and Property/; the rest stays where it was. File moves only; DLU_COMPONENT_INCLUDE_DIRS gives every target the folders. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
70 lines
2.2 KiB
C++
70 lines
2.2 KiB
C++
#include "PropertyVendorComponent.h"
|
|
#include "ObjectMessages.h"
|
|
|
|
#include "PropertyMessages.h"
|
|
#include "GameMessages.h"
|
|
#include "Character.h"
|
|
#include "EntityManager.h"
|
|
#include "dZoneManager.h"
|
|
#include "Game.h"
|
|
#include "Logger.h"
|
|
#include "PropertyManagementComponent.h"
|
|
#include "UserManager.h"
|
|
|
|
PropertyVendorComponent::PropertyVendorComponent(Entity* parent, const int32_t componentID) : Component(parent, componentID) {
|
|
RegisterMsg(&PropertyVendorComponent::OnRequestUse);
|
|
}
|
|
|
|
bool PropertyVendorComponent::OnRequestUse(GameMessages::RequestUseEvent& event) {
|
|
if (event.msg.IsMissionChoice()) return false;
|
|
auto* const originator = event.user;
|
|
if (PropertyManagementComponent::Instance() == nullptr) return true;
|
|
|
|
OnQueryPropertyData(originator, originator->GetSystemAddress());
|
|
|
|
if (PropertyManagementComponent::Instance()->GetOwnerId() == LWOOBJID_EMPTY) {
|
|
LOG("Property vendor opening!");
|
|
|
|
GameMessages::OpenPropertyVendor msg;
|
|
msg.target = m_Parent->GetObjectID();
|
|
msg.Send(originator->GetSystemAddress());
|
|
|
|
return true;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
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;
|
|
|
|
if (PropertyManagementComponent::Instance()->Claim(originator->GetObjectID()) == false) {
|
|
LOG("FAILED TO CLAIM PROPERTY. PLAYER ID IS %llu", originator->GetObjectID());
|
|
return;
|
|
}
|
|
|
|
GameMessages::PropertyRentalResponse msg;
|
|
msg.target = m_Parent->GetObjectID();
|
|
msg.cloneid = 0;
|
|
msg.code = 0;
|
|
msg.propertyID = 0;
|
|
msg.rentdue = 0;
|
|
msg.Send(originator->GetSystemAddress());
|
|
|
|
auto* controller = Game::zoneManager->GetZoneControlObject();
|
|
|
|
controller->OnFireEventServerSide(m_Parent, "propertyRented");
|
|
|
|
PropertyManagementComponent::Instance()->SetOwner(originator);
|
|
|
|
PropertyManagementComponent::Instance()->OnQueryPropertyData(originator, originator->GetSystemAddress());
|
|
|
|
LOG("Fired event; (%d) (%i) (%i)", confirmed, lot, count);
|
|
}
|
|
|