mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-10 05:21:49 +00:00
lua: inventory library
This commit is contained in:
parent
617017d979
commit
e16f7567b1
14 changed files with 257 additions and 44 deletions
39
src/items/Inventories.h
Normal file
39
src/items/Inventories.h
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
#ifndef ITEMS_INVENTORIES_H_
|
||||
#define ITEMS_INVENTORIES_H_
|
||||
|
||||
#include <string>
|
||||
#include <memory>
|
||||
#include <unordered_map>
|
||||
|
||||
#include "Inventory.h"
|
||||
#include "../maths/util.h"
|
||||
|
||||
class Level;
|
||||
|
||||
using inventories_map = std::unordered_map<int64_t, std::shared_ptr<Inventory>>;
|
||||
|
||||
/* Inventories runtime storage */
|
||||
class Inventories {
|
||||
Level& level;
|
||||
inventories_map map;
|
||||
PseudoRandom random;
|
||||
public:
|
||||
Inventories(Level& level);
|
||||
~Inventories();
|
||||
|
||||
/* Create new inventory with new id */
|
||||
std::shared_ptr<Inventory> create(size_t size);
|
||||
|
||||
/* Create runtime-only inventory (has negative id) */
|
||||
std::shared_ptr<Inventory> createVirtual(size_t size);
|
||||
|
||||
/* Store inventory */
|
||||
void store(std::shared_ptr<Inventory> inv);
|
||||
|
||||
/* Get inventory by id (works with both real and virtual)*/
|
||||
std::shared_ptr<Inventory> get(int64_t id);
|
||||
|
||||
const inventories_map& getMap() const;
|
||||
};
|
||||
|
||||
#endif // ITEMS_INVENTORIES_H_
|
||||
Loading…
Add table
Add a link
Reference in a new issue