#pragma once #include "StarJson.hpp" #include "StarWarping.hpp" #include "StarCelestialCoordinate.hpp" #include "StarSystemWorld.hpp" namespace Star { STAR_CLASS(PlayerUniverseMap); template Json jsonFromBookmarkTarget(T const& target); template T jsonToBookmarkTarget(Json const& json); // Bookmark requires T to implement jsonToBookmarkTarget and jsonFromBookmarkTarget // also operator== and operator!= template struct Bookmark { T target; String targetName; String bookmarkName; String icon; static Bookmark fromJson(Json const& json); Json toJson() const; bool operator==(Bookmark const& rhs) const; bool operator!=(Bookmark const& rhs) const; bool operator<(Bookmark const& rhs) const; }; typedef Variant OrbitTarget; typedef pair TeleportTarget; typedef Bookmark OrbitBookmark; typedef Bookmark TeleportBookmark; class PlayerUniverseMap { public: struct MappedObject { String typeName; Maybe orbit; JsonObject parameters; }; PlayerUniverseMap(Json const& json = {}); Json toJson() const; // pair of system location and bookmark, not all orbit bookmarks include the system List> orbitBookmarks() const; bool addOrbitBookmark(CelestialCoordinate const& system, OrbitBookmark const& bookmark); bool removeOrbitBookmark(CelestialCoordinate const& system, OrbitBookmark const& bookmark); List teleportBookmarks() const; bool addTeleportBookmark(TeleportBookmark bookmark); bool removeTeleportBookmark(TeleportBookmark const& bookmark); void invalidateWarpAction(WarpAction const& bookmark); Maybe worldBookmark(CelestialCoordinate const& world) const; List systemBookmarks(CelestialCoordinate const& system) const; List planetBookmarks(CelestialCoordinate const& planet) const; bool isMapped(CelestialCoordinate const& coordinate); HashMap mappedObjects(CelestialCoordinate const& system); void addMappedCoordinate(CelestialCoordinate const& coordinate); void addMappedObject(CelestialCoordinate const& system, Uuid const& uuid, String const& typeName, Maybe const& orbit = {}, JsonObject parameters = {}); void removeMappedObject(CelestialCoordinate const& system, Uuid const& uuid); void filterMappedObjects(CelestialCoordinate const& system, List const& allowed); void setServerUuid(Maybe serverUuid); private: struct SystemMap { Set mappedPlanets; HashMap mappedObjects; Set bookmarks; static SystemMap fromJson(Json const& json); Json toJson() const; }; struct UniverseMap { HashMap systems; Set teleportBookmarks; static UniverseMap fromJson(Json const& json); Json toJson() const; }; UniverseMap const& universeMap() const; UniverseMap& universeMap(); Maybe m_serverUuid; HashMap m_universeMaps; }; template bool Bookmark::operator==(Bookmark const& rhs) const { return target == rhs.target; } template bool Bookmark::operator!=(Bookmark const& rhs) const { return target != rhs.target; } template bool Bookmark::operator<(Bookmark const& rhs) const { return target < rhs.target; } }