Add de/serialization to object subsystem
This commit is contained in:
parent
44ccc07360
commit
f20bb7c2d9
2 changed files with 50 additions and 3 deletions
|
|
@ -1,6 +1,32 @@
|
|||
#include "object_system.h"
|
||||
|
||||
object_system::object_system()
|
||||
{
|
||||
|
||||
|
||||
|
||||
void object_system::init(QDataStream &stream) {
|
||||
int dicnt;
|
||||
stream >> dicnt;
|
||||
this->_dpoints.resize(dicnt);
|
||||
for (int i = 0; i < dicnt; i++) {
|
||||
this->_dpoints[i].deserialize(stream);
|
||||
}
|
||||
|
||||
int vicnt;
|
||||
stream >> vicnt;
|
||||
this->_vessels.resize(vicnt);
|
||||
for (int i = 0; i < vicnt; i++) {
|
||||
this->_vessels[i].deserialize(stream);
|
||||
}
|
||||
}
|
||||
|
||||
void object_system::shutdown(QDataStream &stream) {
|
||||
stream << this->_dpoints.size();
|
||||
for (auto &item : this->_dpoints) {
|
||||
item.serialize(stream);
|
||||
}
|
||||
|
||||
stream << this->_vessels.size();
|
||||
for (auto &item : this->_vessels) {
|
||||
item.serialize(stream);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,32 @@
|
|||
#ifndef OBJECT_SYSTEM_H
|
||||
#define OBJECT_SYSTEM_H
|
||||
|
||||
#include <QVector>
|
||||
|
||||
#include <entities/dpoint_entity.h>
|
||||
#include <entities/vessel_entity.h>
|
||||
|
||||
|
||||
class object_system
|
||||
{
|
||||
private:
|
||||
QVector<dpoint_entity> _dpoints;
|
||||
QVector<vessel_entity> _vessels;
|
||||
|
||||
public:
|
||||
object_system();
|
||||
object_system() = default;
|
||||
|
||||
const dpoint_entity& get_dpoint(entity_id oid, bool &success);
|
||||
bool remove_dpoint(entity_id oid);
|
||||
bool add_dpoint(const dpoint_entity &dpoint);
|
||||
|
||||
const vessel_entity& get_vessel(entity_id oid, bool &success);
|
||||
bool remove_vessel(entity_id oid);
|
||||
bool add_vessel(const vessel_entity &dpoint);
|
||||
|
||||
|
||||
void init(QDataStream &stream);
|
||||
void shutdown(QDataStream &stream);
|
||||
};
|
||||
|
||||
#endif // OBJECT_SYSTEM_H
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue