![]() |
Botcraft 1.21.4
|
#include <InventoryManager.hpp>
Public Member Functions | |
InventoryManager () | |
std::shared_ptr< Window > | GetWindow (const short window_id) const |
short | GetFirstOpenedWindowId () const |
std::shared_ptr< Window > | GetPlayerInventory () const |
short | GetIndexHotbarSelected () const |
ProtocolCraft::Slot | GetHotbarSelected () const |
ProtocolCraft::Slot | GetOffHand () const |
ProtocolCraft::Slot | GetCursor () const |
void | EraseInventory (const short window_id) |
InventoryTransaction | PrepareTransaction (const std::shared_ptr< ProtocolCraft::ServerboundContainerClickPacket > &transaction) |
"think" about the changes made by this transaction, filling in the necessary values in the msg | |
void | ApplyTransaction (const InventoryTransaction &transaction) |
Apply a given transaction to a container. | |
std::vector< ProtocolCraft::MerchantOffer > | GetAvailableMerchantOffers () const |
void | IncrementMerchantOfferUse (const int index) |
Private Attributes | |
std::shared_mutex | inventory_manager_mutex |
std::map< short, std::shared_ptr< Window > > | inventories |
short | index_hotbar_selected |
ProtocolCraft::Slot | cursor |
int | trading_container_id |
std::vector< ProtocolCraft::MerchantOffer > | available_trades |
Definition at line 37 of file InventoryManager.hpp.
Botcraft::InventoryManager::InventoryManager | ( | ) |
Definition at line 10 of file InventoryManager.cpp.
References cursor, index_hotbar_selected, inventories, inventory_manager_mutex, Botcraft::Window::PLAYER_INVENTORY_INDEX, and Botcraft::PlayerInventory.
|
private |
Definition at line 218 of file InventoryManager.cpp.
References inventories, and inventory_manager_mutex.
Referenced by Handle().
void Botcraft::InventoryManager::ApplyTransaction | ( | const InventoryTransaction & | transaction | ) |
Apply a given transaction to a container.
transaction | The transaction to apply |
Definition at line 460 of file InventoryManager.cpp.
References ApplyTransactionImpl(), and inventory_manager_mutex.
|
private |
Definition at line 442 of file InventoryManager.cpp.
References cursor, inventories, and Botcraft::InventoryTransaction::msg.
Referenced by ApplyTransaction().
void Botcraft::InventoryManager::EraseInventory | ( | const short | window_id | ) |
Definition at line 106 of file InventoryManager.cpp.
References available_trades, inventories, inventory_manager_mutex, Botcraft::Window::PLAYER_INVENTORY_INDEX, SynchronizeContainerPlayerInventory(), and trading_container_id.
Referenced by Handle().
std::vector< MerchantOffer > Botcraft::InventoryManager::GetAvailableMerchantOffers | ( | ) | const |
Definition at line 467 of file InventoryManager.cpp.
References available_trades, and inventory_manager_mutex.
Slot Botcraft::InventoryManager::GetCursor | ( | ) | const |
Definition at line 234 of file InventoryManager.cpp.
References cursor, and inventory_manager_mutex.
short Botcraft::InventoryManager::GetFirstOpenedWindowId | ( | ) | const |
Definition at line 67 of file InventoryManager.cpp.
References inventories, inventory_manager_mutex, and Botcraft::Window::PLAYER_INVENTORY_INDEX.
Slot Botcraft::InventoryManager::GetHotbarSelected | ( | ) | const |
Definition at line 82 of file InventoryManager.cpp.
References GetPlayerInventory(), index_hotbar_selected, and Botcraft::Window::INVENTORY_HOTBAR_START.
short Botcraft::InventoryManager::GetIndexHotbarSelected | ( | ) | const |
Definition at line 61 of file InventoryManager.cpp.
References index_hotbar_selected, and inventory_manager_mutex.
Slot Botcraft::InventoryManager::GetOffHand | ( | ) | const |
Definition at line 94 of file InventoryManager.cpp.
References GetPlayerInventory(), and Botcraft::Window::INVENTORY_OFFHAND_INDEX.
std::shared_ptr< Window > Botcraft::InventoryManager::GetPlayerInventory | ( | ) | const |
Definition at line 56 of file InventoryManager.cpp.
References GetWindow(), and Botcraft::Window::PLAYER_INVENTORY_INDEX.
Referenced by GetHotbarSelected(), and GetOffHand().
std::shared_ptr< Window > Botcraft::InventoryManager::GetWindow | ( | const short | window_id | ) | const |
Definition at line 45 of file InventoryManager.cpp.
References inventories, and inventory_manager_mutex.
Referenced by GetPlayerInventory(), Handle(), and PrepareTransaction().
|
overrideprivatevirtual |
Definition at line 626 of file InventoryManager.cpp.
References EraseInventory().
|
overrideprivatevirtual |
Definition at line 518 of file InventoryManager.cpp.
References GetWindow(), and SetStateId().
|
overrideprivatevirtual |
Definition at line 487 of file InventoryManager.cpp.
References Botcraft::Window::INVENTORY_HOTBAR_START, Botcraft::Window::INVENTORY_OFFHAND_INDEX, LOG_WARNING, Botcraft::Window::PLAYER_INVENTORY_INDEX, SetCursor(), SetSlot(), and SetStateId().
|
overrideprivatevirtual |
Definition at line 618 of file InventoryManager.cpp.
References available_trades, inventory_manager_mutex, and trading_container_id.
|
overrideprivatevirtual |
Definition at line 534 of file InventoryManager.cpp.
References AddInventory(), Botcraft::Crafting, Botcraft::Default, Botcraft::Generic9x3, Botcraft::Generic9x6, and LOG_ERROR.
|
overrideprivatevirtual |
Definition at line 632 of file InventoryManager.cpp.
References index_hotbar_selected, Botcraft::Window::INVENTORY_HOTBAR_START, Botcraft::Window::PLAYER_INVENTORY_INDEX, and SetSlot().
|
overrideprivatevirtual |
Definition at line 570 of file InventoryManager.cpp.
|
overrideprivatevirtual |
Definition at line 638 of file InventoryManager.cpp.
References Botcraft::Window::PLAYER_INVENTORY_INDEX, and SetSlot().
void Botcraft::InventoryManager::IncrementMerchantOfferUse | ( | const int | index | ) |
Definition at line 473 of file InventoryManager.cpp.
References available_trades, inventory_manager_mutex, and LOG_WARNING.
InventoryTransaction Botcraft::InventoryManager::PrepareTransaction | ( | const std::shared_ptr< ProtocolCraft::ServerboundContainerClickPacket > & | transaction | ) |
"think" about the changes made by this transaction, filling in the necessary values in the msg
transaction | The transaction to update with the modifications |
Definition at line 246 of file InventoryManager.cpp.
References Botcraft::Crafting, cursor, Botcraft::AssetsManager::getInstance(), GetWindow(), inventory_manager_mutex, ProtocolCraft::Slot::IsEmptySlot(), Botcraft::AssetsManager::Items(), LOG_ERROR, Botcraft::PlayerInventory, and ProtocolCraft::Slot::SameItem().
|
private |
Definition at line 240 of file InventoryManager.cpp.
References cursor, and inventory_manager_mutex.
Referenced by Handle().
|
private |
Definition at line 228 of file InventoryManager.cpp.
References index_hotbar_selected, and inventory_manager_mutex.
|
private |
Definition at line 19 of file InventoryManager.cpp.
References inventories, inventory_manager_mutex, and LOG_WARNING.
|
private |
Definition at line 206 of file InventoryManager.cpp.
References inventories, and inventory_manager_mutex.
|
private |
Definition at line 180 of file InventoryManager.cpp.
References inventories, Botcraft::Window::INVENTORY_HOTBAR_START, Botcraft::Window::INVENTORY_STORAGE_START, LOG_WARNING, and Botcraft::Window::PLAYER_INVENTORY_INDEX.
Referenced by EraseInventory().
|
private |
Definition at line 119 of file InventoryManager.hpp.
Referenced by EraseInventory(), GetAvailableMerchantOffers(), Handle(), and IncrementMerchantOfferUse().
|
private |
Definition at line 108 of file InventoryManager.hpp.
Referenced by ApplyTransactionImpl(), GetCursor(), InventoryManager(), PrepareTransaction(), and SetCursor().
|
private |
Definition at line 107 of file InventoryManager.hpp.
Referenced by GetHotbarSelected(), GetIndexHotbarSelected(), Handle(), InventoryManager(), and SetHotbarSelected().
|
private |
Definition at line 106 of file InventoryManager.hpp.
Referenced by AddInventory(), ApplyTransactionImpl(), EraseInventory(), GetFirstOpenedWindowId(), GetWindow(), InventoryManager(), SetSlot(), SetStateId(), and SynchronizeContainerPlayerInventory().
|
mutableprivate |
Definition at line 104 of file InventoryManager.hpp.
Referenced by AddInventory(), ApplyTransaction(), EraseInventory(), GetAvailableMerchantOffers(), GetCursor(), GetFirstOpenedWindowId(), GetIndexHotbarSelected(), GetWindow(), Handle(), IncrementMerchantOfferUse(), InventoryManager(), PrepareTransaction(), SetCursor(), SetHotbarSelected(), SetSlot(), and SetStateId().
|
private |
Definition at line 118 of file InventoryManager.hpp.
Referenced by EraseInventory(), and Handle().