Something went wrong. Try again.
Starship Simulator Controls thoriumsim.com
Something went wrong. Try again.
1.8 kB · 52 lines
TypeScript
at develop
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253import type StationComplementPlugin from "@thorium/.server/classes/Plugins/StationComplement";import { t } from "@thorium/.server/init/t";import { staticStations } from "@thorium/routes/flight/staticStations";import z from "zod";export const station = t.router({ get: t.procedure .input(z.object({ clientId: z.string() })) .filter((publish: { clientId: string }, { input }) => { if (publish && publish.clientId !== input.clientId) return false; return true; }) .autoPublish(["flightClient"], (entity) => { if (entity.components.flightClient) { return { clientId: entity.components.flightClient.clientId }; } }) .request(({ ctx, input }) => { const flightClient = ctx.getFlightClient(input.clientId)?.components.flightClient; const ship = ctx.getPlayerShip(input.clientId); if (flightClient?.stationOverride) return flightClient.stationOverride; const stations = [...(ship?.components.stationComplement?.stations || [])]; for (const staticStation of staticStations) { stations.push({ cards: staticStation.cards, description: "", logo: "", messageGroups: [], name: staticStation.name, tags: [], theme: "", widgets: [], }); } const station = stations.find((s) => s.name === flightClient?.stationId)!; return station; }), available: t.procedure .autoPublish([], () => null) .request(({ ctx }) => { return ctx.server.plugins .reduce((stations: StationComplementPlugin[], plugin) => { if (!plugin.active) return stations; return stations.concat(plugin.aspects.stationComplements); }, []) .map((station) => ({ name: station.name, pluginName: station.pluginName, stationCount: station.stationCount, hasShipMap: station.hasShipMap, })); }),});