71 lines
2.3 KiB
C++
71 lines
2.3 KiB
C++
#pragma once
|
|
#include "external/nlohmann/json.hpp"
|
|
#include "ISaveable.h"
|
|
#include "NpcCar.h"
|
|
#include "navigation/PathFinder.h"
|
|
#include <memory>
|
|
#include <string>
|
|
#include <unordered_map>
|
|
|
|
namespace FRG {
|
|
|
|
inline constexpr int kSinglePlayerPersistenceVersion = 1;
|
|
|
|
struct LocationLocalState : public ISaveable {
|
|
float cameraAzimuth = -2.35f;
|
|
float cameraInclination = 1.1036f;
|
|
|
|
void save(nlohmann::json& out) const override;
|
|
void load(const nlohmann::json& in) override;
|
|
};
|
|
|
|
struct ClientLocationState : public ISaveable {
|
|
std::unordered_map<std::string, std::shared_ptr<LocationLocalState>> locations;
|
|
|
|
std::shared_ptr<LocationLocalState> getOrCreate(const std::string& locationId);
|
|
void clear();
|
|
void save(nlohmann::json& out) const override;
|
|
void load(const nlohmann::json& in) override;
|
|
};
|
|
|
|
void saveSinglePlayerPersistence(
|
|
const nlohmann::json& networkState,
|
|
const ClientLocationState& localState,
|
|
nlohmann::json& out);
|
|
void loadSinglePlayerPersistence(
|
|
const nlohmann::json& in,
|
|
nlohmann::json& networkState,
|
|
ClientLocationState& localState);
|
|
|
|
struct LocationNetworkState : public ISaveable {
|
|
//This value is populated from the JSON configs and should not be changed during the regular gameplay.
|
|
//It might be changed only in the editor mode during development.
|
|
std::vector<PathFinder> navigationMaps;
|
|
std::vector<Eigen::Vector3f> planPathExceptMyself(const Eigen::Vector3f& start, const Eigen::Vector3f& end, const std::string& entityId) const;
|
|
void initNavigation(
|
|
const std::vector<std::string>& paths,
|
|
const std::string& zipFile = std::string());
|
|
|
|
// ---- Navigation ----
|
|
int activeNavigationIndex = 0;
|
|
|
|
// ---- Walk-to targets (empty = none) ----
|
|
std::string targetInteractiveObjectId;
|
|
std::string targetInteractNpcId;
|
|
std::string targetTeleportZoneId;
|
|
|
|
NpcCar taxiCarInitialState;
|
|
NpcCar taxiCar;
|
|
bool taxiArrivedCallbackCalled = false;
|
|
Eigen::Vector3f taxiCarTriggerPosition = Eigen::Vector3f(0,0,0);
|
|
std::vector<Eigen::Vector3f> taxiCarWaypoints;
|
|
|
|
// (trigger/teleport zone runtime flags are serialised by id directly in Location::save/load)
|
|
|
|
// ---- Serialisation ----
|
|
void save(nlohmann::json& out) const override;
|
|
void load(const nlohmann::json& in) override;
|
|
};
|
|
|
|
} // namespace FRG
|