[nostalgia/world] Update models

This commit is contained in:
Gary Talent 2022-02-13 13:39:10 -06:00
parent 18f02ae25e
commit 71f70cb2e6

View File

@ -13,32 +13,26 @@
namespace nostalgia::world { namespace nostalgia::world {
struct Tile { struct Tile {
static constexpr auto Fields = 2; static constexpr auto TypeName = "net.drinkingtea.nostalgia.world.Tile";
static constexpr auto TypeVersion = 1;
uint8_t bgTile = 0; uint8_t bgTile = 0;
uint8_t type = 0; uint8_t type = 0;
}; };
template<typename T> oxModelBegin(Tile)
ox::Error modelRead(T *io, Tile *obj) { oxModelField(bgTile)
auto err = OxError(0); oxModelField(type)
io->setTypeInfo("nostalgia::world::Tile", Tile::Fields); oxModelEnd()
err |= io->field("bgTile", &obj->bgTile);
err |= io->field("type", &obj->type);
return err;
}
struct Zone { struct Zone {
static constexpr auto TypeName = "net.drinkingtea.nostalgia.world.Zone";
static constexpr auto TypeVersion = 2;
template<typename T> oxModelFriend(Zone);
friend ox::Error modelRead(T*, Zone*);
template<typename T>
friend ox::Error modelWrite(T*, Zone*);
protected: protected:
static constexpr auto Fields = 2;
geo::Bounds m_bounds; geo::Bounds m_bounds;
Tile *m_tiles = nullptr; Tile *m_tiles = nullptr;
@ -59,51 +53,24 @@ struct Zone {
}; };
template<typename T> oxModelBegin(Zone)
ox::Error modelRead(T *io, Zone *obj) { oxModelFieldRename(bounds, m_bounds)
auto err = OxError(0); oxModelEnd()
io->setTypeInfo("net.drinkingtea.nostalgia.world.Zone", Zone::Fields);
err |= io->field("bounds", &obj->m_bounds);
return err;
}
template<typename T>
ox::Error modelWrite(T *io, Zone *obj) {
auto err = OxError(0);
io->setTypeInfo("net.drinkingtea.nostalgia.world.Zone", Zone::Fields);
err |= io->field("bounds", &obj->m_bounds);
return err;
}
struct Region { struct Region {
static constexpr auto TypeName = "net.drinkingtea.nostalgia.world.Region";
static constexpr auto TypeVersion = 1;
template<typename T> oxModelFriend(Region);
friend ox::Error modelRead(T*, Region*);
template<typename T>
friend ox::Error modelWrite(T*, Region*);
protected: protected:
static constexpr auto Fields = 1;
ox::Vector<Zone*> m_zones; ox::Vector<Zone*> m_zones;
public:
}; };
template<typename T> oxModelBegin(Region)
ox::Error modelRead(T *io, Region*) { oxModelFieldRename(zones, m_zones)
auto err = OxError(0); oxModelEnd()
io->setTypeInfo("net.drinkingtea.nostalgia.world.Region", Region::Fields);
return err;
}
template<typename T>
ox::Error modelWrite(T *io, Region*) {
auto err = OxError(0);
io->setTypeInfo("net.drinkingtea.nostalgia.world.Region", Region::Fields);
return err;
}
} }