2022-04-26 10:41:16 +00:00
|
|
|
#pragma once
|
2021-12-05 17:54:36 +00:00
|
|
|
#ifndef VENDORCOMPONENT_H
|
|
|
|
#define VENDORCOMPONENT_H
|
|
|
|
|
2023-07-26 02:35:45 +00:00
|
|
|
#include <functional>
|
2021-12-05 17:54:36 +00:00
|
|
|
#include "CDClientManager.h"
|
|
|
|
#include "Component.h"
|
2022-04-26 10:41:16 +00:00
|
|
|
#include "Entity.h"
|
|
|
|
#include "GameMessages.h"
|
|
|
|
#include "RakNetTypes.h"
|
2023-03-04 07:16:37 +00:00
|
|
|
#include "eReplicaComponentType.h"
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2023-07-26 02:35:45 +00:00
|
|
|
struct SoldItem {
|
|
|
|
SoldItem(const LOT lot, const int32_t sortPriority) {
|
|
|
|
this->lot = lot;
|
|
|
|
this->sortPriority = sortPriority;
|
|
|
|
};
|
|
|
|
LOT lot = 0;
|
|
|
|
int32_t sortPriority = 0;
|
|
|
|
};
|
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
class VendorComponent : public Component {
|
|
|
|
public:
|
2023-07-26 02:35:45 +00:00
|
|
|
inline static const eReplicaComponentType ComponentType = eReplicaComponentType::VENDOR;
|
2021-12-05 17:54:36 +00:00
|
|
|
VendorComponent(Entity* parent);
|
|
|
|
void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags);
|
2022-04-05 12:11:06 +00:00
|
|
|
void OnUse(Entity* originator) override;
|
2022-04-26 10:41:16 +00:00
|
|
|
void RefreshInventory(bool isCreation = false);
|
|
|
|
void SetupConstants();
|
2023-07-26 02:35:45 +00:00
|
|
|
float GetBuyScalar() const { return m_BuyScalar; }
|
|
|
|
float GetSellScalar() const { return m_SellScalar; }
|
|
|
|
void SetBuyScalar(const float value) { m_BuyScalar = value; }
|
|
|
|
void SetSellScalar(const float value) { m_SellScalar = value; }
|
|
|
|
|
|
|
|
std::vector<SoldItem>& GetInventory() { return m_Inventory; }
|
|
|
|
|
|
|
|
void SetHasMultiCostItems(const bool hasMultiCostItems) {
|
|
|
|
if (m_HasMultiCostItems == hasMultiCostItems) return;
|
|
|
|
m_HasMultiCostItems = hasMultiCostItems;
|
|
|
|
m_DirtyVendor = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetHasStandardCostItems(const bool hasStandardCostItems) {
|
|
|
|
if (m_HasStandardCostItems == hasStandardCostItems) return;
|
|
|
|
m_HasStandardCostItems = hasStandardCostItems;
|
|
|
|
m_DirtyVendor = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool SellsItem(const LOT item) const {
|
|
|
|
return std::count_if(m_Inventory.begin(), m_Inventory.end(), [item](const SoldItem& lhs) {
|
|
|
|
return lhs.lot == item;
|
|
|
|
}) > 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void MaxCustomVendorRefreshInventory(bool isCreation = false);
|
2021-12-05 17:54:36 +00:00
|
|
|
private:
|
2023-07-26 02:35:45 +00:00
|
|
|
float m_BuyScalar = 0.0f;
|
|
|
|
float m_SellScalar = 0.0f;
|
|
|
|
float m_RefreshTimeSeconds = 0.0f;
|
|
|
|
uint32_t m_LootMatrixID = 0;
|
|
|
|
std::vector<SoldItem> m_Inventory;
|
|
|
|
bool m_DirtyVendor = false;
|
|
|
|
bool m_HasStandardCostItems = false;
|
|
|
|
bool m_HasMultiCostItems = false;
|
2021-12-05 17:54:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // VENDORCOMPONENT_H
|