Updated interactions with objects subsystem
This commit is contained in:
parent
f20bb7c2d9
commit
39935c4ecd
2 changed files with 76 additions and 2 deletions
|
|
@ -1,7 +1,81 @@
|
||||||
#include "object_system.h"
|
#include "object_system.h"
|
||||||
|
|
||||||
|
|
||||||
|
const dpoint_entity& object_system::get_dpoint(entity_id oid, bool &success) {
|
||||||
|
dpoint_entity *out;
|
||||||
|
|
||||||
|
success = false;
|
||||||
|
for (dpoint_entity &item : this->_dpoints) {
|
||||||
|
if (item.id() == oid) {
|
||||||
|
success = true;
|
||||||
|
out = &item;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return *out;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool object_system::remove_dpoint(entity_id oid) {
|
||||||
|
auto vit = this->_dpoints.begin();
|
||||||
|
for (; vit != this->_dpoints.end(); vit++) {
|
||||||
|
if ((*vit).id() == oid) {
|
||||||
|
this->_dpoints.erase(vit);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool object_system::add_dpoint(dpoint_entity dpoint) {
|
||||||
|
bool exists = false;
|
||||||
|
this->get_dpoint(dpoint.id(), exists);
|
||||||
|
if (!exists) {
|
||||||
|
this->_dpoints.push_back(dpoint);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const vessel_entity& object_system::get_vessel(entity_id oid, bool &success) {
|
||||||
|
vessel_entity *out;
|
||||||
|
|
||||||
|
success = false;
|
||||||
|
for (vessel_entity &item : this->_vessels) {
|
||||||
|
if (item.id() == oid) {
|
||||||
|
success = true;
|
||||||
|
out = &item;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return *out;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool object_system::remove_vessel(entity_id oid) {
|
||||||
|
auto vit = this->_vessels.begin();
|
||||||
|
for (; vit != this->_vessels.end(); vit++) {
|
||||||
|
if ((*vit).id() == oid) {
|
||||||
|
this->_vessels.erase(vit);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool object_system::add_vessel(vessel_entity dpoint) {
|
||||||
|
bool exists = false;
|
||||||
|
this->get_dpoint(dpoint.id(), exists);
|
||||||
|
if (!exists) {
|
||||||
|
this->_vessels.push_back(dpoint);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void object_system::init(QDataStream &stream) {
|
void object_system::init(QDataStream &stream) {
|
||||||
int dicnt;
|
int dicnt;
|
||||||
|
|
|
||||||
|
|
@ -18,11 +18,11 @@ public:
|
||||||
|
|
||||||
const dpoint_entity& get_dpoint(entity_id oid, bool &success);
|
const dpoint_entity& get_dpoint(entity_id oid, bool &success);
|
||||||
bool remove_dpoint(entity_id oid);
|
bool remove_dpoint(entity_id oid);
|
||||||
bool add_dpoint(const dpoint_entity &dpoint);
|
bool add_dpoint(dpoint_entity dpoint);
|
||||||
|
|
||||||
const vessel_entity& get_vessel(entity_id oid, bool &success);
|
const vessel_entity& get_vessel(entity_id oid, bool &success);
|
||||||
bool remove_vessel(entity_id oid);
|
bool remove_vessel(entity_id oid);
|
||||||
bool add_vessel(const vessel_entity &dpoint);
|
bool add_vessel(vessel_entity dpoint);
|
||||||
|
|
||||||
|
|
||||||
void init(QDataStream &stream);
|
void init(QDataStream &stream);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue