From 95dd550fdbef946259b8943645abbf8b935045c4 Mon Sep 17 00:00:00 2001 From: Jonathan Bourdon Date: Fri, 13 Mar 2026 02:03:59 -0400 Subject: [PATCH] Fix miner undock state transition --- SESSION.md | 111 ++++++++++++++++++-- apps/backend/Simulation/SimulationEngine.cs | 9 +- 2 files changed, 111 insertions(+), 9 deletions(-) diff --git a/SESSION.md b/SESSION.md index d26043c..61cfa39 100644 --- a/SESSION.md +++ b/SESSION.md @@ -13,6 +13,12 @@ The repository is now split into two apps that live side-by-side: The complete simulation runs in the backend. The viewer fetches one world snapshot, then subscribes to an SSE delta stream and renders the world as an observer. +The world model is now hierarchical: + +- systems live in galaxy space +- ships, stations, and resource nodes live in system-local space +- the viewer applies a local presentation layer for the active system + ## Runtime / Networking The backend currently provides: @@ -28,6 +34,7 @@ The viewer currently does: 2. connect to the stream 3. apply deltas into a local render model 4. interpolate and briefly extrapolate moving ships for presentation +5. compose galaxy-space systems with system-local entities for rendering This supports multiple simultaneous observers on the same world. Interest management is not implemented yet, so every observer still receives full-world deltas. @@ -44,29 +51,57 @@ The viewer currently supports: - `WASD` panning on the `XZ` plane - middle-mouse orbit camera - smooth wheel zoom across local, system, and universe scales -- presentation fades between zoom bands instead of hard switches +- layered system presentation + - one active local system with detailed content + - non-local systems projected as distant shell markers - procedurally animated planets and moons from orbital metadata - ringed planets, binary star presentation, and richer resource visuals +- follow-camera behavior for selected ships +- dedicated `System` and `Focus` panels on the right HUD +- hover labels for projected system markers +- a bottom ship list with horizontally scrolling ship cards + - card click selects and follows the ship + - cards show ship name, class, fuel, energy, state, and order +- multiple floating history windows for debugging + - openable from ship cards + - independently movable and resizable + - copy-to-clipboard support with a DOM fallback path -Universe-level presentation is now star-centric: +Local presentation is now intentionally isolated: -- solar-system internals fade out as the camera pulls back -- star names remain readable -- system summary panels show icon-plus-count rollups only when entities are present +- only the active system renders local detail + - ships + - stations + - resource nodes + - planets + - moons +- other systems render as distant stars plus compact summary presentation +- projected systems can show shell reticles and hover labels +- distant galaxy motion now has only minimal parallax while moving inside a system The viewer also includes plain-text HUD readouts for: - game state - network statistics +- ship debugging history in separate floating windows The viewer now consumes richer celestial metadata from the backend: - star kind and star count - planet type, shape, moon count, and orbital elements - resource node source kind such as `asteroid-belt` and `gas-cloud` +- galaxy-space system positions +- system-local entity positions and velocities Planets and moons are not simulated as networked entities. Their positions are reconstructed client-side from snapshot time plus orbital configuration. +Viewer-side orbital presentation now also applies to: + +- resource nodes +- stations + +These orbitals prefer nearby planets or moons as anchors, with fallback to the system star. + ## Simulation Status The backend simulation already includes: @@ -75,6 +110,13 @@ The backend simulation already includes: - orbital travel - docking and undocking - mining and refinery delivery +- module-gated ship and station capabilities + - ships require fitted modules such as reactor, capacitor, and mining or gun turrets + - stations require fitted modules such as power, refinery, and storage modules +- fuel-to-energy power simulation + - ship reactors consume `gas` fuel to charge capacitors + - station power cores consume `gas` fuel to charge station energy buffers + - powered actions stop when fuel and energy are depleted - refining / fabrication - faction growth through ship and outpost production - pirate pressure and combat @@ -83,6 +125,11 @@ The backend simulation already includes: - resource geography beyond simple ore nodes - asteroid belts for ore - gas clouds for gas +- hierarchical coordinates for replication + - systems in galaxy space + - in-system entities in local space +- item-based inventories for ships and stations + - ore, refined metals, gas fuel, and cargo now flow through per-item inventories instead of ad hoc stock fields The runtime model still follows the intended layered control architecture: @@ -106,6 +153,29 @@ The runtime model still follows the intended layered control architecture: - added moon rendering in the viewer - added backend-generated asteroid belts and gas clouds as resource sources - injected the `Sol` system into the generated galaxy +- refactored contracts from flat world coordinates to galaxy-space systems plus system-local entities +- normalized authored scenario placements and patrol routes into system-local coordinates during load +- added viewer-side local-focus / floating-origin style presentation for the active system +- reworked local-vs-remote rendering so only one system shows detail at a time +- added projected shell markers and hover labels for distant systems while inside a local system +- added viewer-side orbital motion for stations and resource nodes +- tuned local movement so the rest of the galaxy remains mostly fixed during in-system travel +- reduced the starting faction to a minimal bootstrap + - one modular station + - one constructor ship + - one mining ship +- moved the starting ships close to the `helios` star and next to each other +- added modular ship and station data + - new station power and storage modules + - new ship reactor, capacitor, mining turret, and gun turret modules +- refactored simulation inventories to per-item storage + - stations and ships now replicate inventories instead of specialized ore/refined/cargo counters +- added fuel-driven power generation and energy consumption in the simulation loop +- replaced the viewer bottom faction strip with a horizontal ship-card debugging rail +- added movable, resizable, multi-window history panels in the viewer +- fixed the auto-miner undock controller transition + - ships now keep their docked station link until the undock move actually completes + - this prevents auto-miners from falling into `idle` immediately after unloading ## Current Known Limitations @@ -113,10 +183,16 @@ The runtime model still follows the intended layered control architecture: - no observer-scoped interest management yet - the viewer is still observer-focused - no command submission UI yet -- system/universe transitions are improved but still need tuning in feel and art direction +- local / projected / galaxy presentation is now workable but still needs tuning + - shell marker art direction and scaling still need polish + - local camera feel still needs iteration + - projected-system composition is still a viewer illusion, not a full multi-layer renderer - the galaxy is much larger now, so viewer performance and visual density need active tuning - moon rendering is procedural from counts, not authored moon-by-moon data - resource extraction behavior still treats all resource nodes generically +- item inventories exist, but storage enforcement and module-slot restrictions are still lightweight + - cargo/storage compatibility is mostly data-convention driven + - hull-specific module restrictions are not enforced yet - piracy and faction growth are still functional rather than strategically deep - no persistence for saves, seeds, or reconnect state @@ -128,18 +204,35 @@ The runtime model still follows the intended layered control architecture: - authoritative world state and stream coordination - [apps/backend/Simulation/SimulationEngine.cs](/home/jbourdon/repos/space-game/apps/backend/Simulation/SimulationEngine.cs) - simulation advancement + - snapshot / delta composition for galaxy-space systems and local-space entities + - inventory, fuel, and energy processing + - auto-miner undock state transition fix - [apps/backend/Simulation/ScenarioLoader.cs](/home/jbourdon/repos/space-game/apps/backend/Simulation/ScenarioLoader.cs) - faction bootstrap - galaxy generation - special systems - procedural celestial/resource content + - normalization of authored placements into system-local space + - minimal startup seeding for ships, station, and fuel +- [apps/backend/Contracts/WorldContracts.cs](/home/jbourdon/repos/space-game/apps/backend/Contracts/WorldContracts.cs) + - snapshot and delta contract shape +- [apps/backend/Simulation/RuntimeModels.cs](/home/jbourdon/repos/space-game/apps/backend/Simulation/RuntimeModels.cs) + - runtime vector math and world model + - per-item inventories on ships and stations - [apps/viewer/src/GameViewer.ts](/home/jbourdon/repos/space-game/apps/viewer/src/GameViewer.ts) - camera, selection, streaming integration, and presentation + - layered local/remote system presentation - orbital reconstruction and moon rendering + - projected shell markers and hover labels + - ship card list and multi-window history debugging UI +- [apps/viewer/src/style.css](/home/jbourdon/repos/space-game/apps/viewer/src/style.css) + - HUD layout + - ship-card rail + - floating history window styling - [apps/viewer/src/api.ts](/home/jbourdon/repos/space-game/apps/viewer/src/api.ts) - snapshot fetch and SSE stream integration - [apps/viewer/src/contracts.ts](/home/jbourdon/repos/space-game/apps/viewer/src/contracts.ts) - - viewer-side snapshot contract for celestial metadata + - viewer-side snapshot contract for galaxy-space systems and local-space entities - [shared/data](/home/jbourdon/repos/space-game/shared/data) - scenario and world data definitions @@ -149,3 +242,7 @@ Validation passing at the end of this session: - `dotnet build apps/backend/SpaceGame.Simulation.Api.csproj` - `cd apps/viewer && npm run build` + +## Last Commit + +- `1747d84` diff --git a/apps/backend/Simulation/SimulationEngine.cs b/apps/backend/Simulation/SimulationEngine.cs index c821a77..812a415 100644 --- a/apps/backend/Simulation/SimulationEngine.cs +++ b/apps/backend/Simulation/SimulationEngine.cs @@ -960,10 +960,15 @@ public sealed class SimulationEngine } station?.DockedShipIds.Remove(ship.Id); - ship.DockedStationId = null; ship.State = "undocking"; ship.Position = ship.Position.MoveToward(task.TargetPosition.Value, ship.Definition.Speed * deltaSeconds); - return ship.Position.DistanceTo(task.TargetPosition.Value) <= task.Threshold ? "undocked" : "none"; + if (ship.Position.DistanceTo(task.TargetPosition.Value) > task.Threshold) + { + return "none"; + } + + ship.DockedStationId = null; + return "undocked"; } private void AdvanceControlState(ShipRuntime ship, string controllerEvent)