2022-04-26 10:41:16 +00:00
|
|
|
#pragma once
|
2021-12-05 17:54:36 +00:00
|
|
|
#ifndef VENDORCOMPONENT_H
|
|
|
|
#define VENDORCOMPONENT_H
|
|
|
|
|
|
|
|
#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
|
|
|
|
|
|
|
/**
|
|
|
|
* A component for vendor NPCs. A vendor sells items to the player.
|
|
|
|
*/
|
|
|
|
class VendorComponent : public Component {
|
|
|
|
public:
|
2023-06-09 08:22:45 +00:00
|
|
|
inline static const eReplicaComponentType ComponentType = eReplicaComponentType::VENDOR;
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
VendorComponent(Entity* parent);
|
|
|
|
|
|
|
|
void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags);
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2022-04-05 12:11:06 +00:00
|
|
|
void OnUse(Entity* originator) override;
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2023-06-23 05:56:25 +00:00
|
|
|
float GetBuyScalar() const {
|
|
|
|
return m_BuyScalar;
|
|
|
|
}
|
|
|
|
|
|
|
|
float GetSellScalar() const {
|
|
|
|
return m_SellScalar;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetBuyScalar(float value) {
|
|
|
|
m_BuyScalar = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetSellScalar(float value) {
|
|
|
|
m_SellScalar = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::map<LOT, int>& GetInventory() {
|
|
|
|
return m_Inventory;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetHasMultiCostItems(bool hasMultiCostItems) {
|
|
|
|
if (m_HasMultiCostItems == hasMultiCostItems) return;
|
|
|
|
m_HasMultiCostItems = hasMultiCostItems;
|
|
|
|
m_DirtyVendor = true;
|
|
|
|
}
|
|
|
|
void SetHasStandardCostItems(bool hasStandardCostItems) {
|
|
|
|
if (m_HasStandardCostItems == hasStandardCostItems) return;
|
|
|
|
m_HasStandardCostItems = hasStandardCostItems;
|
|
|
|
m_DirtyVendor = true;
|
|
|
|
}
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2022-04-26 10:41:16 +00:00
|
|
|
/**
|
|
|
|
* Refresh the inventory of this vendor.
|
|
|
|
*/
|
|
|
|
void RefreshInventory(bool isCreation = false);
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2022-04-26 10:41:16 +00:00
|
|
|
/**
|
|
|
|
* Called on startup of vendor to setup the variables for the component.
|
|
|
|
*/
|
|
|
|
void SetupConstants();
|
2023-06-03 07:40:46 +00:00
|
|
|
|
2023-06-23 05:56:25 +00:00
|
|
|
bool SellsItem(const LOT item) const {
|
|
|
|
return m_Inventory.find(item) != m_Inventory.end();
|
|
|
|
}
|
2021-12-05 17:54:36 +00:00
|
|
|
private:
|
|
|
|
/**
|
2022-04-26 10:41:16 +00:00
|
|
|
* The buy scalar.
|
2021-12-05 17:54:36 +00:00
|
|
|
*/
|
|
|
|
float m_BuyScalar;
|
|
|
|
|
|
|
|
/**
|
2022-04-26 10:41:16 +00:00
|
|
|
* The sell scalar.
|
2021-12-05 17:54:36 +00:00
|
|
|
*/
|
|
|
|
float m_SellScalar;
|
|
|
|
|
2022-04-26 10:41:16 +00:00
|
|
|
/**
|
|
|
|
* The refresh time of this vendors' inventory.
|
|
|
|
*/
|
|
|
|
float m_RefreshTimeSeconds;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Loot matrix id of this vendor.
|
|
|
|
*/
|
|
|
|
uint32_t m_LootMatrixID;
|
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
/**
|
|
|
|
* The list of items the vendor sells.
|
|
|
|
*/
|
|
|
|
std::map<LOT, int> m_Inventory;
|
2023-06-23 05:56:25 +00:00
|
|
|
|
|
|
|
bool m_DirtyVendor;
|
|
|
|
bool m_HasStandardCostItems;
|
|
|
|
bool m_HasMultiCostItems;
|
2021-12-05 17:54:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // VENDORCOMPONENT_H
|