add block.has_tag, item.has_tag

This commit is contained in:
MihailRis 2025-08-30 23:46:45 +03:00
parent 8bdf31d7bb
commit 185b6cc661
7 changed files with 41 additions and 6 deletions

View file

@ -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;