diff --git a/Source/Engine/Level/Tags.cpp b/Source/Engine/Level/Tags.cpp index 7f287022f..602aea445 100644 --- a/Source/Engine/Level/Tags.cpp +++ b/Source/Engine/Level/Tags.cpp @@ -55,6 +55,24 @@ Tag Tags::Get(const StringView& tagName) return tag; } +Array Tags::GetSubTags(Tag parentTag) +{ + Array subTags; + const String& parentTagName = parentTag.ToString(); + + for (int i = 0; i < Tags::List.Count(); i++) + { + const Tag tag = Tag(i + 1); + const String& tagName = Tags::List[i]; + if (tagName.StartsWith(parentTagName) && parentTag.Index != tag.Index) + { + subTags.Add(tag); + } + } + + return subTags; +} + bool Tags::HasTag(const Array& list, const Tag tag) { if (tag.Index == 0) diff --git a/Source/Engine/Level/Tags.h b/Source/Engine/Level/Tags.h index b15b5087f..864adcda7 100644 --- a/Source/Engine/Level/Tags.h +++ b/Source/Engine/Level/Tags.h @@ -92,6 +92,13 @@ API_CLASS(Static) class FLAXENGINE_API Tags /// The tag. API_FUNCTION() static Tag Get(const StringView& tagName); + /// + /// Get all subtags of the specific Tag + /// + /// + /// + API_FUNCTION() static Array GetSubTags(Tag tag); + public: /// /// Checks if the list of tags contains a given tag (including parent tags check). For example, HasTag({"A.B"}, "A") returns true, for exact check use HasTagExact.