| 51 | } |
| 52 | |
| 53 | Maybe<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 | |
| 81 | SkyParameters SystemWorldServer::clientSkyParameters(ConnectionId clientId) const { |
| 82 | auto uuid = m_clientShips.get(clientId); |
no test coverage detected