Updated vendor component

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.
This commit is contained in:
EmosewaMC
2022-04-26 03:41:16 -07:00
parent aca2bb1090
commit 5afeb265cd
5 changed files with 133 additions and 93 deletions

View File

@@ -1,11 +1,12 @@
#pragma once
#ifndef VENDORCOMPONENT_H
#define VENDORCOMPONENT_H
#include "RakNetTypes.h"
#include "Entity.h"
#include "GameMessages.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.
@@ -56,17 +57,36 @@ public:
*/
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 scaler.
* The buy scalar.
*/
float m_BuyScalar;
/**
* The sell scaler.
* 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.
*/