osb/source/game/StarClientContext.hpp

68 lines
1.7 KiB
C++
Raw Normal View History

#pragma once
2023-06-20 04:33:09 +00:00
#include "StarNetElementSystem.hpp"
#include "StarJsonRpc.hpp"
#include "StarGameTypes.hpp"
#include "StarDamageTypes.hpp"
#include "StarCelestialCoordinate.hpp"
#include "StarWarping.hpp"
#include "StarWorldStorage.hpp"
#include "StarPlayerTypes.hpp"
namespace Star {
STAR_CLASS(CelestialLog);
STAR_CLASS(ClientContext);
class ClientContext {
public:
2023-07-22 12:31:04 +00:00
ClientContext(Uuid serverUuid, Uuid playerUuid);
2023-06-20 04:33:09 +00:00
Uuid serverUuid() const;
2023-07-22 12:31:04 +00:00
// The player Uuid can differ from the mainPlayer's Uuid
// if the player has swapped character - use this for ship saving.
Uuid playerUuid() const;
2023-06-20 04:33:09 +00:00
// The coordinate for the world which the player's ship is currently
// orbiting.
CelestialCoordinate shipCoordinate() const;
Maybe<pair<WarpAction, WarpMode>> orbitWarpAction() const;
// The current world id of the player
WorldId playerWorldId() const;
bool isAdmin() const;
EntityDamageTeam team() const;
JsonRpcInterfacePtr rpcInterface() const;
WorldChunks newShipUpdates();
ShipUpgrades shipUpgrades() const;
void readUpdate(ByteArray data);
ByteArray writeUpdate();
void setConnectionId(ConnectionId connectionId);
ConnectionId connectionId() const;
2023-06-20 04:33:09 +00:00
private:
Uuid m_serverUuid;
2023-07-22 12:31:04 +00:00
Uuid m_playerUuid;
ConnectionId m_connectionId = 0;
2023-07-22 12:31:04 +00:00
2023-06-20 04:33:09 +00:00
JsonRpcPtr m_rpc;
NetElementTopGroup m_netGroup;
NetElementData<Maybe<pair<WarpAction, WarpMode>>> m_orbitWarpActionNetState;
NetElementData<WorldId> m_playerWorldIdNetState;
NetElementBool m_isAdminNetState;
NetElementData<EntityDamageTeam> m_teamNetState;
NetElementData<ShipUpgrades> m_shipUpgrades;
NetElementData<CelestialCoordinate> m_shipCoordinate;
WorldChunks m_newShipUpdates;
};
}