mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-04 18:41:51 +00:00
86 lines
2.5 KiB
C++
86 lines
2.5 KiB
C++
#include "Content.hpp"
|
|
|
|
#include <glm/glm.hpp>
|
|
#include <memory>
|
|
#include <stdexcept>
|
|
#include <utility>
|
|
|
|
#include "items/ItemDef.hpp"
|
|
#include "logic/scripting/scripting.hpp"
|
|
#include "objects/EntityDef.hpp"
|
|
#include "voxels/Block.hpp"
|
|
#include "world/generator/VoxelFragment.hpp"
|
|
#include "world/generator/GeneratorDef.hpp"
|
|
#include "ContentPack.hpp"
|
|
|
|
ContentIndices::ContentIndices(
|
|
ContentUnitIndices<Block, blockid_t> blocks,
|
|
ContentUnitIndices<ItemDef, itemid_t> items,
|
|
ContentUnitIndices<EntityDef, entitydefid_t> entities
|
|
)
|
|
: blocks(std::move(blocks)),
|
|
items(std::move(items)),
|
|
entities(std::move(entities)) {
|
|
}
|
|
|
|
Content::Content(
|
|
std::unique_ptr<ContentIndices> indices,
|
|
std::unique_ptr<DrawGroups> drawGroups,
|
|
ContentUnitDefs<Block> blocks,
|
|
ContentUnitDefs<ItemDef> items,
|
|
ContentUnitDefs<EntityDef> entities,
|
|
ContentUnitDefs<GeneratorDef> generators,
|
|
UptrsMap<std::string, ContentPackRuntime> packs,
|
|
UptrsMap<std::string, BlockMaterial> blockMaterials,
|
|
ResourceIndicesSet resourceIndices,
|
|
dv::value defaults,
|
|
std::unordered_map<std::string, int> tags
|
|
)
|
|
: indices(std::move(indices)),
|
|
packs(std::move(packs)),
|
|
blockMaterials(std::move(blockMaterials)),
|
|
defaults(std::move(defaults)),
|
|
tags(std::move(tags)),
|
|
blocks(std::move(blocks)),
|
|
items(std::move(items)),
|
|
entities(std::move(entities)),
|
|
generators(std::move(generators)),
|
|
drawGroups(std::move(drawGroups)) {
|
|
for (size_t i = 0; i < RESOURCE_TYPES_COUNT; i++) {
|
|
this->resourceIndices[i] = std::move(resourceIndices[i]);
|
|
}
|
|
}
|
|
|
|
Content::~Content() = default;
|
|
|
|
const BlockMaterial* Content::findBlockMaterial(const std::string& id) const {
|
|
auto found = blockMaterials.find(id);
|
|
if (found == blockMaterials.end()) {
|
|
return nullptr;
|
|
}
|
|
return found->second.get();
|
|
}
|
|
|
|
const ContentPackRuntime* Content::getPackRuntime(const std::string& id) const {
|
|
auto found = packs.find(id);
|
|
if (found == packs.end()) {
|
|
return nullptr;
|
|
}
|
|
return found->second.get();
|
|
}
|
|
|
|
ContentPackRuntime* Content::getPackRuntime(const std::string& id) {
|
|
auto found = packs.find(id);
|
|
if (found == packs.end()) {
|
|
return nullptr;
|
|
}
|
|
return found->second.get();
|
|
}
|
|
|
|
const UptrsMap<std::string, BlockMaterial>& Content::getBlockMaterials() const {
|
|
return blockMaterials;
|
|
}
|
|
|
|
const UptrsMap<std::string, ContentPackRuntime>& Content::getPacks() const {
|
|
return packs;
|
|
}
|