![]() |
Botcraft 1.21.5
|
#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 packet | |
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 39 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, Botcraft::PlayerInventory, and trading_container_id.
|
private |
Definition at line 221 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 475 of file InventoryManager.cpp.
References ApplyTransactionImpl(), and inventory_manager_mutex.
|
private |
Definition at line 457 of file InventoryManager.cpp.
References Botcraft::InventoryTransaction::carried_item, Botcraft::InventoryTransaction::changed_slots, cursor, inventories, and Botcraft::InventoryTransaction::packet.
Referenced by ApplyTransaction().
void Botcraft::InventoryManager::EraseInventory | ( | const short | window_id | ) |
Definition at line 109 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 482 of file InventoryManager.cpp.
References available_trades, and inventory_manager_mutex.
Slot Botcraft::InventoryManager::GetCursor | ( | ) | const |
Definition at line 237 of file InventoryManager.cpp.
References cursor, and inventory_manager_mutex.
short Botcraft::InventoryManager::GetFirstOpenedWindowId | ( | ) | const |
Definition at line 70 of file InventoryManager.cpp.
References inventories, inventory_manager_mutex, and Botcraft::Window::PLAYER_INVENTORY_INDEX.
Slot Botcraft::InventoryManager::GetHotbarSelected | ( | ) | const |
Definition at line 85 of file InventoryManager.cpp.
References GetPlayerInventory(), index_hotbar_selected, and Botcraft::Window::INVENTORY_HOTBAR_START.
short Botcraft::InventoryManager::GetIndexHotbarSelected | ( | ) | const |
Definition at line 64 of file InventoryManager.cpp.
References index_hotbar_selected, and inventory_manager_mutex.
Slot Botcraft::InventoryManager::GetOffHand | ( | ) | const |
Definition at line 97 of file InventoryManager.cpp.
References GetPlayerInventory(), and Botcraft::Window::INVENTORY_OFFHAND_INDEX.
std::shared_ptr< Window > Botcraft::InventoryManager::GetPlayerInventory | ( | ) | const |
Definition at line 59 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 48 of file InventoryManager.cpp.
References inventories, and inventory_manager_mutex.
Referenced by GetPlayerInventory(), Handle(), and PrepareTransaction().
|
overrideprivatevirtual |
Definition at line 641 of file InventoryManager.cpp.
References EraseInventory().
|
overrideprivatevirtual |
Definition at line 533 of file InventoryManager.cpp.
References GetWindow(), and SetStateId().
|
overrideprivatevirtual |
Definition at line 502 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 633 of file InventoryManager.cpp.
References available_trades, inventory_manager_mutex, and trading_container_id.
|
overrideprivatevirtual |
Definition at line 549 of file InventoryManager.cpp.
References AddInventory(), Botcraft::Crafting, Botcraft::Default, Botcraft::Generic9x3, Botcraft::Generic9x6, and LOG_ERROR.
|
overrideprivatevirtual |
Definition at line 647 of file InventoryManager.cpp.
References index_hotbar_selected, Botcraft::Window::INVENTORY_HOTBAR_START, Botcraft::Window::PLAYER_INVENTORY_INDEX, and SetSlot().
|
overrideprivatevirtual |
Definition at line 585 of file InventoryManager.cpp.
|
overrideprivatevirtual |
Definition at line 653 of file InventoryManager.cpp.
References Botcraft::Window::PLAYER_INVENTORY_INDEX, and SetSlot().
void Botcraft::InventoryManager::IncrementMerchantOfferUse | ( | const int | index | ) |
Definition at line 488 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 packet
transaction | The transaction to update with the modifications |
Definition at line 249 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 243 of file InventoryManager.cpp.
References cursor, and inventory_manager_mutex.
Referenced by Handle().
|
private |
Definition at line 231 of file InventoryManager.cpp.
References index_hotbar_selected, and inventory_manager_mutex.
|
private |
Definition at line 22 of file InventoryManager.cpp.
References inventories, inventory_manager_mutex, and LOG_WARNING.
|
private |
Definition at line 209 of file InventoryManager.cpp.
References inventories, and inventory_manager_mutex.
|
private |
Definition at line 183 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 121 of file InventoryManager.hpp.
Referenced by EraseInventory(), GetAvailableMerchantOffers(), Handle(), and IncrementMerchantOfferUse().
|
private |
Definition at line 110 of file InventoryManager.hpp.
Referenced by ApplyTransactionImpl(), GetCursor(), InventoryManager(), PrepareTransaction(), and SetCursor().
|
private |
Definition at line 109 of file InventoryManager.hpp.
Referenced by GetHotbarSelected(), GetIndexHotbarSelected(), Handle(), InventoryManager(), and SetHotbarSelected().
|
private |
Definition at line 108 of file InventoryManager.hpp.
Referenced by AddInventory(), ApplyTransactionImpl(), EraseInventory(), GetFirstOpenedWindowId(), GetWindow(), InventoryManager(), SetSlot(), SetStateId(), and SynchronizeContainerPlayerInventory().
|
mutableprivate |
Definition at line 106 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 120 of file InventoryManager.hpp.
Referenced by EraseInventory(), Handle(), and InventoryManager().