RoboidControl-cpp/Sensor.cpp
2024-11-27 13:40:58 +01:00

34 lines
864 B
C++

#include "Sensor.h"
#include "Roboid.h"
Sensor::Sensor() : Thing(0) { // for now, id should be set properly later
this->type = Thing::SensorType;
}
void Sensor::SetParent(Thing *parent) {
this->parent = parent;
if (this->parent->IsRoboid()) {
Roboid *roboidParent = (Roboid *)this->parent;
roboidParent->perception->AddSensor(this);
}
}
void Sensor::ConnectTo(Thing *thing) {
this->name = thing->name;
this->id = thing->id;
Thing *thingParent = thing->GetParent();
thingParent->RemoveChild(thing);
thingParent->AddChild(this);
this->children = thing->GetChildren();
this->position = thing->position;
this->orientation = thing->orientation;
// delete (thing); // can we do this?
}
void Sensor::ConnectTo(Thing *rootThing, const char *thingName) {
Thing *thing = rootThing->FindChild(thingName);
this->ConnectTo(thing);
}