mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-06 03:21:49 +00:00
add block.has_tag, item.has_tag
This commit is contained in:
parent
8bdf31d7bb
commit
185b6cc661
7 changed files with 41 additions and 6 deletions
|
|
@ -35,13 +35,15 @@ Content::Content(
|
|||
UptrsMap<std::string, BlockMaterial> blockMaterials,
|
||||
UptrsMap<std::string, rigging::SkeletonConfig> skeletons,
|
||||
ResourceIndicesSet resourceIndices,
|
||||
dv::value defaults
|
||||
dv::value defaults,
|
||||
std::unordered_map<std::string, int> tags
|
||||
)
|
||||
: indices(std::move(indices)),
|
||||
packs(std::move(packs)),
|
||||
blockMaterials(std::move(blockMaterials)),
|
||||
skeletons(std::move(skeletons)),
|
||||
defaults(std::move(defaults)),
|
||||
tags(std::move(tags)),
|
||||
blocks(std::move(blocks)),
|
||||
items(std::move(items)),
|
||||
entities(std::move(entities)),
|
||||
|
|
|
|||
|
|
@ -176,6 +176,7 @@ class Content {
|
|||
UptrsMap<std::string, BlockMaterial> blockMaterials;
|
||||
UptrsMap<std::string, rigging::SkeletonConfig> skeletons;
|
||||
dv::value defaults = nullptr;
|
||||
std::unordered_map<std::string, int> tags;
|
||||
public:
|
||||
ContentUnitDefs<Block> blocks;
|
||||
ContentUnitDefs<ItemDef> items;
|
||||
|
|
@ -195,7 +196,8 @@ public:
|
|||
UptrsMap<std::string, BlockMaterial> blockMaterials,
|
||||
UptrsMap<std::string, rigging::SkeletonConfig> skeletons,
|
||||
ResourceIndicesSet resourceIndices,
|
||||
dv::value defaults
|
||||
dv::value defaults,
|
||||
std::unordered_map<std::string, int> tags
|
||||
);
|
||||
~Content();
|
||||
|
||||
|
|
@ -211,6 +213,14 @@ public:
|
|||
return defaults;
|
||||
}
|
||||
|
||||
int getTagIndex(const std::string& tag) const {
|
||||
const auto& found = tags.find(tag);
|
||||
if (found == tags.end()) {
|
||||
return -1;
|
||||
}
|
||||
return found->second;
|
||||
}
|
||||
|
||||
const rigging::SkeletonConfig* getSkeleton(const std::string& id) const;
|
||||
const rigging::SkeletonConfig& requireSkeleton(const std::string& id) const;
|
||||
const BlockMaterial* findBlockMaterial(const std::string& id) const;
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ std::unique_ptr<Content> ContentBuilder::build() {
|
|||
def.rt.id = blockDefsIndices.size();
|
||||
def.rt.emissive = *reinterpret_cast<uint32_t*>(def.emission);
|
||||
for (const auto& tag : def.tags) {
|
||||
def.rt.tags.push_back(tags.add(tag));
|
||||
def.rt.tags.insert(tags.add(tag));
|
||||
}
|
||||
|
||||
if (def.variants) {
|
||||
|
|
@ -96,7 +96,8 @@ std::unique_ptr<Content> ContentBuilder::build() {
|
|||
std::move(blockMaterials),
|
||||
std::move(skeletons),
|
||||
std::move(resourceIndices),
|
||||
std::move(defaults)
|
||||
std::move(defaults),
|
||||
std::move(tags.map)
|
||||
);
|
||||
|
||||
// Now, it's time to resolve foreign keys
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue