Добавил фильтрацию по типу в GetActorsByTag
This commit is contained in:
+13
-10
@@ -31,10 +31,10 @@ public:
|
||||
void load(std::shared_ptr<SaveMap> save) override;
|
||||
#pragma endregion
|
||||
|
||||
template<class T, class Container = std::vector<std::weak_ptr<T>>>
|
||||
Container GetActorsByClass()
|
||||
template<class T, template<class...> class Container = std::vector>
|
||||
Container<std::weak_ptr<T>> GetActorsByClass()
|
||||
{
|
||||
Container list;
|
||||
Container<std::weak_ptr<T>> list;
|
||||
for (auto i = actors_map.cbegin(); i != actors_map.cend(); ++i)
|
||||
{
|
||||
if (RTTI::dyn_cast<T, Actor>(i->second.get()))
|
||||
@@ -57,18 +57,21 @@ public:
|
||||
|
||||
void DestroyActor(std::weak_ptr<Actor> ptr);
|
||||
|
||||
template<class T, class Container = std::vector<std::weak_ptr<T>>>
|
||||
Container GetActorsByTag(std::string tag)
|
||||
template<class T, template<class...> class Container = std::vector>
|
||||
Container<std::weak_ptr<T>> GetActorsByTag(std::string tag)
|
||||
{
|
||||
Container container;
|
||||
Container<std::weak_ptr<T>> container;
|
||||
|
||||
for (auto& i : actors_map)
|
||||
{
|
||||
const std::list<std::string>& tags = i.second->GetTags();
|
||||
for (auto& j : tags)
|
||||
if (RTTI::dyn_cast<T, Actor>(i.second.get()))
|
||||
{
|
||||
if (j == tag)
|
||||
container.push_back(i.second);
|
||||
const std::list<std::string>& tags = i.second->GetTags();
|
||||
for (auto& j : tags)
|
||||
{
|
||||
if (j == tag)
|
||||
container.push_back(i.second);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user