inventory reindexing
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
#include "Player.h"
|
||||
#include "../content/ContentLUT.h"
|
||||
#include "../physics/Hitbox.h"
|
||||
#include "../physics/PhysicsSolver.h"
|
||||
#include "../voxels/Chunks.h"
|
||||
@@ -167,3 +168,34 @@ void Player::setSpawnPoint(glm::vec3 spawnpoint) {
|
||||
glm::vec3 Player::getSpawnPoint() const {
|
||||
return spawnpoint;
|
||||
}
|
||||
|
||||
std::unique_ptr<dynamic::Map> Player::write() const {
|
||||
glm::vec3 position = hitbox->position;
|
||||
auto root = std::make_unique<dynamic::Map>();
|
||||
auto& posarr = root->putList("position");
|
||||
posarr.put(position.x);
|
||||
posarr.put(position.y);
|
||||
posarr.put(position.z);
|
||||
|
||||
auto& rotarr = root->putList("rotation");
|
||||
rotarr.put(cam.x);
|
||||
rotarr.put(cam.y);
|
||||
|
||||
auto& sparr = root->putList("spawnpoint");
|
||||
sparr.put(spawnpoint.x);
|
||||
sparr.put(spawnpoint.y);
|
||||
sparr.put(spawnpoint.z);
|
||||
|
||||
root->put("flight", flight);
|
||||
root->put("noclip", noclip);
|
||||
root->put("chosen-slot", chosenSlot);
|
||||
root->put("inventory", inventory->write().release());
|
||||
return root;
|
||||
}
|
||||
|
||||
void Player::convert(dynamic::Map* data, const ContentLUT* lut) {
|
||||
auto inventory = data->map("inventory");
|
||||
if (inventory) {
|
||||
Inventory::convert(inventory, lut);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,12 +4,14 @@
|
||||
#include <memory>
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
#include "../data/dynamic.h"
|
||||
#include "../voxels/voxel.h"
|
||||
#include "../settings.h"
|
||||
|
||||
class Camera;
|
||||
class Hitbox;
|
||||
class Inventory;
|
||||
class ContentLUT;
|
||||
class PhysicsSolver;
|
||||
class Chunks;
|
||||
class Level;
|
||||
@@ -62,6 +64,10 @@ public:
|
||||
|
||||
void setSpawnPoint(glm::vec3 point);
|
||||
glm::vec3 getSpawnPoint() const;
|
||||
|
||||
std::unique_ptr<dynamic::Map> write() const;
|
||||
|
||||
static void convert(dynamic::Map* data, const ContentLUT* lut);
|
||||
};
|
||||
|
||||
#endif /* SRC_OBJECTS_PLAYER_H_ */
|
||||
|
||||
Reference in New Issue
Block a user