2022-07-17 01:36:09 +00:00
|
|
|
#pragma once
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-04 22:24:45 +00:00
|
|
|
#ifndef INVENTORYCOMPONENT_H
|
|
|
|
#define INVENTORYCOMPONENT_H
|
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
#include <map>
|
|
|
|
#include <stack>
|
|
|
|
|
|
|
|
|
|
|
|
#include "BehaviorSlot.h"
|
|
|
|
#include "tinyxml2.h"
|
|
|
|
|
|
|
|
#include "dCommonVars.h"
|
|
|
|
#include "EquippedItem.h"
|
|
|
|
#include "Inventory.h"
|
|
|
|
#include "LDFFormat.h"
|
|
|
|
#include "DatabasePet.h"
|
|
|
|
#include "Component.h"
|
|
|
|
#include "ItemSetPassiveAbility.h"
|
2023-01-22 23:38:47 +00:00
|
|
|
#include "eItemSetPassiveAbilityID.h"
|
2022-02-10 05:21:10 +00:00
|
|
|
#include "PossessorComponent.h"
|
2022-12-18 15:46:04 +00:00
|
|
|
#include "eInventoryType.h"
|
2023-03-04 07:16:37 +00:00
|
|
|
#include "eReplicaComponentType.h"
|
2023-05-02 22:39:21 +00:00
|
|
|
#include "eLootSourceType.h"
|
2023-07-15 08:54:41 +00:00
|
|
|
#include "eSkillBar.h"
|
2021-12-05 17:54:36 +00:00
|
|
|
|
|
|
|
class Entity;
|
|
|
|
class ItemSet;
|
|
|
|
|
|
|
|
typedef std::map<std::string, EquippedItem> EquipmentMap;
|
|
|
|
|
2022-07-17 01:36:09 +00:00
|
|
|
enum class eItemType : int32_t;
|
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
/**
|
|
|
|
* Handles the inventory of entity, including the items they possess and have equipped. An entity can have inventories
|
|
|
|
* of different types, each type representing a different group of items, see `eInventoryType` for a list of
|
|
|
|
* inventories.
|
|
|
|
*/
|
|
|
|
class InventoryComponent : public Component
|
|
|
|
{
|
|
|
|
public:
|
2023-03-04 07:16:37 +00:00
|
|
|
static const eReplicaComponentType ComponentType = eReplicaComponentType::INVENTORY;
|
2021-12-05 17:54:36 +00:00
|
|
|
explicit InventoryComponent(Entity* parent, tinyxml2::XMLDocument* document = nullptr);
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
void Update(float deltaTime) override;
|
2023-08-10 21:33:15 +00:00
|
|
|
void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override;
|
2022-07-28 13:39:57 +00:00
|
|
|
void LoadXml(tinyxml2::XMLDocument* document);
|
|
|
|
void UpdateXml(tinyxml2::XMLDocument* document) override;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns an inventory of the specified type, if it exists
|
|
|
|
* @param type the inventory type to find an inventory for
|
|
|
|
* @return the inventory of the specified type
|
|
|
|
*/
|
2021-12-05 17:54:36 +00:00
|
|
|
Inventory* GetInventory(eInventoryType type);
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
/**
|
|
|
|
* Returns all the inventories this entity has, indexed by type
|
|
|
|
* @return all the inventories this entity has, indexed by type
|
|
|
|
*/
|
2021-12-05 17:54:36 +00:00
|
|
|
const std::map<eInventoryType, Inventory*>& GetInventories() const;
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
/**
|
|
|
|
* Returns the amount of items this entity possesses of a certain LOT
|
|
|
|
* @param lot the lot to search for
|
|
|
|
* @return the amount of items this entity possesses the specified LOT
|
|
|
|
*/
|
2021-12-05 17:54:36 +00:00
|
|
|
uint32_t GetLotCount(LOT lot) const;
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
/**
|
|
|
|
* Returns the amount of items this entity possesses of a LOT, given that they're not in a temporary inventory
|
|
|
|
* (vendor buyback, vault, etc).
|
|
|
|
* @param lot the lot to search for
|
|
|
|
* @return the amount of items this entity possesses of the specified lot
|
|
|
|
*/
|
2021-12-05 17:54:36 +00:00
|
|
|
uint32_t GetLotCountNonTransfer(LOT lot) const;
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
/**
|
|
|
|
* Returns the items that are currently equipped by this entity
|
|
|
|
* @return the items that are currently equipped by this entity
|
|
|
|
*/
|
2021-12-05 17:54:36 +00:00
|
|
|
const EquipmentMap& GetEquippedItems() const;
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
/**
|
|
|
|
* Adds an item to the inventory of the entity
|
|
|
|
* @param lot the lot to add
|
|
|
|
* @param count the amount of items to add
|
|
|
|
* @param inventoryType the inventory to add the item to
|
|
|
|
* @param config optional config for this item, used for example for rockets
|
|
|
|
* @param parent optional parent of this item, used for proxy items
|
|
|
|
* @param showFlyingLoot show a client animation if the item is added
|
|
|
|
* @param isModMoveAndEquip equips the item
|
|
|
|
* @param subKey optional sub ID of a related object, used by pets
|
|
|
|
* @param inventorySourceType if the inventory was moved, the source inventory
|
|
|
|
* @param sourceType the source of the item, used to determine if the item is dropped or mailed if the inventory is full
|
|
|
|
* @param bound whether this item is bound
|
|
|
|
* @param preferredSlot the preferred slot to store this item
|
|
|
|
* @param lootSourceType The source of the loot. Defaults to none.
|
|
|
|
*/
|
2021-12-05 17:54:36 +00:00
|
|
|
void AddItem(
|
|
|
|
LOT lot,
|
|
|
|
uint32_t count,
|
2023-05-02 22:39:21 +00:00
|
|
|
eLootSourceType lootSourceType = eLootSourceType::NONE,
|
2021-12-05 17:54:36 +00:00
|
|
|
eInventoryType inventoryType = INVALID,
|
|
|
|
const std::vector<LDFBaseData*>& config = {},
|
|
|
|
LWOOBJID parent = LWOOBJID_EMPTY,
|
|
|
|
bool showFlyingLoot = true,
|
|
|
|
bool isModMoveAndEquip = false,
|
|
|
|
LWOOBJID subKey = LWOOBJID_EMPTY,
|
|
|
|
eInventoryType inventorySourceType = INVALID,
|
|
|
|
int32_t sourceType = 0,
|
|
|
|
bool bound = false,
|
2022-04-24 03:35:34 +00:00
|
|
|
int32_t preferredSlot = -1
|
2021-12-05 17:54:36 +00:00
|
|
|
);
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
/**
|
|
|
|
* Removes a LOT from the inventory
|
|
|
|
* @param lot the lot to remove
|
|
|
|
* @param count the number of items to remove
|
|
|
|
* @param inventoryType optional inventory type to remove the item from
|
|
|
|
* @param ignoreBound ignores bound items
|
|
|
|
*/
|
2021-12-05 17:54:36 +00:00
|
|
|
void RemoveItem(LOT lot, uint32_t count, eInventoryType inventoryType = INVALID, bool ignoreBound = false);
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
/**
|
|
|
|
* Moves an existing item to an inventory of the entity
|
|
|
|
* @param item the item to add
|
|
|
|
* @param inventory the inventory to add the item to
|
|
|
|
* @param count the number of items to add
|
|
|
|
* @param showFlyingLot displays UI animation to the user
|
|
|
|
* @param isModMoveAndEquip equips the item
|
|
|
|
* @param ignoreEquipped does not stack on equipped items
|
|
|
|
* @param preferredSlot the preferred slot to store the item in
|
|
|
|
*/
|
2021-12-05 17:54:36 +00:00
|
|
|
void MoveItemToInventory(Item* item, eInventoryType inventory, uint32_t count, bool showFlyingLot = true, bool isModMoveAndEquip = false, bool ignoreEquipped = false, int32_t preferredSlot = -1);
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
/**
|
|
|
|
* Moves a stack of items to an inventory
|
|
|
|
* @param item the item to move
|
|
|
|
* @param inventory the inventory to move the item to
|
|
|
|
* @param slot the slot in the inventory to move the item to
|
|
|
|
*/
|
2021-12-05 17:54:36 +00:00
|
|
|
void MoveStack(Item* item, eInventoryType inventory, uint32_t slot = 0);
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
/**
|
|
|
|
* Returns an item in the inventory by object ID
|
|
|
|
* @param id the id of the item to find
|
|
|
|
* @return item in the inventory by object ID
|
|
|
|
*/
|
2021-12-05 17:54:36 +00:00
|
|
|
Item* FindItemById(LWOOBJID id) const;
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
/**
|
|
|
|
* Returns an item in the inventory that matches the specified LOT
|
|
|
|
* @param lot the lot of the item to find
|
|
|
|
* @param inventoryType optional inventory to search in
|
|
|
|
* @param ignoreEquipped ignores items that are equipped
|
|
|
|
* @param ignoreBound ignores items that are bound
|
|
|
|
* @return item in the inventory that matches the specified LOT
|
|
|
|
*/
|
2021-12-05 17:54:36 +00:00
|
|
|
Item* FindItemByLot(LOT lot, eInventoryType inventoryType = INVALID, bool ignoreEquipped = false, bool ignoreBound = false);
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
/**
|
|
|
|
* Finds an item in the inventory that has the specified subkey, useful for pets
|
|
|
|
* @param id the subkey to look for
|
|
|
|
* @param inventoryType optional inventory type to search in
|
|
|
|
* @return item in the inventory that has the specified subkey
|
|
|
|
*/
|
2021-12-05 17:54:36 +00:00
|
|
|
Item* FindItemBySubKey(LWOOBJID id, eInventoryType inventoryType = INVALID);
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
/**
|
|
|
|
* Checks if the entity has enough space for a batch of loot
|
|
|
|
* @param loot a map of items to add and how many to add
|
|
|
|
* @return whether the entity has enough space for all the items
|
|
|
|
*/
|
2021-12-05 17:54:36 +00:00
|
|
|
bool HasSpaceForLoot(const std::unordered_map<LOT, int32_t>& loot);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Equips an item in the specified slot
|
|
|
|
* @param location the location to store the item (e.g. chest, left hand, etc.)
|
|
|
|
* @param item the item to place
|
|
|
|
* @param keepCurrent stores the item in an additional temp slot if there's already an item equipped
|
|
|
|
*/
|
|
|
|
void UpdateSlot(const std::string& location, EquippedItem item, bool keepCurrent = false);
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
/**
|
|
|
|
* Removes a slot from the inventory
|
|
|
|
* @param location the slot to remove
|
|
|
|
*/
|
2021-12-05 17:54:36 +00:00
|
|
|
void RemoveSlot(const std::string& location);
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
/**
|
|
|
|
* Equips the given item, guesses the slot to equip it in
|
|
|
|
* @param item the item to equip
|
|
|
|
* @param skipChecks skips checks for equipping cars and rockets (e.g. no special behavior follows)
|
|
|
|
*/
|
2021-12-05 17:54:36 +00:00
|
|
|
void EquipItem(Item* item, bool skipChecks = false);
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
/**
|
|
|
|
* Unequips an item from the inventory
|
|
|
|
* @param item the item to unequip
|
|
|
|
*/
|
2021-12-05 17:54:36 +00:00
|
|
|
void UnEquipItem(Item* item);
|
|
|
|
|
2022-09-02 18:49:19 +00:00
|
|
|
/**
|
|
|
|
* Unequips an Item from the inventory
|
|
|
|
* @param item the Item to unequip
|
|
|
|
* @return if we were successful
|
|
|
|
*/
|
|
|
|
void HandlePossession(Item* item);
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
/**
|
|
|
|
* Adds a buff related to equipping a lot to the entity
|
|
|
|
* @param item the item to find buffs for
|
|
|
|
*/
|
2022-03-27 22:24:06 +00:00
|
|
|
void ApplyBuff(Item* item) const;
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
/**
|
|
|
|
* Removes buffs related to equipping a lot from the entity
|
|
|
|
* @param item the item to find buffs for
|
|
|
|
*/
|
2022-03-27 22:24:06 +00:00
|
|
|
void RemoveBuff(Item* item) const;
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
/**
|
|
|
|
* Saves the equipped items into a temp state
|
|
|
|
*/
|
2021-12-05 17:54:36 +00:00
|
|
|
void PushEquippedItems();
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
/**
|
|
|
|
* Unequips all the temporary items and equips the previous item state
|
|
|
|
*/
|
2021-12-05 17:54:36 +00:00
|
|
|
void PopEquippedItems();
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
/**
|
|
|
|
* Returns if the entity has an item equipped of the given lot
|
|
|
|
* @param lot to lot to search for
|
|
|
|
* @return if the entity has an item equipped of the given lot
|
|
|
|
*/
|
2021-12-05 17:54:36 +00:00
|
|
|
bool IsEquipped(LOT lot) const;
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
/**
|
|
|
|
* Checks and ensures that we have loaded the item set that might be related to this item
|
|
|
|
* @param lot the lot to check the item set for
|
|
|
|
*/
|
2021-12-05 17:54:36 +00:00
|
|
|
void CheckItemSet(LOT lot);
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
/**
|
|
|
|
* Sets the current consumable lot
|
|
|
|
* @param lot the lot to set as consumable
|
|
|
|
*/
|
2021-12-05 17:54:36 +00:00
|
|
|
void SetConsumable(LOT lot);
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
/**
|
|
|
|
* Returns the current consumable lot
|
|
|
|
* @return the current consumable lot
|
|
|
|
*/
|
2021-12-05 17:54:36 +00:00
|
|
|
LOT GetConsumable() const;
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
/**
|
|
|
|
* Finds all the buffs related to a lot
|
|
|
|
* @param item the item to get the buffs for
|
|
|
|
* @param castOnEquip if true, the skill missions for these buffs will be progressed
|
|
|
|
* @return the buffs related to the specified lot
|
|
|
|
*/
|
2022-03-27 22:24:06 +00:00
|
|
|
std::vector<uint32_t> FindBuffs(Item* item, bool castOnEquip) const;
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
/**
|
|
|
|
* Initializes the equipped items with a list of items
|
|
|
|
* @param items the items to equip
|
|
|
|
*/
|
2021-12-05 17:54:36 +00:00
|
|
|
void SetNPCItems(const std::vector<LOT>& items);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Adds a skill related to a passed item to the currently equipped skills
|
|
|
|
* @param lot the lot to add a skill for
|
|
|
|
*/
|
|
|
|
void AddItemSkills(LOT lot);
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
/**
|
|
|
|
* Removes the skills related to the passed LOT from the currently equipped skills
|
|
|
|
* @param lot the lot to remove
|
|
|
|
*/
|
2021-12-05 17:54:36 +00:00
|
|
|
void RemoveItemSkills(LOT lot);
|
|
|
|
|
2023-07-15 08:54:41 +00:00
|
|
|
/**
|
|
|
|
* Equip a skill to a bar and slot
|
|
|
|
*/
|
|
|
|
void EquipSkill(eSkillBar bar, BehaviorSlot slot, uint32_t skillID);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Unequip a skill from a bar and slot
|
|
|
|
*/
|
|
|
|
void UnequipSkill(eSkillBar bar, BehaviorSlot slot);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the skill in a bar and slot
|
|
|
|
*/
|
|
|
|
uint32_t GetSkill(eSkillBar bar, BehaviorSlot slot) const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the currently selected skill bar
|
|
|
|
*/
|
|
|
|
eSkillBar GetSelectedSkillBar() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the currently selected skill bar
|
|
|
|
*/
|
|
|
|
void SetSelectedSkillBar(eSkillBar bar);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Update skills on client
|
|
|
|
*/
|
|
|
|
void UpdateSkills();
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
/**
|
|
|
|
* Triggers one of the passive abilities from the equipped item set
|
|
|
|
* @param trigger the trigger to fire
|
|
|
|
*/
|
2022-12-24 02:05:30 +00:00
|
|
|
void TriggerPassiveAbility(PassiveAbilityTrigger trigger, Entity* target = nullptr);
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
/**
|
|
|
|
* Returns if the entity has any of the passed passive abilities equipped
|
|
|
|
* @param passiveIDs the IDs to check for
|
|
|
|
* @param equipmentRequirement the number of equipment required to be allowed to have the ability
|
|
|
|
* @return if the entity has any of the passed passive abilities equipped
|
|
|
|
*/
|
2023-01-22 23:38:47 +00:00
|
|
|
bool HasAnyPassive(const std::vector<eItemSetPassiveAbilityID>& passiveIDs, int32_t equipmentRequirement) const;
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
/**
|
|
|
|
* Despawns the currently active pet, if any
|
|
|
|
*/
|
2021-12-05 17:54:36 +00:00
|
|
|
void DespawnPet();
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
/**
|
|
|
|
* Spawns the item as a pet (if it is one)
|
|
|
|
* @param item the pet to spawn
|
|
|
|
*/
|
2021-12-05 17:54:36 +00:00
|
|
|
void SpawnPet(Item* item);
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
/**
|
|
|
|
* Updates the database pet data for an item (e.g. moderation status)
|
|
|
|
* @param id the id of the pet to find
|
|
|
|
* @param data the data to store on the pet
|
|
|
|
*/
|
2021-12-05 17:54:36 +00:00
|
|
|
void SetDatabasePet(LWOOBJID id, const DatabasePet& data);
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
/**
|
|
|
|
* Returns the database pet information for an object
|
|
|
|
* @param id the object ID to search for
|
|
|
|
* @return the database pet information for the object that belongs to the passed id
|
|
|
|
*/
|
2021-12-05 17:54:36 +00:00
|
|
|
const DatabasePet& GetDatabasePet(LWOOBJID id) const;
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
/**
|
|
|
|
* Checks if the provided object ID is in this inventory and is a pet
|
|
|
|
* @param id the id of the object to check for
|
|
|
|
* @return if the provided object ID is in this inventory and is a pet
|
|
|
|
*/
|
2021-12-05 17:54:36 +00:00
|
|
|
bool IsPet(LWOOBJID id) const;
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
/**
|
|
|
|
* Removes pet database information from the item with the specified object id
|
|
|
|
* @param id the object id to remove pet info for
|
|
|
|
*/
|
2021-12-05 17:54:36 +00:00
|
|
|
void RemoveDatabasePet(LWOOBJID id);
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
/**
|
|
|
|
* Returns the current behavior slot active for the passed item type
|
|
|
|
* @param type the item type to find the behavior slot for
|
|
|
|
* @return the current behavior slot active for the passed item type
|
|
|
|
*/
|
2021-12-05 17:54:36 +00:00
|
|
|
static BehaviorSlot FindBehaviorSlot(eItemType type);
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
/**
|
|
|
|
* Checks if the inventory type is a temp inventory
|
|
|
|
* @param type the inventory type to check
|
|
|
|
* @return if the inventory type is a temp inventory
|
|
|
|
*/
|
2021-12-05 17:54:36 +00:00
|
|
|
static bool IsTransferInventory(eInventoryType type);
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
/**
|
|
|
|
* Finds the skill related to the passed LOT from the ObjectSkills table
|
|
|
|
* @param lot the lot to find
|
|
|
|
* @return the skill related to the passed LOT
|
|
|
|
*/
|
2021-12-05 17:54:36 +00:00
|
|
|
static uint32_t FindSkill(LOT lot);
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2022-12-21 22:33:41 +00:00
|
|
|
/**
|
|
|
|
* Call this when you equip an item. This calls OnFactionTriggerItemEquipped for any scripts found on the items.
|
2023-01-22 23:38:47 +00:00
|
|
|
*
|
2022-12-21 22:33:41 +00:00
|
|
|
* @param equippedItem The item script to lookup and call equip on
|
|
|
|
*/
|
|
|
|
void EquipScripts(Item* equippedItem);
|
2023-01-22 23:38:47 +00:00
|
|
|
|
2022-12-21 22:33:41 +00:00
|
|
|
/**
|
|
|
|
* Call this when you unequip an item. This calls OnFactionTriggerItemUnequipped for any scripts found on the items.
|
2023-01-22 23:38:47 +00:00
|
|
|
*
|
2022-12-21 22:33:41 +00:00
|
|
|
* @param unequippedItem The item script to lookup and call unequip on
|
|
|
|
*/
|
|
|
|
void UnequipScripts(Item* unequippedItem);
|
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
~InventoryComponent() override;
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
private:
|
2022-07-28 13:39:57 +00:00
|
|
|
/**
|
|
|
|
* All the inventory this entity possesses
|
|
|
|
*/
|
2021-12-05 17:54:36 +00:00
|
|
|
std::map<eInventoryType, Inventory*> m_Inventories;
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
/**
|
|
|
|
* The skills that this entity currently has active
|
|
|
|
*/
|
2021-12-05 17:54:36 +00:00
|
|
|
std::map<BehaviorSlot, uint32_t> m_Skills;
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
/**
|
|
|
|
* The pets this entity has, mapped by object ID and pet info
|
|
|
|
*/
|
2021-12-05 17:54:36 +00:00
|
|
|
std::unordered_map<LWOOBJID, DatabasePet> m_Pets;
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
/**
|
|
|
|
* Cache of item sets this entity has encountered
|
|
|
|
*/
|
2021-12-05 17:54:36 +00:00
|
|
|
std::vector<ItemSet*> m_Itemsets;
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
/**
|
|
|
|
* The LOTs we've checked all the item sets for (for cache reasons)
|
|
|
|
*/
|
2021-12-05 17:54:36 +00:00
|
|
|
std::vector<LOT> m_ItemSetsChecked;
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
/**
|
|
|
|
* all the equipped items
|
|
|
|
*/
|
2021-12-05 17:54:36 +00:00
|
|
|
EquipmentMap m_Equipped;
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
/**
|
|
|
|
* Clone of the equipped items before unequipping all of them
|
|
|
|
*/
|
2021-12-05 17:54:36 +00:00
|
|
|
EquipmentMap m_Pushed;
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
/**
|
|
|
|
* If the inventory has changed
|
|
|
|
*/
|
2021-12-05 17:54:36 +00:00
|
|
|
bool m_Dirty;
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
/**
|
|
|
|
* The currently active consumable
|
|
|
|
*/
|
2021-12-05 17:54:36 +00:00
|
|
|
LOT m_Consumable;
|
|
|
|
|
2023-07-15 08:54:41 +00:00
|
|
|
/**
|
|
|
|
* Equipped skills
|
|
|
|
*/
|
|
|
|
std::map<eSkillBar, std::map<BehaviorSlot, uint32_t>> m_EquippedSkills;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The currently selected skill bar
|
|
|
|
*/
|
|
|
|
eSkillBar m_SelectedSkillBar = eSkillBar::Primary;
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
/**
|
|
|
|
* Currently has a car equipped
|
|
|
|
*/
|
|
|
|
bool hasCarEquipped = false;
|
|
|
|
Entity* equippedCarEntity = nullptr;
|
|
|
|
LWOOBJID previousPossessableID = LWOOBJID_EMPTY;
|
|
|
|
LWOOBJID previousPossessorID = LWOOBJID_EMPTY;
|
|
|
|
/**
|
|
|
|
* Creates all the proxy items (subitems) for a parent item
|
|
|
|
* @param parent the parent item to generate all the subitems for
|
|
|
|
* @return the proxy items (subitems) for a parent item
|
|
|
|
*/
|
2021-12-05 17:54:36 +00:00
|
|
|
std::vector<Item*> GenerateProxies(Item* parent);
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
/**
|
|
|
|
* Finds all the proxy items in this inventory for a given parent item
|
|
|
|
* @param parent the parent to find proxy items for
|
|
|
|
* @return the proxy items for the parent
|
|
|
|
*/
|
2021-12-05 17:54:36 +00:00
|
|
|
std::vector<Item*> FindProxies(LWOOBJID parent);
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
/**
|
|
|
|
* Returns true if the provided LWOOBJID is the parent of this Item.
|
|
|
|
* @param parent the parent item to check for proxies
|
|
|
|
* @return if the provided ID is a valid proxy item
|
|
|
|
*/
|
2021-12-05 17:54:36 +00:00
|
|
|
bool IsValidProxy(LWOOBJID parent);
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
/**
|
|
|
|
* Returns if the provided ID is a valid proxy item (e.g. we have children for it)
|
|
|
|
* @param parent the parent item to check for
|
|
|
|
* @return if the provided ID is a valid proxy item
|
|
|
|
*/
|
2021-12-05 17:54:36 +00:00
|
|
|
bool IsParentValid(Item* root);
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
/**
|
|
|
|
* Removes all the proxy items that have a dangling parent
|
|
|
|
*/
|
2021-12-05 17:54:36 +00:00
|
|
|
void CheckProxyIntegrity();
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
/**
|
|
|
|
* Removes all the proxy items for a given parent from the inventory
|
|
|
|
* @param item the item to remove proxy items for
|
|
|
|
*/
|
2021-12-05 17:54:36 +00:00
|
|
|
void PurgeProxies(Item* item);
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
/**
|
|
|
|
* Saves all the pet information stored in inventory items to the database
|
|
|
|
* @param document the xml doc to save to
|
|
|
|
*/
|
2021-12-05 17:54:36 +00:00
|
|
|
void LoadPetXml(tinyxml2::XMLDocument* document);
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
/**
|
|
|
|
* Loads all the pet information from an xml doc into items
|
|
|
|
* @param document the xml doc to load from
|
|
|
|
*/
|
2021-12-05 17:54:36 +00:00
|
|
|
void UpdatePetXml(tinyxml2::XMLDocument* document);
|
|
|
|
};
|
2022-07-04 22:24:45 +00:00
|
|
|
|
|
|
|
#endif
|