#include "Sensor.h" #include "Roboid.h" Sensor::Sensor() : Thing() { // this->type = (unsigned char)Type::Sensor; } // void Sensor::SetParent(Thing *parent) { // this->parent = parent; // if (this->parent != nullptr && // this->parent->GetParent() == nullptr) { // Is the parent a root object? // // Then it is a roboid // Roboid *roboidParent = (Roboid *)this->parent; // roboidParent->perception->AddSensor(this); // } // } void Sensor::ConnectTo(Thing *oldThing) { this->name = oldThing->name; this->id = oldThing->id; Thing *oldParent = oldThing->GetParent(); oldParent->RemoveChild(oldThing); oldParent->AddChild(this); for (int childIx = 0; childIx < oldThing->childCount; childIx++) { Thing *child = oldThing->GetChildByIndex(childIx); this->AddChild(child); } this->position = oldThing->GetPosition(); this->orientation = oldThing->GetOrientation(); // delete (thing); // can we do this? } void Sensor::ConnectTo(Thing *rootThing, const char *thingName) { Thing *thing = rootThing->FindThing(thingName); if (thing != nullptr) this->ConnectTo(thing); }