Refactor runtime bootstrap and ship control flows

This commit is contained in:
2026-04-03 01:12:26 -04:00
parent 0bb72bee35
commit 706e1cda8f
129 changed files with 9588 additions and 3548 deletions

View File

@@ -4,9 +4,11 @@ import type { StationSnapshot } from "../../contractsInfrastructure";
import type { FactionSnapshot } from "../../contractsFactions";
import type { MarketOrderSnapshot } from "../../contractsEconomy";
import type { GeopoliticalStateSnapshot } from "../../contractsGeopolitics";
import type { SystemSnapshot } from "../../contractsCelestial";
export const useGmStore = defineStore("gm", {
state: () => ({
systems: [] as SystemSnapshot[],
ships: [] as ShipSnapshot[],
stations: [] as StationSnapshot[],
factions: [] as FactionSnapshot[],
@@ -15,12 +17,14 @@ export const useGmStore = defineStore("gm", {
}),
actions: {
updateWorld(
systems: SystemSnapshot[],
ships: ShipSnapshot[],
stations: StationSnapshot[],
factions: FactionSnapshot[],
marketOrders: MarketOrderSnapshot[],
geopolitics: GeopoliticalStateSnapshot | null,
) {
this.systems = systems;
this.ships = ships;
this.stations = stations;
this.factions = factions;
@@ -35,5 +39,21 @@ export const useGmStore = defineStore("gm", {
}
this.ships.push(ship);
},
upsertFaction(faction: FactionSnapshot) {
const index = this.factions.findIndex((candidate) => candidate.id === faction.id);
if (index >= 0) {
this.factions.splice(index, 1, faction);
return;
}
this.factions.push(faction);
},
upsertStation(station: StationSnapshot) {
const index = this.stations.findIndex((candidate) => candidate.id === station.id);
if (index >= 0) {
this.stations.splice(index, 1, station);
return;
}
this.stations.push(station);
},
},
});