Added filter by attribute for array attributes
This commit is contained in:
parent
d7374230da
commit
b018dfb8f4
|
@ -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)};
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue