block inventories (backend)

This commit is contained in:
MihailRis 2024-02-12 18:28:18 +03:00
parent fe57c38edf
commit 87f50f79c9
12 changed files with 108 additions and 18 deletions

View file

@ -23,6 +23,8 @@ class Lightmap;
class ContentLUT;
class Inventory;
using chunk_inventories_map = std::unordered_map<uint, std::shared_ptr<Inventory>>;
class Chunk {
public:
int x, z;
@ -32,7 +34,7 @@ public:
int flags = 0;
/* Block inventories map where key is index of block in voxels array */
std::unordered_map<uint, std::shared_ptr<Inventory>> inventories;
chunk_inventories_map inventories;
Chunk(int x, int z);
@ -55,6 +57,8 @@ public:
@return inventory id or 0 if block does not exists */
void addBlockInventory(std::shared_ptr<Inventory> inventory,
uint x, uint y, uint z);
void removeBlockInventory(uint x, uint y, uint z);
void setBlockInventories(chunk_inventories_map map);
/* @return inventory bound to the given block or nullptr */
std::shared_ptr<Inventory> getBlockInventory(uint x, uint y, uint z) const;