Added filter by attribute for array attributes

This commit is contained in:
LuisPoveda 2023-02-13 10:47:58 +01:00 committed by bernat
parent d7374230da
commit b018dfb8f4
1 changed files with 19 additions and 3 deletions

View File

@ -36,14 +36,30 @@ namespace client {
SharedPtr<BlueprintLibrary> BlueprintLibrary::FilterByAttribute(
const std::string &name, const std::string& value) const {
map_type result;
for (auto &pair : _blueprints) {
if (!pair.second.ContainsAttribute(name))
continue;
const ActorAttribute &Attribute = pair.second.GetAttribute(name);
const std::string &AttributeValue = Attribute.GetValue();
if (value == AttributeValue) {
result.emplace(pair);
const std::vector<std::string> &Values = Attribute.GetRecommendedValues();
if (Values.empty())
{
const std::string &AttributeValue = Attribute.GetValue();
if (value == AttributeValue)
result.emplace(pair);
}
else
{
for (const std::string &Value : Values)
{
if (Value == value)
{
result.emplace(pair);
break;
}
}
}
}
return SharedPtr<BlueprintLibrary>{new BlueprintLibrary(result)};
}