mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-23 14:07:20 +00:00
5afeb265cd
Fixed a few issues in VendorComponent. - Corrected serialization to only happen on construction. - Added functionality to refresh the vendor based on info from the vendor component table - some whitespaceing inconsistencies. - Sorted includes. Tested the vendor in Nimbus Station and when the player re-enters the world, the vendor inventory refreshes, as opposed to previously where the world would need to reset in order to refresh the inventory.
97 lines
1.8 KiB
C++
97 lines
1.8 KiB
C++
#pragma once
|
|
#ifndef VENDORCOMPONENT_H
|
|
#define VENDORCOMPONENT_H
|
|
|
|
#include "CDClientManager.h"
|
|
#include "Component.h"
|
|
#include "Entity.h"
|
|
#include "GameMessages.h"
|
|
#include "RakNetTypes.h"
|
|
|
|
/**
|
|
* A component for vendor NPCs. A vendor sells items to the player.
|
|
*/
|
|
class VendorComponent : public Component {
|
|
public:
|
|
static const uint32_t ComponentType = COMPONENT_TYPE_VENDOR;
|
|
|
|
VendorComponent(Entity* parent);
|
|
~VendorComponent() override;
|
|
|
|
void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags);
|
|
|
|
void OnUse(Entity* originator) override;
|
|
|
|
/**
|
|
* Gets the buy scaler
|
|
* @return the buy scaler
|
|
*/
|
|
float GetBuyScalar() const;
|
|
|
|
/**
|
|
* Sets the buy scalar.
|
|
* @param value the new value.
|
|
*/
|
|
void SetBuyScalar(float value);
|
|
|
|
/**
|
|
* Gets the buy scaler
|
|
* @return the buy scaler
|
|
*/
|
|
float GetSellScalar() const;
|
|
|
|
/**
|
|
* Sets the sell scalar.
|
|
* @param value the new value.
|
|
*/
|
|
void SetSellScalar(float value);
|
|
|
|
/**
|
|
* True if the NPC LOT is 13800, the only NPC with a crafting station.
|
|
*/
|
|
bool HasCraftingStation();
|
|
|
|
/**
|
|
* Gets the list if items the vendor sells.
|
|
* @return the list of items.
|
|
*/
|
|
std::map<LOT, int>& GetInventory();
|
|
|
|
/**
|
|
* Refresh the inventory of this vendor.
|
|
*/
|
|
void RefreshInventory(bool isCreation = false);
|
|
|
|
/**
|
|
* Called on startup of vendor to setup the variables for the component.
|
|
*/
|
|
void SetupConstants();
|
|
private:
|
|
/**
|
|
* The buy scalar.
|
|
*/
|
|
float m_BuyScalar;
|
|
|
|
/**
|
|
* The sell scalar.
|
|
*/
|
|
float m_SellScalar;
|
|
|
|
/**
|
|
* The refresh time of this vendors' inventory.
|
|
*/
|
|
float m_RefreshTimeSeconds;
|
|
|
|
/**
|
|
* Loot matrix id of this vendor.
|
|
*/
|
|
uint32_t m_LootMatrixID;
|
|
|
|
/**
|
|
* The list of items the vendor sells.
|
|
*/
|
|
std::map<LOT, int> m_Inventory;
|
|
};
|
|
|
|
#endif // VENDORCOMPONENT_H
|