FindChild by name
This commit is contained in:
parent
f1a6ea29c4
commit
4ebe38eb39
17
Thing.cpp
17
Thing.cpp
@ -1,5 +1,7 @@
|
||||
#include "Thing.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
using namespace Passer::RoboidControl;
|
||||
|
||||
Thing::Thing(unsigned char id) : id(id) {
|
||||
@ -93,6 +95,21 @@ Thing *Passer::RoboidControl::Thing::RemoveChild(Thing *child) {
|
||||
return child;
|
||||
}
|
||||
|
||||
Thing *Thing::FindChild(const char *name) {
|
||||
for (unsigned char childIx = 0; childIx < this->childCount; childIx++) {
|
||||
Thing *child = this->children[childIx];
|
||||
if (child == nullptr)
|
||||
continue;
|
||||
if (strcmp(child->name, name) == 0)
|
||||
return child;
|
||||
|
||||
Thing *foundChild = child->FindChild(name);
|
||||
if (foundChild != nullptr)
|
||||
return foundChild;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Spherical16 Thing::GetLinearVelocity() { return this->linearVelocity; }
|
||||
|
||||
Spherical16 Thing::GetAngularVelocity() { return this->angularVelocity; }
|
Loading…
x
Reference in New Issue
Block a user