From 9b6bce5155c3153a8d98687a90e63e83ff0a8445 Mon Sep 17 00:00:00 2001 From: Pascal Serrarens Date: Tue, 22 Oct 2024 11:25:38 +0200 Subject: [PATCH] Release thing method added --- Roboid.cpp | 8 +++++++- Roboid.h | 5 +++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Roboid.cpp b/Roboid.cpp index e687f4d..032f01a 100644 --- a/Roboid.cpp +++ b/Roboid.cpp @@ -31,7 +31,7 @@ Roboid::Roboid(Propulsion *propulsion) : Roboid() { propulsion->roboid = this; } -void Passer::RoboidControl::Roboid::SetName(char *name) { this->name = name; } +void Roboid::SetName(const char *name) { this->name = name; } #include void Roboid::Update(unsigned long currentTimeMs) { @@ -119,3 +119,9 @@ void Roboid::AddChild(Thing *child) { this->perception->AddSensor(childSensor); } } + +void Passer::RoboidControl::Roboid::Release(Thing *child) { + if (RemoveChild(child) != nullptr) + this->perception->AddTrackedObject(nullptr, Spherical16::zero, + SwingTwist16::identity, child->type); +} diff --git a/Roboid.h b/Roboid.h index 2a4c83d..0d40845 100644 --- a/Roboid.h +++ b/Roboid.h @@ -20,8 +20,8 @@ public: /// @param propulsion The Propulsion implementation to use for this Roboid Roboid(Propulsion *propulsion); - char *name = nullptr; - void SetName(char *name); + const char *name = nullptr; + void SetName(const char *name); /// @brief Update the state of the Roboid /// @param currentTimeMs The time in milliseconds when calling this @@ -67,6 +67,7 @@ public: virtual void SetOrientation(SwingTwist16 worldOrientation); virtual void AddChild(Thing *child) override; + void Release(Thing *child); private: /// @brief The position of the roboid in carthesian coordinates in world space