MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / clientWarpAction

Method clientWarpAction

source/game/StarSystemWorldServer.cpp:53–79  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

51}
52
53Maybe<pair<WarpAction, WarpMode>> SystemWorldServer::clientWarpAction(ConnectionId clientId) const {
54 auto ship = m_ships.get(m_clientShips.get(clientId));
55 if (auto objectUuid = ship->systemLocation().maybe<Uuid>()) {
56 if (auto action = objectWarpAction(*objectUuid)) {
57 return pair<WarpAction, WarpMode>(*action, WarpMode::DeployOnly);
58 }
59 } else if (auto coordinate = ship->systemLocation().maybe<CelestialCoordinate>()) {
60 WarpAction warpAction = WarpToWorld(CelestialWorldId(*coordinate));
61 return pair<WarpAction, WarpMode>(warpAction, WarpMode::BeamOrDeploy);
62 } else if (auto position = ship->systemLocation().maybe<Vec2F>()) {
63 // player can beam to asteroid fields simply by being in proximity to them
64 for (auto planet : planets()) {
65 if (abs(planetPosition(planet).magnitude() - position->magnitude()) > systemConfig().asteroidBeamDistance)
66 continue;
67
68 if (auto parameters = m_celestialDatabase->parameters(planet)) {
69 if (auto awp = as<AsteroidsWorldParameters>(parameters->visitableParameters())) {
70 float targetX = (position->angle() / (2 * Constants::pi)) * awp->worldSize[0];
71 return pair<WarpAction, WarpMode>(WarpAction(WarpToWorld(CelestialWorldId(planet), SpawnTargetX(targetX))),
72 WarpMode::DeployOnly);
73 }
74 }
75 }
76 }
77
78 return {};
79}
80
81SkyParameters SystemWorldServer::clientSkyParameters(ConnectionId clientId) const {
82 auto uuid = m_clientShips.get(clientId);

Callers 2

warpPlayersMethod · 0.45
arriveShipsMethod · 0.45

Calls 7

WarpToWorldClass · 0.85
systemLocationMethod · 0.80
visitableParametersMethod · 0.80
getMethod · 0.45
magnitudeMethod · 0.45
parametersMethod · 0.45
angleMethod · 0.45

Tested by

no test coverage detected