mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-06 03:21:49 +00:00
lua: inventory.clone
This commit is contained in:
parent
60902e69ba
commit
cac963bd7b
5 changed files with 29 additions and 0 deletions
|
|
@ -44,6 +44,16 @@ std::shared_ptr<Inventory> Inventories::get(int64_t id) {
|
|||
return found->second;
|
||||
}
|
||||
|
||||
std::shared_ptr<Inventory> Inventories::clone(int64_t id) {
|
||||
auto original = get(id);
|
||||
if (original == nullptr)
|
||||
return nullptr;
|
||||
auto origptr = reinterpret_cast<const Inventory*>(original.get());
|
||||
auto clone = std::make_shared<Inventory>(*origptr);
|
||||
clone->setId(level.getWorld()->getNextInventoryId());
|
||||
return clone;
|
||||
}
|
||||
|
||||
const inventories_map& Inventories::getMap() const {
|
||||
return map;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue