Refactor runtime bootstrap and ship control flows
This commit is contained in:
@@ -7,13 +7,14 @@ import type {
|
||||
WorldState,
|
||||
} from "./viewerTypes";
|
||||
import { formatGalaxyDistance } from "./viewerMath";
|
||||
import { getShipBehaviorLabel, getShipOrderLabel } from "./shipAutomationPresentation";
|
||||
|
||||
export function describeSelectable(world: WorldState | undefined, item: Selectable): string {
|
||||
if (!world) {
|
||||
return item.kind;
|
||||
}
|
||||
if (item.kind === "ship") {
|
||||
return world.ships.get(item.id)?.label ?? item.id;
|
||||
return world.ships.get(item.id)?.name ?? item.id;
|
||||
}
|
||||
if (item.kind === "station") {
|
||||
return world.stations.get(item.id)?.label ?? item.id;
|
||||
@@ -52,7 +53,7 @@ export function describeHoverLabel(world: WorldState | undefined, item: Selectab
|
||||
}
|
||||
|
||||
const lines = [
|
||||
ship.label,
|
||||
ship.name,
|
||||
`Behavior ${describeShipBehavior(ship)}`,
|
||||
`State ${describeShipState(world, ship)}`,
|
||||
`Order ${describeShipOrder(ship)}`,
|
||||
@@ -303,7 +304,7 @@ export function renderSystemDetails(
|
||||
}
|
||||
|
||||
const followText = activeContext && cameraMode === "follow" && cameraTargetShipId
|
||||
? `<p>Camera locked to ${world.ships.get(cameraTargetShipId)?.label ?? cameraTargetShipId}</p>`
|
||||
? `<p>Camera locked to ${world.ships.get(cameraTargetShipId)?.name ?? cameraTargetShipId}</p>`
|
||||
: "";
|
||||
|
||||
return `
|
||||
@@ -353,7 +354,7 @@ export function describeShipObjective(objective: string): string {
|
||||
}
|
||||
|
||||
export function describeShipBehavior(ship: ShipSnapshot): string {
|
||||
const parts = [ship.defaultBehavior.kind];
|
||||
const parts = [getShipBehaviorLabel(ship.defaultBehavior.kind)];
|
||||
if (ship.assignment?.kind) {
|
||||
parts.push(ship.assignment.kind);
|
||||
}
|
||||
@@ -364,7 +365,7 @@ export function describeShipOrder(ship: ShipSnapshot): string {
|
||||
const activeOrder = [...ship.orderQueue]
|
||||
.sort((left, right) => right.priority - left.priority || left.createdAtUtc.localeCompare(right.createdAtUtc))[0];
|
||||
if (activeOrder) {
|
||||
return activeOrder.label ?? activeOrder.kind;
|
||||
return activeOrder.label ?? getShipOrderLabel(activeOrder.kind);
|
||||
}
|
||||
|
||||
if (ship.assignment?.kind) {
|
||||
@@ -375,7 +376,7 @@ export function describeShipOrder(ship: ShipSnapshot): string {
|
||||
return ship.activePlan.summary || ship.activePlan.kind;
|
||||
}
|
||||
|
||||
return ship.defaultBehavior.kind;
|
||||
return getShipBehaviorLabel(ship.defaultBehavior.kind);
|
||||
}
|
||||
|
||||
export function describeShipCurrentAction(ship: ShipSnapshot): { label: string; progress: number } | undefined {
|
||||
|
||||
Reference in New Issue
Block a user