Weapon RayZ
Weapon RayZ
This commit is contained in:
@@ -22,18 +22,7 @@ EntityWrapper EntityWrapper::Parent()
|
||||
|
||||
EntityWrapper EntityWrapper::FirstChildByName(const std::string& name)
|
||||
{
|
||||
auto itPair = this->World->GetChildren(this->ID);
|
||||
if (itPair.first == itPair.second) {
|
||||
return EntityWrapper::Invalid;
|
||||
}
|
||||
|
||||
for (auto it = itPair.first; it != itPair.second; ++it) {
|
||||
if (this->World->GetName(it->second) == name) {
|
||||
return EntityWrapper(this->World, it->second);
|
||||
}
|
||||
}
|
||||
|
||||
return EntityWrapper::Invalid;
|
||||
return firstChildByNameRecursive(name, this->ID);
|
||||
}
|
||||
|
||||
EntityWrapper EntityWrapper::FirstParentWithComponent(const std::string& componentType)
|
||||
@@ -108,3 +97,25 @@ EntityWrapper::operator bool()
|
||||
return this->Valid();
|
||||
}
|
||||
|
||||
EntityWrapper EntityWrapper::firstChildByNameRecursive(const std::string& name, EntityID parent)
|
||||
{
|
||||
auto itPair = this->World->GetChildren(parent);
|
||||
if (itPair.first == itPair.second) {
|
||||
return EntityWrapper::Invalid;
|
||||
}
|
||||
|
||||
for (auto it = itPair.first; it != itPair.second; ++it) {
|
||||
std::string itName = this->World->GetName(it->second);
|
||||
if (itName == name) {
|
||||
return EntityWrapper(this->World, it->second);
|
||||
} else if (it->second != EntityID_Invalid) {
|
||||
EntityWrapper result = firstChildByNameRecursive(name, it->second);
|
||||
if (result != EntityWrapper::Invalid) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return EntityWrapper::Invalid;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user