Weapon RayZ

Weapon RayZ
This commit is contained in:
2016-01-25 10:25:44 +01:00
parent b95c1fdfa4
commit 4245264029
20 changed files with 300 additions and 20 deletions
+23 -12
View File
@@ -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;
}