What "station" means in this codebase
Station work spans four areas:
- Docking mechanics — when docking is allowed (distance/speed), nearest-station checks.
- Station generation/placement — which planets get stations and how a "main station" is chosen.
- Station rendering — station mesh and in-system orbit behavior.
- Station interaction flow — flight -> landing event -> docked station UI -> undock.
Files to read/modify
Docking mechanics
src/game/constants.ts — docking thresholds:
DOCKING.maxDistanceDOCKING.maxSpeed
src/game/mechanics/DockingSystem.ts — core docking checks:
canDock()— distance and speed gatefindNearestStation()— picks nearest station and avoids docking when scenery is closer
src/game/Game.ts — docking flow:
tryDock()— validates nearest station and docking constraints- Alert behavior for failed docking attempts
Station generation and placement (Rust engine)
engine/src/system_generator.rs — station placement rules:
has_stationassignment on generated planetsmain_station_planet_idselection- Edit here to change station frequency/distribution
engine/src/types/world.rs — station-related data fields:
PlanetData.has_stationSolarSystemData.main_station_planet_id
Station rendering and in-system behavior
src/game/rendering/mesh/entities.ts (exported through src/game/rendering/meshFactory.ts) — makeStation() mesh geometry
src/game/rendering/scene/buildPlanets.ts and src/game/rendering/scene/orbitAndNpcUpdates.ts — station entities:
- Spawns station objects for planets with
hasStation - Sets station orbit radius/speed relative to parent planet
- Tags entities as
type: 'station'for docking systems
Station interaction UI flow
src/ui/LandingDialog/LandingDialog.tsx — pre-docked landing event UI and choice flow
src/ui/StationUI/StationUI.tsx — docked station screen (market and station actions)
src/ui/App.tsx — UI mode transitions and onUndock wiring
src/game/GameState.ts — UI modes ('flight', 'landing', 'docked')
Typical workflows
Change docking radius/speed rules:
src/game/constants.ts(DOCKING)src/game/mechanics/DockingSystem.ts(if logic beyond thresholds is needed)src/game/Game.ts(optional: failure messaging)
Change how stations are distributed across planets/systems:
engine/src/system_generator.rsengine/src/types/world.rs(only if adding/changing station-related data shape)- Rebuild WASM:
npm run wasm:build(orcd engine && wasm-pack build --target web --out-dir pkg)
Change station look/shape:
src/game/rendering/mesh/entities.ts(makeStation)src/game/rendering/scene/buildPlanets.tsorsrc/game/rendering/scene/orbitAndNpcUpdates.ts(optional: orbit/scale/spawn behavior)
Change station interaction flow (dock -> landing -> docked -> undock):
src/game/Game.ts(flow control)src/ui/LandingDialog/LandingDialog.tsxsrc/ui/StationUI/StationUI.tsxsrc/ui/App.tsxand/orsrc/game/GameState.ts(mode plumbing)
Boundaries with other skills
- Use
modify-tradingfor market prices, goods, station economy behavior, and trade UI specifics. - Use
modify-eventsfor landing event narrative content, choices, and event selection logic. - Use
modify-shipsfor ship physics/handling not specific to station docking rules.
Source: charkitch/time-in-transit — distributed by TomeVault.