Added thing reconstruct
This commit is contained in:
parent
31c725b0ca
commit
26be4557c5
@ -72,7 +72,8 @@ void SiteServer::Process(Participant* sender, NetworkIdMsg* msg) {}
|
|||||||
void SiteServer::Process(Participant* sender, ThingMsg* msg) {
|
void SiteServer::Process(Participant* sender, ThingMsg* msg) {
|
||||||
Thing* thing = sender->Get(msg->thingId);
|
Thing* thing = sender->Get(msg->thingId);
|
||||||
if (thing == nullptr)
|
if (thing == nullptr)
|
||||||
new Thing(sender, (Thing::Type)msg->thingType, msg->thingId);
|
// new Thing(sender, (Thing::Type)msg->thingType, msg->thingId);
|
||||||
|
Thing::Reconstruct(sender, msg->thingType, msg->thingId);
|
||||||
|
|
||||||
if (msg->parentId != 0) {
|
if (msg->parentId != 0) {
|
||||||
thing->SetParent(Get(msg->parentId));
|
thing->SetParent(Get(msg->parentId));
|
||||||
|
16
Thing.cpp
16
Thing.cpp
@ -24,12 +24,12 @@ namespace RoboidControl {
|
|||||||
// : Thing(IsolatedParticipant::Isolated(), thingType) {}
|
// : Thing(IsolatedParticipant::Isolated(), thingType) {}
|
||||||
|
|
||||||
Thing::Thing(Participant* owner,
|
Thing::Thing(Participant* owner,
|
||||||
unsigned char thingType,
|
unsigned char thingType) {
|
||||||
unsigned char thingId) {
|
// unsigned char thingId) {
|
||||||
if (owner == nullptr)
|
if (owner == nullptr)
|
||||||
owner = IsolatedParticipant::Isolated();
|
owner = IsolatedParticipant::Isolated();
|
||||||
this->owner = owner;
|
this->owner = owner;
|
||||||
this->id = thingId;
|
// this->id = thingId;
|
||||||
this->type = thingType;
|
this->type = thingType;
|
||||||
|
|
||||||
this->position = Spherical::zero;
|
this->position = Spherical::zero;
|
||||||
@ -47,11 +47,17 @@ Thing::Thing(Participant* owner,
|
|||||||
this->owner->Add(this, true);
|
this->owner->Add(this, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
Thing::Thing(Thing* parent, unsigned char thingType, unsigned char thingId)
|
Thing::Thing(Thing* parent, unsigned char thingType) //, unsigned char thingId)
|
||||||
: Thing(parent->owner, thingType, thingId) {
|
: Thing(parent->owner, thingType) { //}, thingId) {
|
||||||
this->SetParent(parent);
|
this->SetParent(parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Thing Thing::Reconstruct(Participant* owner, unsigned char thingType, unsigned char thingId) {
|
||||||
|
Thing thing = Thing(owner, thingType);
|
||||||
|
thing.id = thingId;
|
||||||
|
return thing;
|
||||||
|
}
|
||||||
|
|
||||||
#pragma endregion Init
|
#pragma endregion Init
|
||||||
|
|
||||||
void Thing::SetName(const char* name) {
|
void Thing::SetName(const char* name) {
|
||||||
|
7
Thing.h
7
Thing.h
@ -51,8 +51,8 @@ class Thing {
|
|||||||
/// @param thingId The ID of the thing, leave out or set to zero to generate
|
/// @param thingId The ID of the thing, leave out or set to zero to generate
|
||||||
/// an ID
|
/// an ID
|
||||||
Thing(Participant* owner = nullptr,
|
Thing(Participant* owner = nullptr,
|
||||||
unsigned char thingType = Type::Undetermined,
|
unsigned char thingType = Type::Undetermined);
|
||||||
unsigned char thingId = 0);
|
//unsigned char thingId = 0);
|
||||||
|
|
||||||
/// @brief Create a new child thing
|
/// @brief Create a new child thing
|
||||||
/// @param parent The parent thing
|
/// @param parent The parent thing
|
||||||
@ -60,8 +60,9 @@ class Thing {
|
|||||||
/// @param thingId The ID of the thing, leave out or set to zero to generate
|
/// @param thingId The ID of the thing, leave out or set to zero to generate
|
||||||
/// an ID
|
/// an ID
|
||||||
/// @note The owner will be the same as the owner of the parent thing
|
/// @note The owner will be the same as the owner of the parent thing
|
||||||
Thing(Thing* parent, unsigned char thingType = 0, unsigned char thingId = 0);
|
Thing(Thing* parent, unsigned char thingType = 0); //, unsigned char thingId = 0);
|
||||||
|
|
||||||
|
static Thing Reconstruct(Participant* owner, unsigned char thingType, unsigned char thingId);
|
||||||
#pragma endregion Init
|
#pragma endregion Init
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user