feat: saving current camera
This commit is contained in:
parent
c9257ec127
commit
d1696eea12
@ -11,6 +11,7 @@
|
|||||||
#include "../objects/Entities.hpp"
|
#include "../objects/Entities.hpp"
|
||||||
#include "../objects/rigging.hpp"
|
#include "../objects/rigging.hpp"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <glm/glm.hpp>
|
#include <glm/glm.hpp>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
@ -267,6 +268,11 @@ std::unique_ptr<dynamic::Map> Player::serialize() const {
|
|||||||
root->put("chosen-slot", chosenSlot);
|
root->put("chosen-slot", chosenSlot);
|
||||||
root->put("entity", eid);
|
root->put("entity", eid);
|
||||||
root->put("inventory", inventory->serialize());
|
root->put("inventory", inventory->serialize());
|
||||||
|
auto found = std::find(level->cameras.begin(), level->cameras.end(), currentCamera);
|
||||||
|
if (found != level->cameras.end()) {
|
||||||
|
root->put("camera", level->content->getIndices(
|
||||||
|
ResourceType::CAMERA).getName(found - level->cameras.begin()));
|
||||||
|
}
|
||||||
return root;
|
return root;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -303,6 +309,14 @@ void Player::deserialize(dynamic::Map *src) {
|
|||||||
if (auto invmap = src->map("inventory")) {
|
if (auto invmap = src->map("inventory")) {
|
||||||
getInventory()->deserialize(invmap.get());
|
getInventory()->deserialize(invmap.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (src->has("camera")) {
|
||||||
|
std::string name;
|
||||||
|
src->str("camera", name);
|
||||||
|
if (auto camera = level->getCamera(name)) {
|
||||||
|
currentCamera = camera;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::convert(dynamic::Map* data, const ContentLUT* lut) {
|
void Player::convert(dynamic::Map* data, const ContentLUT* lut) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user