feat: simplifying the simulation
This commit is contained in:
@@ -3,8 +3,8 @@ import type { InventoryEntry, Vector3Dto } from "./contractsCommon";
|
||||
export interface ShipSnapshot {
|
||||
id: string;
|
||||
label: string;
|
||||
role: string;
|
||||
shipClass: string;
|
||||
kind: string;
|
||||
class: string;
|
||||
systemId: string;
|
||||
localPosition: Vector3Dto;
|
||||
localVelocity: Vector3Dto;
|
||||
@@ -19,8 +19,7 @@ export interface ShipSnapshot {
|
||||
commanderId?: string | null;
|
||||
policySetId?: string | null;
|
||||
cargoCapacity: number;
|
||||
cargoItemId?: string | null;
|
||||
workerPopulation: number;
|
||||
|
||||
travelSpeed: number;
|
||||
travelSpeedUnit: string;
|
||||
inventory: InventoryEntry[];
|
||||
|
||||
@@ -26,9 +26,7 @@ export function renderFactionStrip(
|
||||
|
||||
return ships
|
||||
.map((ship) => {
|
||||
const cargo = ship.cargoItemId
|
||||
? inventoryAmount(ship.inventory, ship.cargoItemId)
|
||||
: 0;
|
||||
const cargo = ship.inventory.reduce((sum, e) => sum + e.amount, 0);
|
||||
const shipLocation = describeShipLocation(world, ship);
|
||||
const shipState = describeShipState(world, ship);
|
||||
const shipAction = describeShipCurrentAction(ship);
|
||||
@@ -42,7 +40,7 @@ export function renderFactionStrip(
|
||||
<div class="ship-card-header">
|
||||
<h3>${ship.label}</h3>
|
||||
<div class="ship-card-meta">
|
||||
<span class="ship-card-badge">${ship.shipClass}</span>
|
||||
<span class="ship-card-badge">${ship.class}</span>
|
||||
<button
|
||||
type="button"
|
||||
class="ship-card-history-button"
|
||||
|
||||
@@ -196,10 +196,7 @@ export function updateDetailPanel(
|
||||
return;
|
||||
}
|
||||
const parent = describeSelectionParent(selected);
|
||||
const cargoUsed = ship.cargoItemId
|
||||
? inventoryAmount(ship.inventory, ship.cargoItemId)
|
||||
: 0;
|
||||
const cargoLabel = ship.cargoItemId ?? "none";
|
||||
const cargoUsed = ship.inventory.reduce((sum, e) => sum + e.amount, 0);
|
||||
const shipState = describeShipState(world, ship);
|
||||
const shipAction = describeShipCurrentAction(ship);
|
||||
detailTitleEl.textContent = ship.label;
|
||||
@@ -217,7 +214,7 @@ export function updateDetailPanel(
|
||||
</div>
|
||||
</div>
|
||||
` : ""}
|
||||
<p>Cargo ${cargoLabel} ${cargoUsed.toFixed(0)} / ${ship.cargoCapacity.toFixed(0)}</p>
|
||||
<p>Cargo ${cargoUsed.toFixed(0)} / ${ship.cargoCapacity.toFixed(0)}</p>
|
||||
<p>Inventory ${formatInventory(ship.inventory)}</p>
|
||||
<p>Speed ${formatShipSpeed(ship)}</p>
|
||||
<p>Camera ${cameraMode === "follow" && cameraTargetShipId === ship.id ? "camera-follow" : "tactical"}<br>Press C to toggle follow</p>
|
||||
|
||||
@@ -2,7 +2,7 @@ import * as THREE from "three";
|
||||
import type { ShipSnapshot } from "./contracts";
|
||||
|
||||
export function shipSize(ship: ShipSnapshot) {
|
||||
switch (ship.shipClass) {
|
||||
switch (ship.class) {
|
||||
case "capital":
|
||||
return 18;
|
||||
case "cruiser":
|
||||
@@ -20,11 +20,11 @@ export function shipLength(ship: ShipSnapshot) {
|
||||
return shipSize(ship) * 2.6;
|
||||
}
|
||||
|
||||
export function shipColor(role: ShipSnapshot["role"]) {
|
||||
if (role === "mining") {
|
||||
export function shipColor(kind: ShipSnapshot["kind"]) {
|
||||
if (kind === "mining") {
|
||||
return "#ffcf6e";
|
||||
}
|
||||
if (role === "transport") {
|
||||
if (kind === "transport") {
|
||||
return "#9ff0aa";
|
||||
}
|
||||
return "#8bc0ff";
|
||||
@@ -40,7 +40,7 @@ export function shipPresentationColor(ship: ShipSnapshot) {
|
||||
if (ship.spatialState.movementRegime === "ftl-transit") {
|
||||
return "#ff6ad5";
|
||||
}
|
||||
return shipColor(ship.role);
|
||||
return shipColor(ship.kind);
|
||||
}
|
||||
|
||||
export function spatialNodeColor(kind: string) {
|
||||
|
||||
Reference in New Issue
Block a user