ui/phase-11: map wired to live game state

Replaces the Phase 10 map stub with live planet rendering driven by
`user.games.report`, and wires the header turn counter to the same
data. Phase 11's frontend sits on a per-game `GameStateStore` that
lives in `lib/game-state.svelte.ts`: the in-game shell layout
instantiates one per game, exposes it through Svelte context, and
disposes it on remount. The store discovers the game's current turn
through `lobby.my.games.list`, fetches the matching report, and
exposes a TS-friendly snapshot to the header turn counter, the map
view, and the inspector / order / calculator tabs that later phases
will plug onto the same instance.

The pipeline forced one cross-stage decision: the user surface needs
the current turn number to know which report to fetch, but
`GameSummary` did not expose it. Phase 11 extends the lobby
catalogue (FB schema, transcoder, Go model, backend
gameSummaryWire, gateway decoders, openapi, TS bindings,
api/lobby.ts) with `current_turn:int32`. The data was already
tracked in backend's `RuntimeSnapshot.CurrentTurn`; surfacing it is
a wire change only. Two alternatives were rejected: a brand-new
`user.games.state` message (full wire-flow for one field) and
hard-coding `turn=0` (works for the dev sandbox, which never
advances past zero, but renders the initial state for any real
game). The change crosses Phase 8's already-shipped catalogue per
the project's "decisions baked back into the live plan" rule —
existing tests and fixtures are updated in the same patch.

The state binding lives in `map/state-binding.ts::reportToWorld`:
one Point primitive per planet across all four kinds (local /
other / uninhabited / unidentified) with distinct fill colours,
fill alphas, and point radii so the user can tell them apart at a
glance. The planet engine number is reused as the primitive id so
a hit-test result resolves directly to a planet without an extra
lookup table. Zero-planet reports yield a well-formed empty world;
malformed dimensions fall back to 1×1 so a bad report cannot crash
the renderer.

The map view's mount effect creates the renderer once and skips
re-mount on no-op refreshes (same turn, same wrap mode); a turn
change or wrap-mode flip disposes and recreates it. The renderer's
external API does not yet expose `setWorld`; Phase 24 / 34 will
extract it once high-frequency updates land. The store installs a
`visibilitychange` listener that calls `refresh()` when the tab
regains focus.

Wrap-mode preference uses `Cache` namespace `game-prefs`, key
`<gameId>/wrap-mode`, default `torus`. Phase 11 reads through
`store.wrapMode`; Phase 29 wires the toggle UI on top of
`setWrapMode`.

Tests: Vitest unit coverage for `reportToWorld` (every kind,
ids, styling, empty / zero-dimension edges, priority order) and
for the store lifecycle (init success, missing-membership error,
forbidden-result error, `setTurn`, wrap-mode persistence across
instances, `failBootstrap`). Playwright e2e mocks the gateway for
`lobby.my.games.list` and `user.games.report` and asserts the
live data path: turn counter shows the reported turn,
`active-view-map` flips to `data-status="ready"`, and
`data-planet-count` matches the fixture count. The zero-planet
regression and the missing-membership error path are covered.

Phase 11 status stays `pending` in `ui/PLAN.md` until the local-ci
run lands green; flipping to `done` follows in the next commit per
the per-stage CI gate in `CLAUDE.md`.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
Ilia Denisov
2026-05-08 21:17:17 +02:00
parent ff524fabc6
commit ce7a66b3e6
53 changed files with 5994 additions and 70 deletions
+178
View File
@@ -0,0 +1,178 @@
// Typed wrapper around `GalaxyClient.executeCommand("user.games.report",
// ...)`. The signed-gRPC wire shape is the FlatBuffers
// `report.GameReportRequest` for the request and `report.Report` for
// the response (see `pkg/schema/fbs/report.fbs`). Phase 11 only
// surfaces the planet subset of the response — full ship / fleet /
// science decoding lands in Phases 17-22.
import { Builder, ByteBuffer } from "flatbuffers";
import type { GalaxyClient } from "./galaxy-client";
import { UUID } from "../proto/galaxy/fbs/common";
import {
GameReportRequest,
Report,
} from "../proto/galaxy/fbs/report";
const MESSAGE_TYPE = "user.games.report";
export class GameStateError extends Error {
readonly resultCode: string;
readonly code: string;
constructor(resultCode: string, code: string, message: string) {
super(message);
this.name = "GameStateError";
this.resultCode = resultCode;
this.code = code;
}
}
export interface ReportPlanet {
number: number;
name: string;
x: number;
y: number;
kind: "local" | "other" | "uninhabited" | "unidentified";
owner: string | null;
size: number | null;
resources: number | null;
}
export interface GameReport {
turn: number;
mapWidth: number;
mapHeight: number;
planetCount: number;
planets: ReportPlanet[];
}
export async function fetchGameReport(
client: GalaxyClient,
gameId: string,
turn: number,
): Promise<GameReport> {
const builder = new Builder(64);
const [hi, lo] = uuidToHiLo(gameId);
const gameIdOffset = UUID.createUUID(builder, hi, lo);
GameReportRequest.startGameReportRequest(builder);
GameReportRequest.addGameId(builder, gameIdOffset);
GameReportRequest.addTurn(builder, turn);
builder.finish(GameReportRequest.endGameReportRequest(builder));
const result = await client.executeCommand(MESSAGE_TYPE, builder.asUint8Array());
if (result.resultCode !== "ok") {
const { code, message } = decodeErrorMessage(result.payloadBytes);
throw new GameStateError(result.resultCode, code, message);
}
const buffer = new ByteBuffer(result.payloadBytes);
const report = Report.getRootAsReport(buffer);
return decodeReport(report);
}
function decodeReport(report: Report): GameReport {
const planets: ReportPlanet[] = [];
for (let i = 0; i < report.localPlanetLength(); i++) {
const p = report.localPlanet(i);
if (p === null) continue;
planets.push({
number: Number(p.number()),
name: p.name() ?? "",
x: p.x(),
y: p.y(),
kind: "local",
owner: null,
size: p.size(),
resources: p.resources(),
});
}
for (let i = 0; i < report.otherPlanetLength(); i++) {
const p = report.otherPlanet(i);
if (p === null) continue;
planets.push({
number: Number(p.number()),
name: p.name() ?? "",
x: p.x(),
y: p.y(),
kind: "other",
owner: p.owner() ?? null,
size: p.size(),
resources: p.resources(),
});
}
for (let i = 0; i < report.uninhabitedPlanetLength(); i++) {
const p = report.uninhabitedPlanet(i);
if (p === null) continue;
planets.push({
number: Number(p.number()),
name: p.name() ?? "",
x: p.x(),
y: p.y(),
kind: "uninhabited",
owner: null,
size: p.size(),
resources: p.resources(),
});
}
for (let i = 0; i < report.unidentifiedPlanetLength(); i++) {
const p = report.unidentifiedPlanet(i);
if (p === null) continue;
planets.push({
number: Number(p.number()),
name: "",
x: p.x(),
y: p.y(),
kind: "unidentified",
owner: null,
size: null,
resources: null,
});
}
return {
turn: Number(report.turn()),
mapWidth: report.width(),
mapHeight: report.height(),
planetCount: report.planetCount(),
planets,
};
}
/**
* uuidToHiLo splits the canonical 36-character UUID string
* (`xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx`) into the two big-endian
* uint64 halves used by `common.UUID`. Mirrors `pkg/transcoder/uuid.go`.
*/
export function uuidToHiLo(value: string): [bigint, bigint] {
const hex = value.replace(/-/g, "").toLowerCase();
if (hex.length !== 32 || /[^0-9a-f]/.test(hex)) {
throw new GameStateError(
"invalid_request",
"invalid_request",
`invalid uuid: ${value}`,
);
}
const hi = BigInt(`0x${hex.slice(0, 16)}`);
const lo = BigInt(`0x${hex.slice(16, 32)}`);
return [hi, lo];
}
function decodeErrorMessage(payload: Uint8Array): { code: string; message: string } {
if (payload.length === 0) {
return { code: "internal_error", message: "empty error payload" };
}
try {
const text = new TextDecoder().decode(payload);
const parsed = JSON.parse(text) as { code?: string; message?: string };
return {
code: typeof parsed.code === "string" ? parsed.code : "internal_error",
message: typeof parsed.message === "string" ? parsed.message : text,
};
} catch {
return { code: "internal_error", message: "non-json error payload" };
}
}
+8
View File
@@ -55,6 +55,13 @@ export interface GameSummary {
enrollmentEndsAt: Date;
createdAt: Date;
updatedAt: Date;
/**
* Most recent turn number observed by backend's runtime
* projection. Zero before the engine produces its first
* snapshot. The map view uses this to fetch the matching
* `user.games.report` without a separate state query.
*/
currentTurn: number;
}
export interface PublicGamesPage {
@@ -319,6 +326,7 @@ function decodeGameSummary(summary: FbsGameSummary): GameSummary {
enrollmentEndsAt: dateFromMs(summary.enrollmentEndsAtMs()),
createdAt: dateFromMs(summary.createdAtMs()),
updatedAt: dateFromMs(summary.updatedAtMs()),
currentTurn: summary.currentTurn(),
};
}
+173 -15
View File
@@ -1,29 +1,187 @@
<!--
Phase 10 stub for the map active view. Phase 11 swaps this for the
live renderer integration described in `ui/PLAN.md` Phase 11. The
stub keeps the same `data-testid` so Phase 11's spec replaces the
copy assertion without touching navigation.
Phase 11 map active view: integrates the Phase 9 renderer with the
per-game `GameStateStore` provided through context by
`routes/games/[id]/+layout.svelte`. The view mounts the renderer
once the store has produced a report and re-mounts when the
report's turn changes (a refresh that returns the same turn keeps
the existing renderer instance alive). Empty-planet reports render
the empty world without errors — the regression test in
`tests/e2e/game-shell-map.spec.ts` covers this.
Phase 9 owns the renderer's hit-test and pan/zoom semantics; Phase 13
will plug map clicks into the inspector. Phase 29 wires the wrap-mode
toggle on top of the per-game `wrapMode` preference the store
already manages.
-->
<script lang="ts">
import { getContext, onDestroy, onMount, untrack } from "svelte";
import { i18n } from "$lib/i18n/index.svelte";
import {
createRenderer,
minScaleNoWrap,
type RendererHandle,
} from "../../map/index";
import { reportToWorld } from "../../map/state-binding";
import {
GAME_STATE_CONTEXT_KEY,
type GameStateStore,
} from "$lib/game-state.svelte";
const store = getContext<GameStateStore | undefined>(GAME_STATE_CONTEXT_KEY);
let canvasEl: HTMLCanvasElement | null = $state(null);
let containerEl: HTMLDivElement | null = $state(null);
let mountError: string | null = $state(null);
let handle: RendererHandle | null = null;
let mountedTurn: number | null = null;
let mountedGameId: string | null = null;
let onResize: (() => void) | null = null;
let mounted = false;
$effect(() => {
const report = store?.report;
const status = store?.status ?? "idle";
// Track the wrap mode so the renderer remounts when Phase 29's
// toggle UI flips it; the read here also subscribes the effect.
const mode = store?.wrapMode ?? "torus";
const gameId = store?.gameId ?? "";
if (!mounted || canvasEl === null || containerEl === null) return;
if (status !== "ready" || !report) return;
// Skip a re-mount when the same turn is reloaded for the same
// game and the wrap mode did not change. The store's `refresh`
// path lands here on tab focus; an unchanged snapshot must not
// flicker the canvas.
const sameSnapshot =
mountedTurn === report.turn &&
mountedGameId === gameId &&
handle !== null &&
handle.getMode() === mode;
if (sameSnapshot) return;
untrack(() => {
void mountRenderer(report, mode);
});
});
async function mountRenderer(
report: NonNullable<GameStateStore["report"]>,
mode: "torus" | "no-wrap",
): Promise<void> {
if (canvasEl === null || containerEl === null) return;
if (handle !== null) {
handle.dispose();
handle = null;
}
try {
const world = reportToWorld(report);
handle = await createRenderer({
canvas: canvasEl,
world,
mode,
preference: ["webgpu", "webgl"],
});
handle.viewport.moveCenter(world.width / 2, world.height / 2);
const minScale = minScaleNoWrap(
{
widthPx: containerEl.clientWidth,
heightPx: containerEl.clientHeight,
},
world,
);
handle.viewport.setZoom(minScale * 1.05, true);
if (mode === "no-wrap") handle.setMode("no-wrap");
mountedTurn = report.turn;
mountedGameId = store?.gameId ?? "";
mountError = null;
} catch (err) {
mountError = err instanceof Error ? err.message : String(err);
}
}
onMount(() => {
mounted = true;
onResize = (): void => {
if (handle === null || containerEl === null) return;
handle.resize(containerEl.clientWidth, containerEl.clientHeight);
};
window.addEventListener("resize", onResize);
});
onDestroy(() => {
mounted = false;
if (onResize !== null) {
window.removeEventListener("resize", onResize);
onResize = null;
}
if (handle !== null) {
handle.dispose();
handle = null;
}
});
</script>
<section class="active-view" data-testid="active-view-map">
<h2>{i18n.t("game.view.map")}</h2>
<p>{i18n.t("game.shell.coming_soon")}</p>
<section class="active-view" data-testid="active-view-map" data-status={store?.status ?? "idle"}>
{#if store?.status === "error"}
<p class="overlay error" role="alert" data-testid="map-error">
{store.error ?? "request failed"}
</p>
{:else if mountError !== null}
<p class="overlay error" role="alert" data-testid="map-mount-error">
{mountError}
</p>
{:else if store?.status !== "ready"}
<p class="overlay" data-testid="map-loading">{i18n.t("common.loading")}</p>
{/if}
<div
class="canvas-wrap"
data-testid="map-canvas-wrap"
data-planet-count={store?.report?.planets.length ?? 0}
bind:this={containerEl}
>
<canvas bind:this={canvasEl}></canvas>
</div>
</section>
<style>
.active-view {
padding: 1.5rem;
position: relative;
display: flex;
flex-direction: column;
height: 100%;
min-height: 0;
}
.canvas-wrap {
flex: 1;
min-height: 0;
position: relative;
overflow: hidden;
background: #0a0e1a;
}
canvas {
display: block;
width: 100%;
height: 100%;
}
.overlay {
position: absolute;
top: 0.75rem;
left: 50%;
transform: translateX(-50%);
padding: 0.4rem 0.9rem;
background: rgba(20, 24, 42, 0.85);
color: #e8eaf6;
border: 1px solid #2a3150;
border-radius: 6px;
z-index: 10;
font-family: system-ui, sans-serif;
}
.active-view h2 {
margin: 0 0 0.5rem;
font-size: 1.1rem;
}
.active-view p {
font-size: 0.9rem;
margin: 0;
color: #555;
}
.overlay.error {
background: #4a1820;
border-color: #6d2530;
color: #ffb4b4;
}
</style>
+200
View File
@@ -0,0 +1,200 @@
// Per-game runtime state owned by the in-game shell layout
// (`routes/games/[id]/+layout.svelte`). The store discovers the
// game's current turn through `lobby.my.games.list`, fetches the
// matching `user.games.report`, and exposes a TS-friendly `GameReport`
// snapshot to every consumer (header turn counter, map view,
// inspector tabs in later phases).
//
// Phase 11 covers planets only; later phases extend the report
// surface as their slice of state lands. Every consumer reads from
// the same store instance — instantiation per game guarantees the
// layout remount on `gameId` change reseeds the snapshot, while
// navigation between active views inside the same game keeps the
// instance alive (state-preservation rule, see ui/docs/navigation.md).
import {
GameStateError,
fetchGameReport,
type GameReport,
} from "../api/game-state";
import { listMyGames, type GameSummary } from "../api/lobby";
import type { GalaxyClient } from "../api/galaxy-client";
import type { Cache } from "../platform/store/index";
import type { WrapMode } from "../map/world";
const PREF_NAMESPACE = "game-prefs";
const PREF_KEY_WRAP_MODE = (gameId: string) => `${gameId}/wrap-mode`;
/**
* GAME_STATE_CONTEXT_KEY is the Svelte context key the in-game shell
* layout uses to expose its `GameStateStore` instance to descendants.
* Header / map / inspector children resolve the store via
* `getContext(GAME_STATE_CONTEXT_KEY)`.
*/
export const GAME_STATE_CONTEXT_KEY = Symbol("game-state");
type Status = "idle" | "loading" | "ready" | "error";
export class GameStateStore {
gameId: string = $state("");
status: Status = $state("idle");
report: GameReport | null = $state(null);
wrapMode: WrapMode = $state("torus");
error: string | null = $state(null);
private client: GalaxyClient | null = null;
private cache: Cache | null = null;
private currentTurn = 0;
private destroyed = false;
private visibilityListener: (() => void) | null = null;
/**
* init kicks off the per-game lifecycle. The call is idempotent on
* the same `gameId`; calling with a different game forwards through
* `setGame` so the layout can hand off across navigations.
*/
async init(opts: {
client: GalaxyClient;
cache: Cache;
gameId: string;
}): Promise<void> {
this.client = opts.client;
this.cache = opts.cache;
await this.setGame(opts.gameId);
this.installVisibilityListener();
}
/**
* setGame switches the store to the supplied game id, fetches the
* matching lobby record to discover `current_turn`, then loads the
* report. Failure paths surface through `status === "error"` and
* the matching `error` string (already localised by the caller).
*/
async setGame(gameId: string): Promise<void> {
if (this.client === null || this.cache === null) {
throw new Error("game-state: setGame called before init");
}
this.gameId = gameId;
this.status = "loading";
this.error = null;
this.report = null;
this.wrapMode = await readWrapMode(this.cache, gameId);
try {
const summary = await this.findGame(gameId);
if (summary === null) {
this.status = "error";
this.error = `game ${gameId} is not in your list`;
return;
}
this.currentTurn = summary.currentTurn;
await this.loadTurn(summary.currentTurn);
} catch (err) {
if (this.destroyed) return;
this.status = "error";
this.error = describe(err);
}
}
/**
* setTurn loads a different turn snapshot — used by Phase 26 history
* mode. The current turn stays at whatever `setGame` discovered;
* calling without an argument refetches the same turn.
*/
async setTurn(turn: number): Promise<void> {
if (this.client === null) return;
this.status = "loading";
this.error = null;
try {
await this.loadTurn(turn);
} catch (err) {
this.status = "error";
this.error = describe(err);
}
}
/**
* refresh re-fetches the report at the current turn. Called on
* window `visibilitychange` so the map and the turn counter stay
* fresh after the user returns to the tab.
*/
refresh(): Promise<void> {
return this.setTurn(this.currentTurn);
}
/**
* setWrapMode persists the per-game preference into Cache so the
* next visit to the game restores it. Phase 29 wires the toggle UI;
* Phase 11 only reads through `wrapMode` and writes via this method.
*/
async setWrapMode(mode: WrapMode): Promise<void> {
this.wrapMode = mode;
if (this.cache !== null) {
await this.cache.put(PREF_NAMESPACE, PREF_KEY_WRAP_MODE(this.gameId), mode);
}
}
/**
* failBootstrap is used by the layout to surface errors that
* happen *before* `init` could be reached (missing keypair, missing
* gateway public key, core/store load failure). It does not need
* `init` to have run first.
*/
failBootstrap(message: string): void {
this.status = "error";
this.error = message;
}
dispose(): void {
this.destroyed = true;
if (this.visibilityListener !== null && typeof document !== "undefined") {
document.removeEventListener("visibilitychange", this.visibilityListener);
}
this.visibilityListener = null;
this.client = null;
this.cache = null;
}
private async findGame(gameId: string): Promise<GameSummary | null> {
if (this.client === null) return null;
const games = await listMyGames(this.client);
return games.find((g) => g.gameId === gameId) ?? null;
}
private async loadTurn(turn: number): Promise<void> {
if (this.client === null) return;
const report = await fetchGameReport(this.client, this.gameId, turn);
if (this.destroyed) return;
this.report = report;
this.currentTurn = turn;
this.status = "ready";
}
private installVisibilityListener(): void {
if (typeof document === "undefined") return;
const listener = (): void => {
if (document.visibilityState === "visible" && this.status === "ready") {
void this.refresh();
}
};
this.visibilityListener = listener;
document.addEventListener("visibilitychange", listener);
}
}
async function readWrapMode(cache: Cache, gameId: string): Promise<WrapMode> {
const stored = await cache.get<string>(PREF_NAMESPACE, PREF_KEY_WRAP_MODE(gameId));
if (stored === "no-wrap") return "no-wrap";
return "torus";
}
function describe(err: unknown): string {
if (err instanceof GameStateError) {
return err.message;
}
if (err instanceof Error) {
return err.message;
}
return "request failed";
}
+22 -6
View File
@@ -1,15 +1,31 @@
<!--
Phase 10 placeholder turn counter. The displayed value is the static
`?` glyph from `game.shell.turn_unknown`; Phase 11 swaps the source
to the live game state. The wrapping span is kept as the public
shape so Phase 11 only needs to replace the inner text.
Phase 11 turn counter: reads the live turn number from the per-game
`GameStateStore` provided through context by
`routes/games/[id]/+layout.svelte`. Renders the static `?` placeholder
from `game.shell.turn_unknown` when the store has not yet produced a
report (boot, network error, no membership) so the header chrome
keeps its width across loading transitions.
Phase 26 will turn this into a clickable trigger that opens the
turn navigator; Phase 24 wires push-event-driven turn-ready toasts
that may flash this counter when a new turn is ready.
-->
<script lang="ts">
import { getContext } from "svelte";
import { i18n } from "$lib/i18n/index.svelte";
import { GAME_STATE_CONTEXT_KEY, type GameStateStore } from "$lib/game-state.svelte";
const store = getContext<GameStateStore | undefined>(GAME_STATE_CONTEXT_KEY);
const display = $derived.by(() => {
const report = store?.report ?? null;
if (report === null) return i18n.t("game.shell.turn_unknown");
return String(report.turn);
});
</script>
<span class="turn" data-testid="turn-counter">
{i18n.t("game.shell.turn_label")}&nbsp;{i18n.t("game.shell.turn_unknown")}
<span class="turn" data-testid="turn-counter" data-turn={display}>
{i18n.t("game.shell.turn_label")}&nbsp;{display}
</span>
<style>
+98
View File
@@ -0,0 +1,98 @@
// State binding between the typed game report and the renderer's
// World. Phase 11 only emits primitives for planets; later phases
// extend the binding with ship-class reach circles (Phase 17 / 18),
// hyperspace and incoming groups (Phase 11+ via separate primitives),
// cargo routes (Phase 16), reach / visibility zones (Phase 17), and
// battle / bombing markers (Phase 27).
//
// The four planet kinds in the report each map to a distinct style so
// the user can tell own / other-race / uninhabited / unidentified
// planets apart at a glance. The exact colours are Phase 11 defaults
// chosen against the dark theme; Phase 35 polish picks final
// colours and adds theme switching.
import type { GameReport, ReportPlanet } from "../api/game-state";
import { World, type Primitive, type Style } from "./world";
const STYLE_LOCAL: Style = {
fillColor: 0x6dd2ff,
fillAlpha: 1,
pointRadiusPx: 6,
};
const STYLE_OTHER: Style = {
fillColor: 0xff8a65,
fillAlpha: 1,
pointRadiusPx: 5,
};
const STYLE_UNINHABITED: Style = {
fillColor: 0xb0bec5,
fillAlpha: 0.85,
pointRadiusPx: 4,
};
const STYLE_UNIDENTIFIED: Style = {
fillColor: 0x546e7a,
fillAlpha: 0.7,
pointRadiusPx: 3,
};
// PlanetIDs occupy the [0, 4_000_000_000) range — well below
// JavaScript's `Number.MAX_SAFE_INTEGER` — so the engine `number` (uint64)
// fits in a primitive id (number) without truncation. The binding
// uses the engine number directly as the primitive id so later phases
// can resolve a planet by its hit-test result without an extra
// lookup table.
function styleFor(kind: ReportPlanet["kind"]): Style {
switch (kind) {
case "local":
return STYLE_LOCAL;
case "other":
return STYLE_OTHER;
case "uninhabited":
return STYLE_UNINHABITED;
case "unidentified":
return STYLE_UNIDENTIFIED;
}
}
function priorityFor(kind: ReportPlanet["kind"]): number {
switch (kind) {
case "local":
return 4;
case "other":
return 3;
case "uninhabited":
return 2;
case "unidentified":
return 1;
}
}
/**
* reportToWorld translates a GameReport into a renderer-ready World
* containing one Point primitive per planet (all four planet kinds).
* The world rectangle matches `report.mapWidth` × `report.mapHeight`.
*
* If the report carries zero planets (turn-zero edge cases or seeded
* tests), the World is still well-formed: the renderer mounts on an
* empty primitive list without errors.
*/
export function reportToWorld(report: GameReport): World {
const primitives: Primitive[] = [];
for (const planet of report.planets) {
primitives.push({
kind: "point",
id: planet.number,
priority: priorityFor(planet.kind),
style: styleFor(planet.kind),
hitSlopPx: 0,
x: planet.x,
y: planet.y,
});
}
const width = report.mapWidth > 0 ? report.mapWidth : 1;
const height = report.mapHeight > 0 ? report.mapHeight : 1;
return new World(width, height, primitives);
}
@@ -0,0 +1,5 @@
// automatically generated by the FlatBuffers compiler, do not modify
/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
export { UUID, UUIDT } from './common/uuid.js';
@@ -0,0 +1,65 @@
// automatically generated by the FlatBuffers compiler, do not modify
/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
import * as flatbuffers from 'flatbuffers';
export class UUID implements flatbuffers.IUnpackableObject<UUIDT> {
bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0;
__init(i:number, bb:flatbuffers.ByteBuffer):UUID {
this.bb_pos = i;
this.bb = bb;
return this;
}
hi():bigint {
return this.bb!.readUint64(this.bb_pos);
}
lo():bigint {
return this.bb!.readUint64(this.bb_pos + 8);
}
static sizeOf():number {
return 16;
}
static createUUID(builder:flatbuffers.Builder, hi: bigint, lo: bigint):flatbuffers.Offset {
builder.prep(8, 16);
builder.writeInt64(BigInt(lo ?? 0));
builder.writeInt64(BigInt(hi ?? 0));
return builder.offset();
}
unpack(): UUIDT {
return new UUIDT(
this.hi(),
this.lo()
);
}
unpackTo(_o: UUIDT): void {
_o.hi = this.hi();
_o.lo = this.lo();
}
}
export class UUIDT implements flatbuffers.IGeneratedObject {
constructor(
public hi: bigint = BigInt('0'),
public lo: bigint = BigInt('0')
){}
pack(builder:flatbuffers.Builder): flatbuffers.Offset {
return UUID.createUUID(builder,
this.hi,
this.lo
);
}
}
@@ -84,8 +84,13 @@ updatedAtMs():bigint {
return offset ? this.bb!.readInt64(this.bb_pos + offset) : BigInt('0');
}
currentTurn():number {
const offset = this.bb!.__offset(this.bb_pos, 24);
return offset ? this.bb!.readInt32(this.bb_pos + offset) : 0;
}
static startGameSummary(builder:flatbuffers.Builder) {
builder.startObject(10);
builder.startObject(11);
}
static addGameId(builder:flatbuffers.Builder, gameIdOffset:flatbuffers.Offset) {
@@ -128,12 +133,16 @@ static addUpdatedAtMs(builder:flatbuffers.Builder, updatedAtMs:bigint) {
builder.addFieldInt64(9, updatedAtMs, BigInt('0'));
}
static addCurrentTurn(builder:flatbuffers.Builder, currentTurn:number) {
builder.addFieldInt32(10, currentTurn, 0);
}
static endGameSummary(builder:flatbuffers.Builder):flatbuffers.Offset {
const offset = builder.endObject();
return offset;
}
static createGameSummary(builder:flatbuffers.Builder, gameIdOffset:flatbuffers.Offset, gameNameOffset:flatbuffers.Offset, gameTypeOffset:flatbuffers.Offset, statusOffset:flatbuffers.Offset, ownerUserIdOffset:flatbuffers.Offset, minPlayers:number, maxPlayers:number, enrollmentEndsAtMs:bigint, createdAtMs:bigint, updatedAtMs:bigint):flatbuffers.Offset {
static createGameSummary(builder:flatbuffers.Builder, gameIdOffset:flatbuffers.Offset, gameNameOffset:flatbuffers.Offset, gameTypeOffset:flatbuffers.Offset, statusOffset:flatbuffers.Offset, ownerUserIdOffset:flatbuffers.Offset, minPlayers:number, maxPlayers:number, enrollmentEndsAtMs:bigint, createdAtMs:bigint, updatedAtMs:bigint, currentTurn:number):flatbuffers.Offset {
GameSummary.startGameSummary(builder);
GameSummary.addGameId(builder, gameIdOffset);
GameSummary.addGameName(builder, gameNameOffset);
@@ -145,6 +154,7 @@ static createGameSummary(builder:flatbuffers.Builder, gameIdOffset:flatbuffers.O
GameSummary.addEnrollmentEndsAtMs(builder, enrollmentEndsAtMs);
GameSummary.addCreatedAtMs(builder, createdAtMs);
GameSummary.addUpdatedAtMs(builder, updatedAtMs);
GameSummary.addCurrentTurn(builder, currentTurn);
return GameSummary.endGameSummary(builder);
}
@@ -159,7 +169,8 @@ unpack(): GameSummaryT {
this.maxPlayers(),
this.enrollmentEndsAtMs(),
this.createdAtMs(),
this.updatedAtMs()
this.updatedAtMs(),
this.currentTurn()
);
}
@@ -175,6 +186,7 @@ unpackTo(_o: GameSummaryT): void {
_o.enrollmentEndsAtMs = this.enrollmentEndsAtMs();
_o.createdAtMs = this.createdAtMs();
_o.updatedAtMs = this.updatedAtMs();
_o.currentTurn = this.currentTurn();
}
}
@@ -189,7 +201,8 @@ constructor(
public maxPlayers: number = 0,
public enrollmentEndsAtMs: bigint = BigInt('0'),
public createdAtMs: bigint = BigInt('0'),
public updatedAtMs: bigint = BigInt('0')
public updatedAtMs: bigint = BigInt('0'),
public currentTurn: number = 0
){}
@@ -210,7 +223,8 @@ pack(builder:flatbuffers.Builder): flatbuffers.Offset {
this.maxPlayers,
this.enrollmentEndsAtMs,
this.createdAtMs,
this.updatedAtMs
this.updatedAtMs,
this.currentTurn
);
}
}
@@ -0,0 +1,25 @@
// automatically generated by the FlatBuffers compiler, do not modify
/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
export { Bombing, BombingT } from './report/bombing.js';
export { GameReportRequest, GameReportRequestT } from './report/game-report-request.js';
export { IncomingGroup, IncomingGroupT } from './report/incoming-group.js';
export { LocalFleet, LocalFleetT } from './report/local-fleet.js';
export { LocalGroup, LocalGroupT } from './report/local-group.js';
export { LocalPlanet, LocalPlanetT } from './report/local-planet.js';
export { OtherGroup, OtherGroupT } from './report/other-group.js';
export { OtherPlanet, OtherPlanetT } from './report/other-planet.js';
export { OtherScience, OtherScienceT } from './report/other-science.js';
export { OthersShipClass, OthersShipClassT } from './report/others-ship-class.js';
export { Player, PlayerT } from './report/player.js';
export { Report, ReportT } from './report/report.js';
export { Route, RouteT } from './report/route.js';
export { RouteEntry, RouteEntryT } from './report/route-entry.js';
export { Science, ScienceT } from './report/science.js';
export { ShipClass, ShipClassT } from './report/ship-class.js';
export { ShipProduction, ShipProductionT } from './report/ship-production.js';
export { TechEntry, TechEntryT } from './report/tech-entry.js';
export { UnidentifiedGroup, UnidentifiedGroupT } from './report/unidentified-group.js';
export { UnidentifiedPlanet, UnidentifiedPlanetT } from './report/unidentified-planet.js';
export { UninhabitedPlanet, UninhabitedPlanetT } from './report/uninhabited-planet.js';
@@ -0,0 +1,241 @@
// automatically generated by the FlatBuffers compiler, do not modify
/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
import * as flatbuffers from 'flatbuffers';
export class Bombing implements flatbuffers.IUnpackableObject<BombingT> {
bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0;
__init(i:number, bb:flatbuffers.ByteBuffer):Bombing {
this.bb_pos = i;
this.bb = bb;
return this;
}
static getRootAsBombing(bb:flatbuffers.ByteBuffer, obj?:Bombing):Bombing {
return (obj || new Bombing()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
static getSizePrefixedRootAsBombing(bb:flatbuffers.ByteBuffer, obj?:Bombing):Bombing {
bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
return (obj || new Bombing()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
number():bigint {
const offset = this.bb!.__offset(this.bb_pos, 4);
return offset ? this.bb!.readUint64(this.bb_pos + offset) : BigInt('0');
}
planet():string|null
planet(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
planet(optionalEncoding?:any):string|Uint8Array|null {
const offset = this.bb!.__offset(this.bb_pos, 6);
return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
}
owner():string|null
owner(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
owner(optionalEncoding?:any):string|Uint8Array|null {
const offset = this.bb!.__offset(this.bb_pos, 8);
return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
}
attacker():string|null
attacker(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
attacker(optionalEncoding?:any):string|Uint8Array|null {
const offset = this.bb!.__offset(this.bb_pos, 10);
return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
}
production():string|null
production(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
production(optionalEncoding?:any):string|Uint8Array|null {
const offset = this.bb!.__offset(this.bb_pos, 12);
return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
}
industry():number {
const offset = this.bb!.__offset(this.bb_pos, 14);
return offset ? this.bb!.readFloat32(this.bb_pos + offset) : 0.0;
}
population():number {
const offset = this.bb!.__offset(this.bb_pos, 16);
return offset ? this.bb!.readFloat32(this.bb_pos + offset) : 0.0;
}
colonists():number {
const offset = this.bb!.__offset(this.bb_pos, 18);
return offset ? this.bb!.readFloat32(this.bb_pos + offset) : 0.0;
}
capital():number {
const offset = this.bb!.__offset(this.bb_pos, 20);
return offset ? this.bb!.readFloat32(this.bb_pos + offset) : 0.0;
}
material():number {
const offset = this.bb!.__offset(this.bb_pos, 22);
return offset ? this.bb!.readFloat32(this.bb_pos + offset) : 0.0;
}
attackPower():number {
const offset = this.bb!.__offset(this.bb_pos, 24);
return offset ? this.bb!.readFloat32(this.bb_pos + offset) : 0.0;
}
wiped():boolean {
const offset = this.bb!.__offset(this.bb_pos, 26);
return offset ? !!this.bb!.readInt8(this.bb_pos + offset) : false;
}
static startBombing(builder:flatbuffers.Builder) {
builder.startObject(12);
}
static addNumber(builder:flatbuffers.Builder, number:bigint) {
builder.addFieldInt64(0, number, BigInt('0'));
}
static addPlanet(builder:flatbuffers.Builder, planetOffset:flatbuffers.Offset) {
builder.addFieldOffset(1, planetOffset, 0);
}
static addOwner(builder:flatbuffers.Builder, ownerOffset:flatbuffers.Offset) {
builder.addFieldOffset(2, ownerOffset, 0);
}
static addAttacker(builder:flatbuffers.Builder, attackerOffset:flatbuffers.Offset) {
builder.addFieldOffset(3, attackerOffset, 0);
}
static addProduction(builder:flatbuffers.Builder, productionOffset:flatbuffers.Offset) {
builder.addFieldOffset(4, productionOffset, 0);
}
static addIndustry(builder:flatbuffers.Builder, industry:number) {
builder.addFieldFloat32(5, industry, 0.0);
}
static addPopulation(builder:flatbuffers.Builder, population:number) {
builder.addFieldFloat32(6, population, 0.0);
}
static addColonists(builder:flatbuffers.Builder, colonists:number) {
builder.addFieldFloat32(7, colonists, 0.0);
}
static addCapital(builder:flatbuffers.Builder, capital:number) {
builder.addFieldFloat32(8, capital, 0.0);
}
static addMaterial(builder:flatbuffers.Builder, material:number) {
builder.addFieldFloat32(9, material, 0.0);
}
static addAttackPower(builder:flatbuffers.Builder, attackPower:number) {
builder.addFieldFloat32(10, attackPower, 0.0);
}
static addWiped(builder:flatbuffers.Builder, wiped:boolean) {
builder.addFieldInt8(11, +wiped, +false);
}
static endBombing(builder:flatbuffers.Builder):flatbuffers.Offset {
const offset = builder.endObject();
return offset;
}
static createBombing(builder:flatbuffers.Builder, number:bigint, planetOffset:flatbuffers.Offset, ownerOffset:flatbuffers.Offset, attackerOffset:flatbuffers.Offset, productionOffset:flatbuffers.Offset, industry:number, population:number, colonists:number, capital:number, material:number, attackPower:number, wiped:boolean):flatbuffers.Offset {
Bombing.startBombing(builder);
Bombing.addNumber(builder, number);
Bombing.addPlanet(builder, planetOffset);
Bombing.addOwner(builder, ownerOffset);
Bombing.addAttacker(builder, attackerOffset);
Bombing.addProduction(builder, productionOffset);
Bombing.addIndustry(builder, industry);
Bombing.addPopulation(builder, population);
Bombing.addColonists(builder, colonists);
Bombing.addCapital(builder, capital);
Bombing.addMaterial(builder, material);
Bombing.addAttackPower(builder, attackPower);
Bombing.addWiped(builder, wiped);
return Bombing.endBombing(builder);
}
unpack(): BombingT {
return new BombingT(
this.number(),
this.planet(),
this.owner(),
this.attacker(),
this.production(),
this.industry(),
this.population(),
this.colonists(),
this.capital(),
this.material(),
this.attackPower(),
this.wiped()
);
}
unpackTo(_o: BombingT): void {
_o.number = this.number();
_o.planet = this.planet();
_o.owner = this.owner();
_o.attacker = this.attacker();
_o.production = this.production();
_o.industry = this.industry();
_o.population = this.population();
_o.colonists = this.colonists();
_o.capital = this.capital();
_o.material = this.material();
_o.attackPower = this.attackPower();
_o.wiped = this.wiped();
}
}
export class BombingT implements flatbuffers.IGeneratedObject {
constructor(
public number: bigint = BigInt('0'),
public planet: string|Uint8Array|null = null,
public owner: string|Uint8Array|null = null,
public attacker: string|Uint8Array|null = null,
public production: string|Uint8Array|null = null,
public industry: number = 0.0,
public population: number = 0.0,
public colonists: number = 0.0,
public capital: number = 0.0,
public material: number = 0.0,
public attackPower: number = 0.0,
public wiped: boolean = false
){}
pack(builder:flatbuffers.Builder): flatbuffers.Offset {
const planet = (this.planet !== null ? builder.createString(this.planet!) : 0);
const owner = (this.owner !== null ? builder.createString(this.owner!) : 0);
const attacker = (this.attacker !== null ? builder.createString(this.attacker!) : 0);
const production = (this.production !== null ? builder.createString(this.production!) : 0);
return Bombing.createBombing(builder,
this.number,
planet,
owner,
attacker,
production,
this.industry,
this.population,
this.colonists,
this.capital,
this.material,
this.attackPower,
this.wiped
);
}
}
@@ -0,0 +1,90 @@
// automatically generated by the FlatBuffers compiler, do not modify
/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
import * as flatbuffers from 'flatbuffers';
import { UUID, UUIDT } from '../common/uuid.js';
export class GameReportRequest implements flatbuffers.IUnpackableObject<GameReportRequestT> {
bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0;
__init(i:number, bb:flatbuffers.ByteBuffer):GameReportRequest {
this.bb_pos = i;
this.bb = bb;
return this;
}
static getRootAsGameReportRequest(bb:flatbuffers.ByteBuffer, obj?:GameReportRequest):GameReportRequest {
return (obj || new GameReportRequest()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
static getSizePrefixedRootAsGameReportRequest(bb:flatbuffers.ByteBuffer, obj?:GameReportRequest):GameReportRequest {
bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
return (obj || new GameReportRequest()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
gameId(obj?:UUID):UUID|null {
const offset = this.bb!.__offset(this.bb_pos, 4);
return offset ? (obj || new UUID()).__init(this.bb_pos + offset, this.bb!) : null;
}
turn():number {
const offset = this.bb!.__offset(this.bb_pos, 6);
return offset ? this.bb!.readUint32(this.bb_pos + offset) : 0;
}
static startGameReportRequest(builder:flatbuffers.Builder) {
builder.startObject(2);
}
static addGameId(builder:flatbuffers.Builder, gameIdOffset:flatbuffers.Offset) {
builder.addFieldStruct(0, gameIdOffset, 0);
}
static addTurn(builder:flatbuffers.Builder, turn:number) {
builder.addFieldInt32(1, turn, 0);
}
static endGameReportRequest(builder:flatbuffers.Builder):flatbuffers.Offset {
const offset = builder.endObject();
builder.requiredField(offset, 4) // game_id
return offset;
}
static createGameReportRequest(builder:flatbuffers.Builder, gameIdOffset:flatbuffers.Offset, turn:number):flatbuffers.Offset {
GameReportRequest.startGameReportRequest(builder);
GameReportRequest.addGameId(builder, gameIdOffset);
GameReportRequest.addTurn(builder, turn);
return GameReportRequest.endGameReportRequest(builder);
}
unpack(): GameReportRequestT {
return new GameReportRequestT(
(this.gameId() !== null ? this.gameId()!.unpack() : null),
this.turn()
);
}
unpackTo(_o: GameReportRequestT): void {
_o.gameId = (this.gameId() !== null ? this.gameId()!.unpack() : null);
_o.turn = this.turn();
}
}
export class GameReportRequestT implements flatbuffers.IGeneratedObject {
constructor(
public gameId: UUIDT|null = null,
public turn: number = 0
){}
pack(builder:flatbuffers.Builder): flatbuffers.Offset {
return GameReportRequest.createGameReportRequest(builder,
(this.gameId !== null ? this.gameId!.pack(builder) : 0),
this.turn
);
}
}
@@ -0,0 +1,130 @@
// automatically generated by the FlatBuffers compiler, do not modify
/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
import * as flatbuffers from 'flatbuffers';
export class IncomingGroup implements flatbuffers.IUnpackableObject<IncomingGroupT> {
bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0;
__init(i:number, bb:flatbuffers.ByteBuffer):IncomingGroup {
this.bb_pos = i;
this.bb = bb;
return this;
}
static getRootAsIncomingGroup(bb:flatbuffers.ByteBuffer, obj?:IncomingGroup):IncomingGroup {
return (obj || new IncomingGroup()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
static getSizePrefixedRootAsIncomingGroup(bb:flatbuffers.ByteBuffer, obj?:IncomingGroup):IncomingGroup {
bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
return (obj || new IncomingGroup()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
origin():bigint {
const offset = this.bb!.__offset(this.bb_pos, 4);
return offset ? this.bb!.readUint64(this.bb_pos + offset) : BigInt('0');
}
destination():bigint {
const offset = this.bb!.__offset(this.bb_pos, 6);
return offset ? this.bb!.readUint64(this.bb_pos + offset) : BigInt('0');
}
distance():number {
const offset = this.bb!.__offset(this.bb_pos, 8);
return offset ? this.bb!.readFloat32(this.bb_pos + offset) : 0.0;
}
speed():number {
const offset = this.bb!.__offset(this.bb_pos, 10);
return offset ? this.bb!.readFloat32(this.bb_pos + offset) : 0.0;
}
mass():number {
const offset = this.bb!.__offset(this.bb_pos, 12);
return offset ? this.bb!.readFloat32(this.bb_pos + offset) : 0.0;
}
static startIncomingGroup(builder:flatbuffers.Builder) {
builder.startObject(5);
}
static addOrigin(builder:flatbuffers.Builder, origin:bigint) {
builder.addFieldInt64(0, origin, BigInt('0'));
}
static addDestination(builder:flatbuffers.Builder, destination:bigint) {
builder.addFieldInt64(1, destination, BigInt('0'));
}
static addDistance(builder:flatbuffers.Builder, distance:number) {
builder.addFieldFloat32(2, distance, 0.0);
}
static addSpeed(builder:flatbuffers.Builder, speed:number) {
builder.addFieldFloat32(3, speed, 0.0);
}
static addMass(builder:flatbuffers.Builder, mass:number) {
builder.addFieldFloat32(4, mass, 0.0);
}
static endIncomingGroup(builder:flatbuffers.Builder):flatbuffers.Offset {
const offset = builder.endObject();
return offset;
}
static createIncomingGroup(builder:flatbuffers.Builder, origin:bigint, destination:bigint, distance:number, speed:number, mass:number):flatbuffers.Offset {
IncomingGroup.startIncomingGroup(builder);
IncomingGroup.addOrigin(builder, origin);
IncomingGroup.addDestination(builder, destination);
IncomingGroup.addDistance(builder, distance);
IncomingGroup.addSpeed(builder, speed);
IncomingGroup.addMass(builder, mass);
return IncomingGroup.endIncomingGroup(builder);
}
unpack(): IncomingGroupT {
return new IncomingGroupT(
this.origin(),
this.destination(),
this.distance(),
this.speed(),
this.mass()
);
}
unpackTo(_o: IncomingGroupT): void {
_o.origin = this.origin();
_o.destination = this.destination();
_o.distance = this.distance();
_o.speed = this.speed();
_o.mass = this.mass();
}
}
export class IncomingGroupT implements flatbuffers.IGeneratedObject {
constructor(
public origin: bigint = BigInt('0'),
public destination: bigint = BigInt('0'),
public distance: number = 0.0,
public speed: number = 0.0,
public mass: number = 0.0
){}
pack(builder:flatbuffers.Builder): flatbuffers.Offset {
return IncomingGroup.createIncomingGroup(builder,
this.origin,
this.destination,
this.distance,
this.speed,
this.mass
);
}
}
@@ -0,0 +1,167 @@
// automatically generated by the FlatBuffers compiler, do not modify
/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
import * as flatbuffers from 'flatbuffers';
export class LocalFleet implements flatbuffers.IUnpackableObject<LocalFleetT> {
bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0;
__init(i:number, bb:flatbuffers.ByteBuffer):LocalFleet {
this.bb_pos = i;
this.bb = bb;
return this;
}
static getRootAsLocalFleet(bb:flatbuffers.ByteBuffer, obj?:LocalFleet):LocalFleet {
return (obj || new LocalFleet()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
static getSizePrefixedRootAsLocalFleet(bb:flatbuffers.ByteBuffer, obj?:LocalFleet):LocalFleet {
bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
return (obj || new LocalFleet()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
name():string|null
name(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
name(optionalEncoding?:any):string|Uint8Array|null {
const offset = this.bb!.__offset(this.bb_pos, 4);
return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
}
groups():bigint {
const offset = this.bb!.__offset(this.bb_pos, 6);
return offset ? this.bb!.readUint64(this.bb_pos + offset) : BigInt('0');
}
destination():bigint {
const offset = this.bb!.__offset(this.bb_pos, 8);
return offset ? this.bb!.readUint64(this.bb_pos + offset) : BigInt('0');
}
origin():bigint|null {
const offset = this.bb!.__offset(this.bb_pos, 10);
return offset ? this.bb!.readUint64(this.bb_pos + offset) : null;
}
range():number|null {
const offset = this.bb!.__offset(this.bb_pos, 12);
return offset ? this.bb!.readFloat32(this.bb_pos + offset) : null;
}
speed():number {
const offset = this.bb!.__offset(this.bb_pos, 14);
return offset ? this.bb!.readFloat32(this.bb_pos + offset) : 0.0;
}
state():string|null
state(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
state(optionalEncoding?:any):string|Uint8Array|null {
const offset = this.bb!.__offset(this.bb_pos, 16);
return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
}
static startLocalFleet(builder:flatbuffers.Builder) {
builder.startObject(7);
}
static addName(builder:flatbuffers.Builder, nameOffset:flatbuffers.Offset) {
builder.addFieldOffset(0, nameOffset, 0);
}
static addGroups(builder:flatbuffers.Builder, groups:bigint) {
builder.addFieldInt64(1, groups, BigInt('0'));
}
static addDestination(builder:flatbuffers.Builder, destination:bigint) {
builder.addFieldInt64(2, destination, BigInt('0'));
}
static addOrigin(builder:flatbuffers.Builder, origin:bigint) {
builder.addFieldInt64(3, origin, null);
}
static addRange(builder:flatbuffers.Builder, range:number) {
builder.addFieldFloat32(4, range, null);
}
static addSpeed(builder:flatbuffers.Builder, speed:number) {
builder.addFieldFloat32(5, speed, 0.0);
}
static addState(builder:flatbuffers.Builder, stateOffset:flatbuffers.Offset) {
builder.addFieldOffset(6, stateOffset, 0);
}
static endLocalFleet(builder:flatbuffers.Builder):flatbuffers.Offset {
const offset = builder.endObject();
return offset;
}
static createLocalFleet(builder:flatbuffers.Builder, nameOffset:flatbuffers.Offset, groups:bigint, destination:bigint, origin:bigint|null, range:number|null, speed:number, stateOffset:flatbuffers.Offset):flatbuffers.Offset {
LocalFleet.startLocalFleet(builder);
LocalFleet.addName(builder, nameOffset);
LocalFleet.addGroups(builder, groups);
LocalFleet.addDestination(builder, destination);
if (origin !== null)
LocalFleet.addOrigin(builder, origin);
if (range !== null)
LocalFleet.addRange(builder, range);
LocalFleet.addSpeed(builder, speed);
LocalFleet.addState(builder, stateOffset);
return LocalFleet.endLocalFleet(builder);
}
unpack(): LocalFleetT {
return new LocalFleetT(
this.name(),
this.groups(),
this.destination(),
this.origin(),
this.range(),
this.speed(),
this.state()
);
}
unpackTo(_o: LocalFleetT): void {
_o.name = this.name();
_o.groups = this.groups();
_o.destination = this.destination();
_o.origin = this.origin();
_o.range = this.range();
_o.speed = this.speed();
_o.state = this.state();
}
}
export class LocalFleetT implements flatbuffers.IGeneratedObject {
constructor(
public name: string|Uint8Array|null = null,
public groups: bigint = BigInt('0'),
public destination: bigint = BigInt('0'),
public origin: bigint|null = null,
public range: number|null = null,
public speed: number = 0.0,
public state: string|Uint8Array|null = null
){}
pack(builder:flatbuffers.Builder): flatbuffers.Offset {
const name = (this.name !== null ? builder.createString(this.name!) : 0);
const state = (this.state !== null ? builder.createString(this.state!) : 0);
return LocalFleet.createLocalFleet(builder,
name,
this.groups,
this.destination,
this.origin,
this.range,
this.speed,
state
);
}
}
@@ -0,0 +1,262 @@
// automatically generated by the FlatBuffers compiler, do not modify
/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
import * as flatbuffers from 'flatbuffers';
import { UUID, UUIDT } from '../common/uuid.js';
import { TechEntry, TechEntryT } from './tech-entry.js';
export class LocalGroup implements flatbuffers.IUnpackableObject<LocalGroupT> {
bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0;
__init(i:number, bb:flatbuffers.ByteBuffer):LocalGroup {
this.bb_pos = i;
this.bb = bb;
return this;
}
static getRootAsLocalGroup(bb:flatbuffers.ByteBuffer, obj?:LocalGroup):LocalGroup {
return (obj || new LocalGroup()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
static getSizePrefixedRootAsLocalGroup(bb:flatbuffers.ByteBuffer, obj?:LocalGroup):LocalGroup {
bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
return (obj || new LocalGroup()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
number():bigint {
const offset = this.bb!.__offset(this.bb_pos, 4);
return offset ? this.bb!.readUint64(this.bb_pos + offset) : BigInt('0');
}
class_():string|null
class_(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
class_(optionalEncoding?:any):string|Uint8Array|null {
const offset = this.bb!.__offset(this.bb_pos, 6);
return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
}
tech(index: number, obj?:TechEntry):TechEntry|null {
const offset = this.bb!.__offset(this.bb_pos, 8);
return offset ? (obj || new TechEntry()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null;
}
techLength():number {
const offset = this.bb!.__offset(this.bb_pos, 8);
return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
}
cargo():string|null
cargo(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
cargo(optionalEncoding?:any):string|Uint8Array|null {
const offset = this.bb!.__offset(this.bb_pos, 10);
return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
}
load():number {
const offset = this.bb!.__offset(this.bb_pos, 12);
return offset ? this.bb!.readFloat32(this.bb_pos + offset) : 0.0;
}
destination():bigint {
const offset = this.bb!.__offset(this.bb_pos, 14);
return offset ? this.bb!.readUint64(this.bb_pos + offset) : BigInt('0');
}
origin():bigint|null {
const offset = this.bb!.__offset(this.bb_pos, 16);
return offset ? this.bb!.readUint64(this.bb_pos + offset) : null;
}
range():number|null {
const offset = this.bb!.__offset(this.bb_pos, 18);
return offset ? this.bb!.readFloat32(this.bb_pos + offset) : null;
}
speed():number {
const offset = this.bb!.__offset(this.bb_pos, 20);
return offset ? this.bb!.readFloat32(this.bb_pos + offset) : 0.0;
}
mass():number {
const offset = this.bb!.__offset(this.bb_pos, 22);
return offset ? this.bb!.readFloat32(this.bb_pos + offset) : 0.0;
}
id(obj?:UUID):UUID|null {
const offset = this.bb!.__offset(this.bb_pos, 24);
return offset ? (obj || new UUID()).__init(this.bb_pos + offset, this.bb!) : null;
}
state():string|null
state(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
state(optionalEncoding?:any):string|Uint8Array|null {
const offset = this.bb!.__offset(this.bb_pos, 26);
return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
}
fleet():string|null
fleet(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
fleet(optionalEncoding?:any):string|Uint8Array|null {
const offset = this.bb!.__offset(this.bb_pos, 28);
return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
}
static startLocalGroup(builder:flatbuffers.Builder) {
builder.startObject(13);
}
static addNumber(builder:flatbuffers.Builder, number:bigint) {
builder.addFieldInt64(0, number, BigInt('0'));
}
static addClass(builder:flatbuffers.Builder, class_Offset:flatbuffers.Offset) {
builder.addFieldOffset(1, class_Offset, 0);
}
static addTech(builder:flatbuffers.Builder, techOffset:flatbuffers.Offset) {
builder.addFieldOffset(2, techOffset, 0);
}
static createTechVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset {
builder.startVector(4, data.length, 4);
for (let i = data.length - 1; i >= 0; i--) {
builder.addOffset(data[i]!);
}
return builder.endVector();
}
static startTechVector(builder:flatbuffers.Builder, numElems:number) {
builder.startVector(4, numElems, 4);
}
static addCargo(builder:flatbuffers.Builder, cargoOffset:flatbuffers.Offset) {
builder.addFieldOffset(3, cargoOffset, 0);
}
static addLoad(builder:flatbuffers.Builder, load:number) {
builder.addFieldFloat32(4, load, 0.0);
}
static addDestination(builder:flatbuffers.Builder, destination:bigint) {
builder.addFieldInt64(5, destination, BigInt('0'));
}
static addOrigin(builder:flatbuffers.Builder, origin:bigint) {
builder.addFieldInt64(6, origin, null);
}
static addRange(builder:flatbuffers.Builder, range:number) {
builder.addFieldFloat32(7, range, null);
}
static addSpeed(builder:flatbuffers.Builder, speed:number) {
builder.addFieldFloat32(8, speed, 0.0);
}
static addMass(builder:flatbuffers.Builder, mass:number) {
builder.addFieldFloat32(9, mass, 0.0);
}
static addId(builder:flatbuffers.Builder, idOffset:flatbuffers.Offset) {
builder.addFieldStruct(10, idOffset, 0);
}
static addState(builder:flatbuffers.Builder, stateOffset:flatbuffers.Offset) {
builder.addFieldOffset(11, stateOffset, 0);
}
static addFleet(builder:flatbuffers.Builder, fleetOffset:flatbuffers.Offset) {
builder.addFieldOffset(12, fleetOffset, 0);
}
static endLocalGroup(builder:flatbuffers.Builder):flatbuffers.Offset {
const offset = builder.endObject();
builder.requiredField(offset, 24) // id
return offset;
}
unpack(): LocalGroupT {
return new LocalGroupT(
this.number(),
this.class_(),
this.bb!.createObjList<TechEntry, TechEntryT>(this.tech.bind(this), this.techLength()),
this.cargo(),
this.load(),
this.destination(),
this.origin(),
this.range(),
this.speed(),
this.mass(),
(this.id() !== null ? this.id()!.unpack() : null),
this.state(),
this.fleet()
);
}
unpackTo(_o: LocalGroupT): void {
_o.number = this.number();
_o.class_ = this.class_();
_o.tech = this.bb!.createObjList<TechEntry, TechEntryT>(this.tech.bind(this), this.techLength());
_o.cargo = this.cargo();
_o.load = this.load();
_o.destination = this.destination();
_o.origin = this.origin();
_o.range = this.range();
_o.speed = this.speed();
_o.mass = this.mass();
_o.id = (this.id() !== null ? this.id()!.unpack() : null);
_o.state = this.state();
_o.fleet = this.fleet();
}
}
export class LocalGroupT implements flatbuffers.IGeneratedObject {
constructor(
public number: bigint = BigInt('0'),
public class_: string|Uint8Array|null = null,
public tech: (TechEntryT)[] = [],
public cargo: string|Uint8Array|null = null,
public load: number = 0.0,
public destination: bigint = BigInt('0'),
public origin: bigint|null = null,
public range: number|null = null,
public speed: number = 0.0,
public mass: number = 0.0,
public id: UUIDT|null = null,
public state: string|Uint8Array|null = null,
public fleet: string|Uint8Array|null = null
){}
pack(builder:flatbuffers.Builder): flatbuffers.Offset {
const class_ = (this.class_ !== null ? builder.createString(this.class_!) : 0);
const tech = LocalGroup.createTechVector(builder, builder.createObjectOffsetList(this.tech));
const cargo = (this.cargo !== null ? builder.createString(this.cargo!) : 0);
const state = (this.state !== null ? builder.createString(this.state!) : 0);
const fleet = (this.fleet !== null ? builder.createString(this.fleet!) : 0);
LocalGroup.startLocalGroup(builder);
LocalGroup.addNumber(builder, this.number);
LocalGroup.addClass(builder, class_);
LocalGroup.addTech(builder, tech);
LocalGroup.addCargo(builder, cargo);
LocalGroup.addLoad(builder, this.load);
LocalGroup.addDestination(builder, this.destination);
if (this.origin !== null)
LocalGroup.addOrigin(builder, this.origin);
if (this.range !== null)
LocalGroup.addRange(builder, this.range);
LocalGroup.addSpeed(builder, this.speed);
LocalGroup.addMass(builder, this.mass);
LocalGroup.addId(builder, (this.id !== null ? this.id!.pack(builder) : 0));
LocalGroup.addState(builder, state);
LocalGroup.addFleet(builder, fleet);
return LocalGroup.endLocalGroup(builder);
}
}
@@ -0,0 +1,249 @@
// automatically generated by the FlatBuffers compiler, do not modify
/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
import * as flatbuffers from 'flatbuffers';
export class LocalPlanet implements flatbuffers.IUnpackableObject<LocalPlanetT> {
bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0;
__init(i:number, bb:flatbuffers.ByteBuffer):LocalPlanet {
this.bb_pos = i;
this.bb = bb;
return this;
}
static getRootAsLocalPlanet(bb:flatbuffers.ByteBuffer, obj?:LocalPlanet):LocalPlanet {
return (obj || new LocalPlanet()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
static getSizePrefixedRootAsLocalPlanet(bb:flatbuffers.ByteBuffer, obj?:LocalPlanet):LocalPlanet {
bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
return (obj || new LocalPlanet()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
x():number {
const offset = this.bb!.__offset(this.bb_pos, 4);
return offset ? this.bb!.readFloat32(this.bb_pos + offset) : 0.0;
}
y():number {
const offset = this.bb!.__offset(this.bb_pos, 6);
return offset ? this.bb!.readFloat32(this.bb_pos + offset) : 0.0;
}
number():bigint {
const offset = this.bb!.__offset(this.bb_pos, 8);
return offset ? this.bb!.readUint64(this.bb_pos + offset) : BigInt('0');
}
size():number {
const offset = this.bb!.__offset(this.bb_pos, 10);
return offset ? this.bb!.readFloat32(this.bb_pos + offset) : 0.0;
}
name():string|null
name(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
name(optionalEncoding?:any):string|Uint8Array|null {
const offset = this.bb!.__offset(this.bb_pos, 12);
return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
}
resources():number {
const offset = this.bb!.__offset(this.bb_pos, 14);
return offset ? this.bb!.readFloat32(this.bb_pos + offset) : 0.0;
}
capital():number {
const offset = this.bb!.__offset(this.bb_pos, 16);
return offset ? this.bb!.readFloat32(this.bb_pos + offset) : 0.0;
}
material():number {
const offset = this.bb!.__offset(this.bb_pos, 18);
return offset ? this.bb!.readFloat32(this.bb_pos + offset) : 0.0;
}
industry():number {
const offset = this.bb!.__offset(this.bb_pos, 20);
return offset ? this.bb!.readFloat32(this.bb_pos + offset) : 0.0;
}
population():number {
const offset = this.bb!.__offset(this.bb_pos, 22);
return offset ? this.bb!.readFloat32(this.bb_pos + offset) : 0.0;
}
colonists():number {
const offset = this.bb!.__offset(this.bb_pos, 24);
return offset ? this.bb!.readFloat32(this.bb_pos + offset) : 0.0;
}
production():string|null
production(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
production(optionalEncoding?:any):string|Uint8Array|null {
const offset = this.bb!.__offset(this.bb_pos, 26);
return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
}
freeIndustry():number {
const offset = this.bb!.__offset(this.bb_pos, 28);
return offset ? this.bb!.readFloat32(this.bb_pos + offset) : 0.0;
}
static startLocalPlanet(builder:flatbuffers.Builder) {
builder.startObject(13);
}
static addX(builder:flatbuffers.Builder, x:number) {
builder.addFieldFloat32(0, x, 0.0);
}
static addY(builder:flatbuffers.Builder, y:number) {
builder.addFieldFloat32(1, y, 0.0);
}
static addNumber(builder:flatbuffers.Builder, number:bigint) {
builder.addFieldInt64(2, number, BigInt('0'));
}
static addSize(builder:flatbuffers.Builder, size:number) {
builder.addFieldFloat32(3, size, 0.0);
}
static addName(builder:flatbuffers.Builder, nameOffset:flatbuffers.Offset) {
builder.addFieldOffset(4, nameOffset, 0);
}
static addResources(builder:flatbuffers.Builder, resources:number) {
builder.addFieldFloat32(5, resources, 0.0);
}
static addCapital(builder:flatbuffers.Builder, capital:number) {
builder.addFieldFloat32(6, capital, 0.0);
}
static addMaterial(builder:flatbuffers.Builder, material:number) {
builder.addFieldFloat32(7, material, 0.0);
}
static addIndustry(builder:flatbuffers.Builder, industry:number) {
builder.addFieldFloat32(8, industry, 0.0);
}
static addPopulation(builder:flatbuffers.Builder, population:number) {
builder.addFieldFloat32(9, population, 0.0);
}
static addColonists(builder:flatbuffers.Builder, colonists:number) {
builder.addFieldFloat32(10, colonists, 0.0);
}
static addProduction(builder:flatbuffers.Builder, productionOffset:flatbuffers.Offset) {
builder.addFieldOffset(11, productionOffset, 0);
}
static addFreeIndustry(builder:flatbuffers.Builder, freeIndustry:number) {
builder.addFieldFloat32(12, freeIndustry, 0.0);
}
static endLocalPlanet(builder:flatbuffers.Builder):flatbuffers.Offset {
const offset = builder.endObject();
return offset;
}
static createLocalPlanet(builder:flatbuffers.Builder, x:number, y:number, number:bigint, size:number, nameOffset:flatbuffers.Offset, resources:number, capital:number, material:number, industry:number, population:number, colonists:number, productionOffset:flatbuffers.Offset, freeIndustry:number):flatbuffers.Offset {
LocalPlanet.startLocalPlanet(builder);
LocalPlanet.addX(builder, x);
LocalPlanet.addY(builder, y);
LocalPlanet.addNumber(builder, number);
LocalPlanet.addSize(builder, size);
LocalPlanet.addName(builder, nameOffset);
LocalPlanet.addResources(builder, resources);
LocalPlanet.addCapital(builder, capital);
LocalPlanet.addMaterial(builder, material);
LocalPlanet.addIndustry(builder, industry);
LocalPlanet.addPopulation(builder, population);
LocalPlanet.addColonists(builder, colonists);
LocalPlanet.addProduction(builder, productionOffset);
LocalPlanet.addFreeIndustry(builder, freeIndustry);
return LocalPlanet.endLocalPlanet(builder);
}
unpack(): LocalPlanetT {
return new LocalPlanetT(
this.x(),
this.y(),
this.number(),
this.size(),
this.name(),
this.resources(),
this.capital(),
this.material(),
this.industry(),
this.population(),
this.colonists(),
this.production(),
this.freeIndustry()
);
}
unpackTo(_o: LocalPlanetT): void {
_o.x = this.x();
_o.y = this.y();
_o.number = this.number();
_o.size = this.size();
_o.name = this.name();
_o.resources = this.resources();
_o.capital = this.capital();
_o.material = this.material();
_o.industry = this.industry();
_o.population = this.population();
_o.colonists = this.colonists();
_o.production = this.production();
_o.freeIndustry = this.freeIndustry();
}
}
export class LocalPlanetT implements flatbuffers.IGeneratedObject {
constructor(
public x: number = 0.0,
public y: number = 0.0,
public number: bigint = BigInt('0'),
public size: number = 0.0,
public name: string|Uint8Array|null = null,
public resources: number = 0.0,
public capital: number = 0.0,
public material: number = 0.0,
public industry: number = 0.0,
public population: number = 0.0,
public colonists: number = 0.0,
public production: string|Uint8Array|null = null,
public freeIndustry: number = 0.0
){}
pack(builder:flatbuffers.Builder): flatbuffers.Offset {
const name = (this.name !== null ? builder.createString(this.name!) : 0);
const production = (this.production !== null ? builder.createString(this.production!) : 0);
return LocalPlanet.createLocalPlanet(builder,
this.x,
this.y,
this.number,
this.size,
name,
this.resources,
this.capital,
this.material,
this.industry,
this.population,
this.colonists,
production,
this.freeIndustry
);
}
}
@@ -0,0 +1,228 @@
// automatically generated by the FlatBuffers compiler, do not modify
/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
import * as flatbuffers from 'flatbuffers';
import { TechEntry, TechEntryT } from './tech-entry.js';
export class OtherGroup implements flatbuffers.IUnpackableObject<OtherGroupT> {
bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0;
__init(i:number, bb:flatbuffers.ByteBuffer):OtherGroup {
this.bb_pos = i;
this.bb = bb;
return this;
}
static getRootAsOtherGroup(bb:flatbuffers.ByteBuffer, obj?:OtherGroup):OtherGroup {
return (obj || new OtherGroup()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
static getSizePrefixedRootAsOtherGroup(bb:flatbuffers.ByteBuffer, obj?:OtherGroup):OtherGroup {
bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
return (obj || new OtherGroup()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
number():bigint {
const offset = this.bb!.__offset(this.bb_pos, 4);
return offset ? this.bb!.readUint64(this.bb_pos + offset) : BigInt('0');
}
class_():string|null
class_(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
class_(optionalEncoding?:any):string|Uint8Array|null {
const offset = this.bb!.__offset(this.bb_pos, 6);
return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
}
tech(index: number, obj?:TechEntry):TechEntry|null {
const offset = this.bb!.__offset(this.bb_pos, 8);
return offset ? (obj || new TechEntry()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null;
}
techLength():number {
const offset = this.bb!.__offset(this.bb_pos, 8);
return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
}
cargo():string|null
cargo(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
cargo(optionalEncoding?:any):string|Uint8Array|null {
const offset = this.bb!.__offset(this.bb_pos, 10);
return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
}
load():number {
const offset = this.bb!.__offset(this.bb_pos, 12);
return offset ? this.bb!.readFloat32(this.bb_pos + offset) : 0.0;
}
destination():bigint {
const offset = this.bb!.__offset(this.bb_pos, 14);
return offset ? this.bb!.readUint64(this.bb_pos + offset) : BigInt('0');
}
origin():bigint|null {
const offset = this.bb!.__offset(this.bb_pos, 16);
return offset ? this.bb!.readUint64(this.bb_pos + offset) : null;
}
range():number|null {
const offset = this.bb!.__offset(this.bb_pos, 18);
return offset ? this.bb!.readFloat32(this.bb_pos + offset) : null;
}
speed():number {
const offset = this.bb!.__offset(this.bb_pos, 20);
return offset ? this.bb!.readFloat32(this.bb_pos + offset) : 0.0;
}
mass():number {
const offset = this.bb!.__offset(this.bb_pos, 22);
return offset ? this.bb!.readFloat32(this.bb_pos + offset) : 0.0;
}
static startOtherGroup(builder:flatbuffers.Builder) {
builder.startObject(10);
}
static addNumber(builder:flatbuffers.Builder, number:bigint) {
builder.addFieldInt64(0, number, BigInt('0'));
}
static addClass(builder:flatbuffers.Builder, class_Offset:flatbuffers.Offset) {
builder.addFieldOffset(1, class_Offset, 0);
}
static addTech(builder:flatbuffers.Builder, techOffset:flatbuffers.Offset) {
builder.addFieldOffset(2, techOffset, 0);
}
static createTechVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset {
builder.startVector(4, data.length, 4);
for (let i = data.length - 1; i >= 0; i--) {
builder.addOffset(data[i]!);
}
return builder.endVector();
}
static startTechVector(builder:flatbuffers.Builder, numElems:number) {
builder.startVector(4, numElems, 4);
}
static addCargo(builder:flatbuffers.Builder, cargoOffset:flatbuffers.Offset) {
builder.addFieldOffset(3, cargoOffset, 0);
}
static addLoad(builder:flatbuffers.Builder, load:number) {
builder.addFieldFloat32(4, load, 0.0);
}
static addDestination(builder:flatbuffers.Builder, destination:bigint) {
builder.addFieldInt64(5, destination, BigInt('0'));
}
static addOrigin(builder:flatbuffers.Builder, origin:bigint) {
builder.addFieldInt64(6, origin, null);
}
static addRange(builder:flatbuffers.Builder, range:number) {
builder.addFieldFloat32(7, range, null);
}
static addSpeed(builder:flatbuffers.Builder, speed:number) {
builder.addFieldFloat32(8, speed, 0.0);
}
static addMass(builder:flatbuffers.Builder, mass:number) {
builder.addFieldFloat32(9, mass, 0.0);
}
static endOtherGroup(builder:flatbuffers.Builder):flatbuffers.Offset {
const offset = builder.endObject();
return offset;
}
static createOtherGroup(builder:flatbuffers.Builder, number:bigint, class_Offset:flatbuffers.Offset, techOffset:flatbuffers.Offset, cargoOffset:flatbuffers.Offset, load:number, destination:bigint, origin:bigint|null, range:number|null, speed:number, mass:number):flatbuffers.Offset {
OtherGroup.startOtherGroup(builder);
OtherGroup.addNumber(builder, number);
OtherGroup.addClass(builder, class_Offset);
OtherGroup.addTech(builder, techOffset);
OtherGroup.addCargo(builder, cargoOffset);
OtherGroup.addLoad(builder, load);
OtherGroup.addDestination(builder, destination);
if (origin !== null)
OtherGroup.addOrigin(builder, origin);
if (range !== null)
OtherGroup.addRange(builder, range);
OtherGroup.addSpeed(builder, speed);
OtherGroup.addMass(builder, mass);
return OtherGroup.endOtherGroup(builder);
}
unpack(): OtherGroupT {
return new OtherGroupT(
this.number(),
this.class_(),
this.bb!.createObjList<TechEntry, TechEntryT>(this.tech.bind(this), this.techLength()),
this.cargo(),
this.load(),
this.destination(),
this.origin(),
this.range(),
this.speed(),
this.mass()
);
}
unpackTo(_o: OtherGroupT): void {
_o.number = this.number();
_o.class_ = this.class_();
_o.tech = this.bb!.createObjList<TechEntry, TechEntryT>(this.tech.bind(this), this.techLength());
_o.cargo = this.cargo();
_o.load = this.load();
_o.destination = this.destination();
_o.origin = this.origin();
_o.range = this.range();
_o.speed = this.speed();
_o.mass = this.mass();
}
}
export class OtherGroupT implements flatbuffers.IGeneratedObject {
constructor(
public number: bigint = BigInt('0'),
public class_: string|Uint8Array|null = null,
public tech: (TechEntryT)[] = [],
public cargo: string|Uint8Array|null = null,
public load: number = 0.0,
public destination: bigint = BigInt('0'),
public origin: bigint|null = null,
public range: number|null = null,
public speed: number = 0.0,
public mass: number = 0.0
){}
pack(builder:flatbuffers.Builder): flatbuffers.Offset {
const class_ = (this.class_ !== null ? builder.createString(this.class_!) : 0);
const tech = OtherGroup.createTechVector(builder, builder.createObjectOffsetList(this.tech));
const cargo = (this.cargo !== null ? builder.createString(this.cargo!) : 0);
return OtherGroup.createOtherGroup(builder,
this.number,
class_,
tech,
cargo,
this.load,
this.destination,
this.origin,
this.range,
this.speed,
this.mass
);
}
}
@@ -0,0 +1,266 @@
// automatically generated by the FlatBuffers compiler, do not modify
/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
import * as flatbuffers from 'flatbuffers';
export class OtherPlanet implements flatbuffers.IUnpackableObject<OtherPlanetT> {
bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0;
__init(i:number, bb:flatbuffers.ByteBuffer):OtherPlanet {
this.bb_pos = i;
this.bb = bb;
return this;
}
static getRootAsOtherPlanet(bb:flatbuffers.ByteBuffer, obj?:OtherPlanet):OtherPlanet {
return (obj || new OtherPlanet()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
static getSizePrefixedRootAsOtherPlanet(bb:flatbuffers.ByteBuffer, obj?:OtherPlanet):OtherPlanet {
bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
return (obj || new OtherPlanet()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
owner():string|null
owner(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
owner(optionalEncoding?:any):string|Uint8Array|null {
const offset = this.bb!.__offset(this.bb_pos, 4);
return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
}
x():number {
const offset = this.bb!.__offset(this.bb_pos, 6);
return offset ? this.bb!.readFloat32(this.bb_pos + offset) : 0.0;
}
y():number {
const offset = this.bb!.__offset(this.bb_pos, 8);
return offset ? this.bb!.readFloat32(this.bb_pos + offset) : 0.0;
}
number():bigint {
const offset = this.bb!.__offset(this.bb_pos, 10);
return offset ? this.bb!.readUint64(this.bb_pos + offset) : BigInt('0');
}
size():number {
const offset = this.bb!.__offset(this.bb_pos, 12);
return offset ? this.bb!.readFloat32(this.bb_pos + offset) : 0.0;
}
name():string|null
name(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
name(optionalEncoding?:any):string|Uint8Array|null {
const offset = this.bb!.__offset(this.bb_pos, 14);
return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
}
resources():number {
const offset = this.bb!.__offset(this.bb_pos, 16);
return offset ? this.bb!.readFloat32(this.bb_pos + offset) : 0.0;
}
capital():number {
const offset = this.bb!.__offset(this.bb_pos, 18);
return offset ? this.bb!.readFloat32(this.bb_pos + offset) : 0.0;
}
material():number {
const offset = this.bb!.__offset(this.bb_pos, 20);
return offset ? this.bb!.readFloat32(this.bb_pos + offset) : 0.0;
}
industry():number {
const offset = this.bb!.__offset(this.bb_pos, 22);
return offset ? this.bb!.readFloat32(this.bb_pos + offset) : 0.0;
}
population():number {
const offset = this.bb!.__offset(this.bb_pos, 24);
return offset ? this.bb!.readFloat32(this.bb_pos + offset) : 0.0;
}
colonists():number {
const offset = this.bb!.__offset(this.bb_pos, 26);
return offset ? this.bb!.readFloat32(this.bb_pos + offset) : 0.0;
}
production():string|null
production(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
production(optionalEncoding?:any):string|Uint8Array|null {
const offset = this.bb!.__offset(this.bb_pos, 28);
return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
}
freeIndustry():number {
const offset = this.bb!.__offset(this.bb_pos, 30);
return offset ? this.bb!.readFloat32(this.bb_pos + offset) : 0.0;
}
static startOtherPlanet(builder:flatbuffers.Builder) {
builder.startObject(14);
}
static addOwner(builder:flatbuffers.Builder, ownerOffset:flatbuffers.Offset) {
builder.addFieldOffset(0, ownerOffset, 0);
}
static addX(builder:flatbuffers.Builder, x:number) {
builder.addFieldFloat32(1, x, 0.0);
}
static addY(builder:flatbuffers.Builder, y:number) {
builder.addFieldFloat32(2, y, 0.0);
}
static addNumber(builder:flatbuffers.Builder, number:bigint) {
builder.addFieldInt64(3, number, BigInt('0'));
}
static addSize(builder:flatbuffers.Builder, size:number) {
builder.addFieldFloat32(4, size, 0.0);
}
static addName(builder:flatbuffers.Builder, nameOffset:flatbuffers.Offset) {
builder.addFieldOffset(5, nameOffset, 0);
}
static addResources(builder:flatbuffers.Builder, resources:number) {
builder.addFieldFloat32(6, resources, 0.0);
}
static addCapital(builder:flatbuffers.Builder, capital:number) {
builder.addFieldFloat32(7, capital, 0.0);
}
static addMaterial(builder:flatbuffers.Builder, material:number) {
builder.addFieldFloat32(8, material, 0.0);
}
static addIndustry(builder:flatbuffers.Builder, industry:number) {
builder.addFieldFloat32(9, industry, 0.0);
}
static addPopulation(builder:flatbuffers.Builder, population:number) {
builder.addFieldFloat32(10, population, 0.0);
}
static addColonists(builder:flatbuffers.Builder, colonists:number) {
builder.addFieldFloat32(11, colonists, 0.0);
}
static addProduction(builder:flatbuffers.Builder, productionOffset:flatbuffers.Offset) {
builder.addFieldOffset(12, productionOffset, 0);
}
static addFreeIndustry(builder:flatbuffers.Builder, freeIndustry:number) {
builder.addFieldFloat32(13, freeIndustry, 0.0);
}
static endOtherPlanet(builder:flatbuffers.Builder):flatbuffers.Offset {
const offset = builder.endObject();
return offset;
}
static createOtherPlanet(builder:flatbuffers.Builder, ownerOffset:flatbuffers.Offset, x:number, y:number, number:bigint, size:number, nameOffset:flatbuffers.Offset, resources:number, capital:number, material:number, industry:number, population:number, colonists:number, productionOffset:flatbuffers.Offset, freeIndustry:number):flatbuffers.Offset {
OtherPlanet.startOtherPlanet(builder);
OtherPlanet.addOwner(builder, ownerOffset);
OtherPlanet.addX(builder, x);
OtherPlanet.addY(builder, y);
OtherPlanet.addNumber(builder, number);
OtherPlanet.addSize(builder, size);
OtherPlanet.addName(builder, nameOffset);
OtherPlanet.addResources(builder, resources);
OtherPlanet.addCapital(builder, capital);
OtherPlanet.addMaterial(builder, material);
OtherPlanet.addIndustry(builder, industry);
OtherPlanet.addPopulation(builder, population);
OtherPlanet.addColonists(builder, colonists);
OtherPlanet.addProduction(builder, productionOffset);
OtherPlanet.addFreeIndustry(builder, freeIndustry);
return OtherPlanet.endOtherPlanet(builder);
}
unpack(): OtherPlanetT {
return new OtherPlanetT(
this.owner(),
this.x(),
this.y(),
this.number(),
this.size(),
this.name(),
this.resources(),
this.capital(),
this.material(),
this.industry(),
this.population(),
this.colonists(),
this.production(),
this.freeIndustry()
);
}
unpackTo(_o: OtherPlanetT): void {
_o.owner = this.owner();
_o.x = this.x();
_o.y = this.y();
_o.number = this.number();
_o.size = this.size();
_o.name = this.name();
_o.resources = this.resources();
_o.capital = this.capital();
_o.material = this.material();
_o.industry = this.industry();
_o.population = this.population();
_o.colonists = this.colonists();
_o.production = this.production();
_o.freeIndustry = this.freeIndustry();
}
}
export class OtherPlanetT implements flatbuffers.IGeneratedObject {
constructor(
public owner: string|Uint8Array|null = null,
public x: number = 0.0,
public y: number = 0.0,
public number: bigint = BigInt('0'),
public size: number = 0.0,
public name: string|Uint8Array|null = null,
public resources: number = 0.0,
public capital: number = 0.0,
public material: number = 0.0,
public industry: number = 0.0,
public population: number = 0.0,
public colonists: number = 0.0,
public production: string|Uint8Array|null = null,
public freeIndustry: number = 0.0
){}
pack(builder:flatbuffers.Builder): flatbuffers.Offset {
const owner = (this.owner !== null ? builder.createString(this.owner!) : 0);
const name = (this.name !== null ? builder.createString(this.name!) : 0);
const production = (this.production !== null ? builder.createString(this.production!) : 0);
return OtherPlanet.createOtherPlanet(builder,
owner,
this.x,
this.y,
this.number,
this.size,
name,
this.resources,
this.capital,
this.material,
this.industry,
this.population,
this.colonists,
production,
this.freeIndustry
);
}
}
@@ -0,0 +1,151 @@
// automatically generated by the FlatBuffers compiler, do not modify
/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
import * as flatbuffers from 'flatbuffers';
export class OtherScience implements flatbuffers.IUnpackableObject<OtherScienceT> {
bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0;
__init(i:number, bb:flatbuffers.ByteBuffer):OtherScience {
this.bb_pos = i;
this.bb = bb;
return this;
}
static getRootAsOtherScience(bb:flatbuffers.ByteBuffer, obj?:OtherScience):OtherScience {
return (obj || new OtherScience()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
static getSizePrefixedRootAsOtherScience(bb:flatbuffers.ByteBuffer, obj?:OtherScience):OtherScience {
bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
return (obj || new OtherScience()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
race():string|null
race(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
race(optionalEncoding?:any):string|Uint8Array|null {
const offset = this.bb!.__offset(this.bb_pos, 4);
return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
}
name():string|null
name(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
name(optionalEncoding?:any):string|Uint8Array|null {
const offset = this.bb!.__offset(this.bb_pos, 6);
return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
}
drive():number {
const offset = this.bb!.__offset(this.bb_pos, 8);
return offset ? this.bb!.readFloat32(this.bb_pos + offset) : 0.0;
}
weapons():number {
const offset = this.bb!.__offset(this.bb_pos, 10);
return offset ? this.bb!.readFloat32(this.bb_pos + offset) : 0.0;
}
shields():number {
const offset = this.bb!.__offset(this.bb_pos, 12);
return offset ? this.bb!.readFloat32(this.bb_pos + offset) : 0.0;
}
cargo():number {
const offset = this.bb!.__offset(this.bb_pos, 14);
return offset ? this.bb!.readFloat32(this.bb_pos + offset) : 0.0;
}
static startOtherScience(builder:flatbuffers.Builder) {
builder.startObject(6);
}
static addRace(builder:flatbuffers.Builder, raceOffset:flatbuffers.Offset) {
builder.addFieldOffset(0, raceOffset, 0);
}
static addName(builder:flatbuffers.Builder, nameOffset:flatbuffers.Offset) {
builder.addFieldOffset(1, nameOffset, 0);
}
static addDrive(builder:flatbuffers.Builder, drive:number) {
builder.addFieldFloat32(2, drive, 0.0);
}
static addWeapons(builder:flatbuffers.Builder, weapons:number) {
builder.addFieldFloat32(3, weapons, 0.0);
}
static addShields(builder:flatbuffers.Builder, shields:number) {
builder.addFieldFloat32(4, shields, 0.0);
}
static addCargo(builder:flatbuffers.Builder, cargo:number) {
builder.addFieldFloat32(5, cargo, 0.0);
}
static endOtherScience(builder:flatbuffers.Builder):flatbuffers.Offset {
const offset = builder.endObject();
return offset;
}
static createOtherScience(builder:flatbuffers.Builder, raceOffset:flatbuffers.Offset, nameOffset:flatbuffers.Offset, drive:number, weapons:number, shields:number, cargo:number):flatbuffers.Offset {
OtherScience.startOtherScience(builder);
OtherScience.addRace(builder, raceOffset);
OtherScience.addName(builder, nameOffset);
OtherScience.addDrive(builder, drive);
OtherScience.addWeapons(builder, weapons);
OtherScience.addShields(builder, shields);
OtherScience.addCargo(builder, cargo);
return OtherScience.endOtherScience(builder);
}
unpack(): OtherScienceT {
return new OtherScienceT(
this.race(),
this.name(),
this.drive(),
this.weapons(),
this.shields(),
this.cargo()
);
}
unpackTo(_o: OtherScienceT): void {
_o.race = this.race();
_o.name = this.name();
_o.drive = this.drive();
_o.weapons = this.weapons();
_o.shields = this.shields();
_o.cargo = this.cargo();
}
}
export class OtherScienceT implements flatbuffers.IGeneratedObject {
constructor(
public race: string|Uint8Array|null = null,
public name: string|Uint8Array|null = null,
public drive: number = 0.0,
public weapons: number = 0.0,
public shields: number = 0.0,
public cargo: number = 0.0
){}
pack(builder:flatbuffers.Builder): flatbuffers.Offset {
const race = (this.race !== null ? builder.createString(this.race!) : 0);
const name = (this.name !== null ? builder.createString(this.name!) : 0);
return OtherScience.createOtherScience(builder,
race,
name,
this.drive,
this.weapons,
this.shields,
this.cargo
);
}
}
@@ -0,0 +1,179 @@
// automatically generated by the FlatBuffers compiler, do not modify
/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
import * as flatbuffers from 'flatbuffers';
export class OthersShipClass implements flatbuffers.IUnpackableObject<OthersShipClassT> {
bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0;
__init(i:number, bb:flatbuffers.ByteBuffer):OthersShipClass {
this.bb_pos = i;
this.bb = bb;
return this;
}
static getRootAsOthersShipClass(bb:flatbuffers.ByteBuffer, obj?:OthersShipClass):OthersShipClass {
return (obj || new OthersShipClass()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
static getSizePrefixedRootAsOthersShipClass(bb:flatbuffers.ByteBuffer, obj?:OthersShipClass):OthersShipClass {
bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
return (obj || new OthersShipClass()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
race():string|null
race(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
race(optionalEncoding?:any):string|Uint8Array|null {
const offset = this.bb!.__offset(this.bb_pos, 4);
return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
}
name():string|null
name(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
name(optionalEncoding?:any):string|Uint8Array|null {
const offset = this.bb!.__offset(this.bb_pos, 6);
return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
}
drive():number {
const offset = this.bb!.__offset(this.bb_pos, 8);
return offset ? this.bb!.readFloat32(this.bb_pos + offset) : 0.0;
}
armament():bigint {
const offset = this.bb!.__offset(this.bb_pos, 10);
return offset ? this.bb!.readUint64(this.bb_pos + offset) : BigInt('0');
}
weapons():number {
const offset = this.bb!.__offset(this.bb_pos, 12);
return offset ? this.bb!.readFloat32(this.bb_pos + offset) : 0.0;
}
shields():number {
const offset = this.bb!.__offset(this.bb_pos, 14);
return offset ? this.bb!.readFloat32(this.bb_pos + offset) : 0.0;
}
cargo():number {
const offset = this.bb!.__offset(this.bb_pos, 16);
return offset ? this.bb!.readFloat32(this.bb_pos + offset) : 0.0;
}
mass():number {
const offset = this.bb!.__offset(this.bb_pos, 18);
return offset ? this.bb!.readFloat32(this.bb_pos + offset) : 0.0;
}
static startOthersShipClass(builder:flatbuffers.Builder) {
builder.startObject(8);
}
static addRace(builder:flatbuffers.Builder, raceOffset:flatbuffers.Offset) {
builder.addFieldOffset(0, raceOffset, 0);
}
static addName(builder:flatbuffers.Builder, nameOffset:flatbuffers.Offset) {
builder.addFieldOffset(1, nameOffset, 0);
}
static addDrive(builder:flatbuffers.Builder, drive:number) {
builder.addFieldFloat32(2, drive, 0.0);
}
static addArmament(builder:flatbuffers.Builder, armament:bigint) {
builder.addFieldInt64(3, armament, BigInt('0'));
}
static addWeapons(builder:flatbuffers.Builder, weapons:number) {
builder.addFieldFloat32(4, weapons, 0.0);
}
static addShields(builder:flatbuffers.Builder, shields:number) {
builder.addFieldFloat32(5, shields, 0.0);
}
static addCargo(builder:flatbuffers.Builder, cargo:number) {
builder.addFieldFloat32(6, cargo, 0.0);
}
static addMass(builder:flatbuffers.Builder, mass:number) {
builder.addFieldFloat32(7, mass, 0.0);
}
static endOthersShipClass(builder:flatbuffers.Builder):flatbuffers.Offset {
const offset = builder.endObject();
return offset;
}
static createOthersShipClass(builder:flatbuffers.Builder, raceOffset:flatbuffers.Offset, nameOffset:flatbuffers.Offset, drive:number, armament:bigint, weapons:number, shields:number, cargo:number, mass:number):flatbuffers.Offset {
OthersShipClass.startOthersShipClass(builder);
OthersShipClass.addRace(builder, raceOffset);
OthersShipClass.addName(builder, nameOffset);
OthersShipClass.addDrive(builder, drive);
OthersShipClass.addArmament(builder, armament);
OthersShipClass.addWeapons(builder, weapons);
OthersShipClass.addShields(builder, shields);
OthersShipClass.addCargo(builder, cargo);
OthersShipClass.addMass(builder, mass);
return OthersShipClass.endOthersShipClass(builder);
}
unpack(): OthersShipClassT {
return new OthersShipClassT(
this.race(),
this.name(),
this.drive(),
this.armament(),
this.weapons(),
this.shields(),
this.cargo(),
this.mass()
);
}
unpackTo(_o: OthersShipClassT): void {
_o.race = this.race();
_o.name = this.name();
_o.drive = this.drive();
_o.armament = this.armament();
_o.weapons = this.weapons();
_o.shields = this.shields();
_o.cargo = this.cargo();
_o.mass = this.mass();
}
}
export class OthersShipClassT implements flatbuffers.IGeneratedObject {
constructor(
public race: string|Uint8Array|null = null,
public name: string|Uint8Array|null = null,
public drive: number = 0.0,
public armament: bigint = BigInt('0'),
public weapons: number = 0.0,
public shields: number = 0.0,
public cargo: number = 0.0,
public mass: number = 0.0
){}
pack(builder:flatbuffers.Builder): flatbuffers.Offset {
const race = (this.race !== null ? builder.createString(this.race!) : 0);
const name = (this.name !== null ? builder.createString(this.name!) : 0);
return OthersShipClass.createOthersShipClass(builder,
race,
name,
this.drive,
this.armament,
this.weapons,
this.shields,
this.cargo,
this.mass
);
}
}
@@ -0,0 +1,221 @@
// automatically generated by the FlatBuffers compiler, do not modify
/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
import * as flatbuffers from 'flatbuffers';
export class Player implements flatbuffers.IUnpackableObject<PlayerT> {
bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0;
__init(i:number, bb:flatbuffers.ByteBuffer):Player {
this.bb_pos = i;
this.bb = bb;
return this;
}
static getRootAsPlayer(bb:flatbuffers.ByteBuffer, obj?:Player):Player {
return (obj || new Player()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
static getSizePrefixedRootAsPlayer(bb:flatbuffers.ByteBuffer, obj?:Player):Player {
bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
return (obj || new Player()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
name():string|null
name(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
name(optionalEncoding?:any):string|Uint8Array|null {
const offset = this.bb!.__offset(this.bb_pos, 4);
return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
}
drive():number {
const offset = this.bb!.__offset(this.bb_pos, 6);
return offset ? this.bb!.readFloat32(this.bb_pos + offset) : 0.0;
}
weapons():number {
const offset = this.bb!.__offset(this.bb_pos, 8);
return offset ? this.bb!.readFloat32(this.bb_pos + offset) : 0.0;
}
shields():number {
const offset = this.bb!.__offset(this.bb_pos, 10);
return offset ? this.bb!.readFloat32(this.bb_pos + offset) : 0.0;
}
cargo():number {
const offset = this.bb!.__offset(this.bb_pos, 12);
return offset ? this.bb!.readFloat32(this.bb_pos + offset) : 0.0;
}
population():number {
const offset = this.bb!.__offset(this.bb_pos, 14);
return offset ? this.bb!.readFloat32(this.bb_pos + offset) : 0.0;
}
industry():number {
const offset = this.bb!.__offset(this.bb_pos, 16);
return offset ? this.bb!.readFloat32(this.bb_pos + offset) : 0.0;
}
planets():number {
const offset = this.bb!.__offset(this.bb_pos, 18);
return offset ? this.bb!.readUint16(this.bb_pos + offset) : 0;
}
relation():string|null
relation(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
relation(optionalEncoding?:any):string|Uint8Array|null {
const offset = this.bb!.__offset(this.bb_pos, 20);
return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
}
votes():number {
const offset = this.bb!.__offset(this.bb_pos, 22);
return offset ? this.bb!.readFloat32(this.bb_pos + offset) : 0.0;
}
extinct():boolean {
const offset = this.bb!.__offset(this.bb_pos, 24);
return offset ? !!this.bb!.readInt8(this.bb_pos + offset) : false;
}
static startPlayer(builder:flatbuffers.Builder) {
builder.startObject(11);
}
static addName(builder:flatbuffers.Builder, nameOffset:flatbuffers.Offset) {
builder.addFieldOffset(0, nameOffset, 0);
}
static addDrive(builder:flatbuffers.Builder, drive:number) {
builder.addFieldFloat32(1, drive, 0.0);
}
static addWeapons(builder:flatbuffers.Builder, weapons:number) {
builder.addFieldFloat32(2, weapons, 0.0);
}
static addShields(builder:flatbuffers.Builder, shields:number) {
builder.addFieldFloat32(3, shields, 0.0);
}
static addCargo(builder:flatbuffers.Builder, cargo:number) {
builder.addFieldFloat32(4, cargo, 0.0);
}
static addPopulation(builder:flatbuffers.Builder, population:number) {
builder.addFieldFloat32(5, population, 0.0);
}
static addIndustry(builder:flatbuffers.Builder, industry:number) {
builder.addFieldFloat32(6, industry, 0.0);
}
static addPlanets(builder:flatbuffers.Builder, planets:number) {
builder.addFieldInt16(7, planets, 0);
}
static addRelation(builder:flatbuffers.Builder, relationOffset:flatbuffers.Offset) {
builder.addFieldOffset(8, relationOffset, 0);
}
static addVotes(builder:flatbuffers.Builder, votes:number) {
builder.addFieldFloat32(9, votes, 0.0);
}
static addExtinct(builder:flatbuffers.Builder, extinct:boolean) {
builder.addFieldInt8(10, +extinct, +false);
}
static endPlayer(builder:flatbuffers.Builder):flatbuffers.Offset {
const offset = builder.endObject();
return offset;
}
static createPlayer(builder:flatbuffers.Builder, nameOffset:flatbuffers.Offset, drive:number, weapons:number, shields:number, cargo:number, population:number, industry:number, planets:number, relationOffset:flatbuffers.Offset, votes:number, extinct:boolean):flatbuffers.Offset {
Player.startPlayer(builder);
Player.addName(builder, nameOffset);
Player.addDrive(builder, drive);
Player.addWeapons(builder, weapons);
Player.addShields(builder, shields);
Player.addCargo(builder, cargo);
Player.addPopulation(builder, population);
Player.addIndustry(builder, industry);
Player.addPlanets(builder, planets);
Player.addRelation(builder, relationOffset);
Player.addVotes(builder, votes);
Player.addExtinct(builder, extinct);
return Player.endPlayer(builder);
}
unpack(): PlayerT {
return new PlayerT(
this.name(),
this.drive(),
this.weapons(),
this.shields(),
this.cargo(),
this.population(),
this.industry(),
this.planets(),
this.relation(),
this.votes(),
this.extinct()
);
}
unpackTo(_o: PlayerT): void {
_o.name = this.name();
_o.drive = this.drive();
_o.weapons = this.weapons();
_o.shields = this.shields();
_o.cargo = this.cargo();
_o.population = this.population();
_o.industry = this.industry();
_o.planets = this.planets();
_o.relation = this.relation();
_o.votes = this.votes();
_o.extinct = this.extinct();
}
}
export class PlayerT implements flatbuffers.IGeneratedObject {
constructor(
public name: string|Uint8Array|null = null,
public drive: number = 0.0,
public weapons: number = 0.0,
public shields: number = 0.0,
public cargo: number = 0.0,
public population: number = 0.0,
public industry: number = 0.0,
public planets: number = 0,
public relation: string|Uint8Array|null = null,
public votes: number = 0.0,
public extinct: boolean = false
){}
pack(builder:flatbuffers.Builder): flatbuffers.Offset {
const name = (this.name !== null ? builder.createString(this.name!) : 0);
const relation = (this.relation !== null ? builder.createString(this.relation!) : 0);
return Player.createPlayer(builder,
name,
this.drive,
this.weapons,
this.shields,
this.cargo,
this.population,
this.industry,
this.planets,
relation,
this.votes,
this.extinct
);
}
}
@@ -0,0 +1,773 @@
// automatically generated by the FlatBuffers compiler, do not modify
/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
import * as flatbuffers from 'flatbuffers';
import { UUID, UUIDT } from '../common/uuid.js';
import { Bombing, BombingT } from './bombing.js';
import { IncomingGroup, IncomingGroupT } from './incoming-group.js';
import { LocalFleet, LocalFleetT } from './local-fleet.js';
import { LocalGroup, LocalGroupT } from './local-group.js';
import { LocalPlanet, LocalPlanetT } from './local-planet.js';
import { OtherGroup, OtherGroupT } from './other-group.js';
import { OtherPlanet, OtherPlanetT } from './other-planet.js';
import { OtherScience, OtherScienceT } from './other-science.js';
import { OthersShipClass, OthersShipClassT } from './others-ship-class.js';
import { Player, PlayerT } from './player.js';
import { Route, RouteT } from './route.js';
import { Science, ScienceT } from './science.js';
import { ShipClass, ShipClassT } from './ship-class.js';
import { ShipProduction, ShipProductionT } from './ship-production.js';
import { UnidentifiedGroup, UnidentifiedGroupT } from './unidentified-group.js';
import { UnidentifiedPlanet, UnidentifiedPlanetT } from './unidentified-planet.js';
import { UninhabitedPlanet, UninhabitedPlanetT } from './uninhabited-planet.js';
export class Report implements flatbuffers.IUnpackableObject<ReportT> {
bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0;
__init(i:number, bb:flatbuffers.ByteBuffer):Report {
this.bb_pos = i;
this.bb = bb;
return this;
}
static getRootAsReport(bb:flatbuffers.ByteBuffer, obj?:Report):Report {
return (obj || new Report()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
static getSizePrefixedRootAsReport(bb:flatbuffers.ByteBuffer, obj?:Report):Report {
bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
return (obj || new Report()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
version():bigint {
const offset = this.bb!.__offset(this.bb_pos, 4);
return offset ? this.bb!.readUint64(this.bb_pos + offset) : BigInt('0');
}
turn():bigint {
const offset = this.bb!.__offset(this.bb_pos, 6);
return offset ? this.bb!.readUint64(this.bb_pos + offset) : BigInt('0');
}
width():number {
const offset = this.bb!.__offset(this.bb_pos, 8);
return offset ? this.bb!.readUint32(this.bb_pos + offset) : 0;
}
height():number {
const offset = this.bb!.__offset(this.bb_pos, 10);
return offset ? this.bb!.readUint32(this.bb_pos + offset) : 0;
}
planetCount():number {
const offset = this.bb!.__offset(this.bb_pos, 12);
return offset ? this.bb!.readUint32(this.bb_pos + offset) : 0;
}
race():string|null
race(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
race(optionalEncoding?:any):string|Uint8Array|null {
const offset = this.bb!.__offset(this.bb_pos, 14);
return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
}
votes():number {
const offset = this.bb!.__offset(this.bb_pos, 16);
return offset ? this.bb!.readFloat32(this.bb_pos + offset) : 0.0;
}
voteFor():string|null
voteFor(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
voteFor(optionalEncoding?:any):string|Uint8Array|null {
const offset = this.bb!.__offset(this.bb_pos, 18);
return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
}
player(index: number, obj?:Player):Player|null {
const offset = this.bb!.__offset(this.bb_pos, 20);
return offset ? (obj || new Player()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null;
}
playerLength():number {
const offset = this.bb!.__offset(this.bb_pos, 20);
return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
}
localScience(index: number, obj?:Science):Science|null {
const offset = this.bb!.__offset(this.bb_pos, 22);
return offset ? (obj || new Science()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null;
}
localScienceLength():number {
const offset = this.bb!.__offset(this.bb_pos, 22);
return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
}
otherScience(index: number, obj?:OtherScience):OtherScience|null {
const offset = this.bb!.__offset(this.bb_pos, 24);
return offset ? (obj || new OtherScience()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null;
}
otherScienceLength():number {
const offset = this.bb!.__offset(this.bb_pos, 24);
return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
}
localShipClass(index: number, obj?:ShipClass):ShipClass|null {
const offset = this.bb!.__offset(this.bb_pos, 26);
return offset ? (obj || new ShipClass()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null;
}
localShipClassLength():number {
const offset = this.bb!.__offset(this.bb_pos, 26);
return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
}
otherShipClass(index: number, obj?:OthersShipClass):OthersShipClass|null {
const offset = this.bb!.__offset(this.bb_pos, 28);
return offset ? (obj || new OthersShipClass()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null;
}
otherShipClassLength():number {
const offset = this.bb!.__offset(this.bb_pos, 28);
return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
}
battle(index: number, obj?:UUID):UUID|null {
const offset = this.bb!.__offset(this.bb_pos, 30);
return offset ? (obj || new UUID()).__init(this.bb!.__vector(this.bb_pos + offset) + index * 16, this.bb!) : null;
}
battleLength():number {
const offset = this.bb!.__offset(this.bb_pos, 30);
return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
}
bombing(index: number, obj?:Bombing):Bombing|null {
const offset = this.bb!.__offset(this.bb_pos, 32);
return offset ? (obj || new Bombing()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null;
}
bombingLength():number {
const offset = this.bb!.__offset(this.bb_pos, 32);
return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
}
incomingGroup(index: number, obj?:IncomingGroup):IncomingGroup|null {
const offset = this.bb!.__offset(this.bb_pos, 34);
return offset ? (obj || new IncomingGroup()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null;
}
incomingGroupLength():number {
const offset = this.bb!.__offset(this.bb_pos, 34);
return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
}
localPlanet(index: number, obj?:LocalPlanet):LocalPlanet|null {
const offset = this.bb!.__offset(this.bb_pos, 36);
return offset ? (obj || new LocalPlanet()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null;
}
localPlanetLength():number {
const offset = this.bb!.__offset(this.bb_pos, 36);
return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
}
shipProduction(index: number, obj?:ShipProduction):ShipProduction|null {
const offset = this.bb!.__offset(this.bb_pos, 38);
return offset ? (obj || new ShipProduction()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null;
}
shipProductionLength():number {
const offset = this.bb!.__offset(this.bb_pos, 38);
return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
}
route(index: number, obj?:Route):Route|null {
const offset = this.bb!.__offset(this.bb_pos, 40);
return offset ? (obj || new Route()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null;
}
routeLength():number {
const offset = this.bb!.__offset(this.bb_pos, 40);
return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
}
otherPlanet(index: number, obj?:OtherPlanet):OtherPlanet|null {
const offset = this.bb!.__offset(this.bb_pos, 42);
return offset ? (obj || new OtherPlanet()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null;
}
otherPlanetLength():number {
const offset = this.bb!.__offset(this.bb_pos, 42);
return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
}
uninhabitedPlanet(index: number, obj?:UninhabitedPlanet):UninhabitedPlanet|null {
const offset = this.bb!.__offset(this.bb_pos, 44);
return offset ? (obj || new UninhabitedPlanet()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null;
}
uninhabitedPlanetLength():number {
const offset = this.bb!.__offset(this.bb_pos, 44);
return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
}
unidentifiedPlanet(index: number, obj?:UnidentifiedPlanet):UnidentifiedPlanet|null {
const offset = this.bb!.__offset(this.bb_pos, 46);
return offset ? (obj || new UnidentifiedPlanet()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null;
}
unidentifiedPlanetLength():number {
const offset = this.bb!.__offset(this.bb_pos, 46);
return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
}
localFleet(index: number, obj?:LocalFleet):LocalFleet|null {
const offset = this.bb!.__offset(this.bb_pos, 48);
return offset ? (obj || new LocalFleet()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null;
}
localFleetLength():number {
const offset = this.bb!.__offset(this.bb_pos, 48);
return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
}
localGroup(index: number, obj?:LocalGroup):LocalGroup|null {
const offset = this.bb!.__offset(this.bb_pos, 50);
return offset ? (obj || new LocalGroup()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null;
}
localGroupLength():number {
const offset = this.bb!.__offset(this.bb_pos, 50);
return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
}
otherGroup(index: number, obj?:OtherGroup):OtherGroup|null {
const offset = this.bb!.__offset(this.bb_pos, 52);
return offset ? (obj || new OtherGroup()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null;
}
otherGroupLength():number {
const offset = this.bb!.__offset(this.bb_pos, 52);
return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
}
unidentifiedGroup(index: number, obj?:UnidentifiedGroup):UnidentifiedGroup|null {
const offset = this.bb!.__offset(this.bb_pos, 54);
return offset ? (obj || new UnidentifiedGroup()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null;
}
unidentifiedGroupLength():number {
const offset = this.bb!.__offset(this.bb_pos, 54);
return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
}
static startReport(builder:flatbuffers.Builder) {
builder.startObject(26);
}
static addVersion(builder:flatbuffers.Builder, version:bigint) {
builder.addFieldInt64(0, version, BigInt('0'));
}
static addTurn(builder:flatbuffers.Builder, turn:bigint) {
builder.addFieldInt64(1, turn, BigInt('0'));
}
static addWidth(builder:flatbuffers.Builder, width:number) {
builder.addFieldInt32(2, width, 0);
}
static addHeight(builder:flatbuffers.Builder, height:number) {
builder.addFieldInt32(3, height, 0);
}
static addPlanetCount(builder:flatbuffers.Builder, planetCount:number) {
builder.addFieldInt32(4, planetCount, 0);
}
static addRace(builder:flatbuffers.Builder, raceOffset:flatbuffers.Offset) {
builder.addFieldOffset(5, raceOffset, 0);
}
static addVotes(builder:flatbuffers.Builder, votes:number) {
builder.addFieldFloat32(6, votes, 0.0);
}
static addVoteFor(builder:flatbuffers.Builder, voteForOffset:flatbuffers.Offset) {
builder.addFieldOffset(7, voteForOffset, 0);
}
static addPlayer(builder:flatbuffers.Builder, playerOffset:flatbuffers.Offset) {
builder.addFieldOffset(8, playerOffset, 0);
}
static createPlayerVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset {
builder.startVector(4, data.length, 4);
for (let i = data.length - 1; i >= 0; i--) {
builder.addOffset(data[i]!);
}
return builder.endVector();
}
static startPlayerVector(builder:flatbuffers.Builder, numElems:number) {
builder.startVector(4, numElems, 4);
}
static addLocalScience(builder:flatbuffers.Builder, localScienceOffset:flatbuffers.Offset) {
builder.addFieldOffset(9, localScienceOffset, 0);
}
static createLocalScienceVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset {
builder.startVector(4, data.length, 4);
for (let i = data.length - 1; i >= 0; i--) {
builder.addOffset(data[i]!);
}
return builder.endVector();
}
static startLocalScienceVector(builder:flatbuffers.Builder, numElems:number) {
builder.startVector(4, numElems, 4);
}
static addOtherScience(builder:flatbuffers.Builder, otherScienceOffset:flatbuffers.Offset) {
builder.addFieldOffset(10, otherScienceOffset, 0);
}
static createOtherScienceVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset {
builder.startVector(4, data.length, 4);
for (let i = data.length - 1; i >= 0; i--) {
builder.addOffset(data[i]!);
}
return builder.endVector();
}
static startOtherScienceVector(builder:flatbuffers.Builder, numElems:number) {
builder.startVector(4, numElems, 4);
}
static addLocalShipClass(builder:flatbuffers.Builder, localShipClassOffset:flatbuffers.Offset) {
builder.addFieldOffset(11, localShipClassOffset, 0);
}
static createLocalShipClassVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset {
builder.startVector(4, data.length, 4);
for (let i = data.length - 1; i >= 0; i--) {
builder.addOffset(data[i]!);
}
return builder.endVector();
}
static startLocalShipClassVector(builder:flatbuffers.Builder, numElems:number) {
builder.startVector(4, numElems, 4);
}
static addOtherShipClass(builder:flatbuffers.Builder, otherShipClassOffset:flatbuffers.Offset) {
builder.addFieldOffset(12, otherShipClassOffset, 0);
}
static createOtherShipClassVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset {
builder.startVector(4, data.length, 4);
for (let i = data.length - 1; i >= 0; i--) {
builder.addOffset(data[i]!);
}
return builder.endVector();
}
static startOtherShipClassVector(builder:flatbuffers.Builder, numElems:number) {
builder.startVector(4, numElems, 4);
}
static addBattle(builder:flatbuffers.Builder, battleOffset:flatbuffers.Offset) {
builder.addFieldOffset(13, battleOffset, 0);
}
static startBattleVector(builder:flatbuffers.Builder, numElems:number) {
builder.startVector(16, numElems, 8);
}
static addBombing(builder:flatbuffers.Builder, bombingOffset:flatbuffers.Offset) {
builder.addFieldOffset(14, bombingOffset, 0);
}
static createBombingVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset {
builder.startVector(4, data.length, 4);
for (let i = data.length - 1; i >= 0; i--) {
builder.addOffset(data[i]!);
}
return builder.endVector();
}
static startBombingVector(builder:flatbuffers.Builder, numElems:number) {
builder.startVector(4, numElems, 4);
}
static addIncomingGroup(builder:flatbuffers.Builder, incomingGroupOffset:flatbuffers.Offset) {
builder.addFieldOffset(15, incomingGroupOffset, 0);
}
static createIncomingGroupVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset {
builder.startVector(4, data.length, 4);
for (let i = data.length - 1; i >= 0; i--) {
builder.addOffset(data[i]!);
}
return builder.endVector();
}
static startIncomingGroupVector(builder:flatbuffers.Builder, numElems:number) {
builder.startVector(4, numElems, 4);
}
static addLocalPlanet(builder:flatbuffers.Builder, localPlanetOffset:flatbuffers.Offset) {
builder.addFieldOffset(16, localPlanetOffset, 0);
}
static createLocalPlanetVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset {
builder.startVector(4, data.length, 4);
for (let i = data.length - 1; i >= 0; i--) {
builder.addOffset(data[i]!);
}
return builder.endVector();
}
static startLocalPlanetVector(builder:flatbuffers.Builder, numElems:number) {
builder.startVector(4, numElems, 4);
}
static addShipProduction(builder:flatbuffers.Builder, shipProductionOffset:flatbuffers.Offset) {
builder.addFieldOffset(17, shipProductionOffset, 0);
}
static createShipProductionVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset {
builder.startVector(4, data.length, 4);
for (let i = data.length - 1; i >= 0; i--) {
builder.addOffset(data[i]!);
}
return builder.endVector();
}
static startShipProductionVector(builder:flatbuffers.Builder, numElems:number) {
builder.startVector(4, numElems, 4);
}
static addRoute(builder:flatbuffers.Builder, routeOffset:flatbuffers.Offset) {
builder.addFieldOffset(18, routeOffset, 0);
}
static createRouteVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset {
builder.startVector(4, data.length, 4);
for (let i = data.length - 1; i >= 0; i--) {
builder.addOffset(data[i]!);
}
return builder.endVector();
}
static startRouteVector(builder:flatbuffers.Builder, numElems:number) {
builder.startVector(4, numElems, 4);
}
static addOtherPlanet(builder:flatbuffers.Builder, otherPlanetOffset:flatbuffers.Offset) {
builder.addFieldOffset(19, otherPlanetOffset, 0);
}
static createOtherPlanetVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset {
builder.startVector(4, data.length, 4);
for (let i = data.length - 1; i >= 0; i--) {
builder.addOffset(data[i]!);
}
return builder.endVector();
}
static startOtherPlanetVector(builder:flatbuffers.Builder, numElems:number) {
builder.startVector(4, numElems, 4);
}
static addUninhabitedPlanet(builder:flatbuffers.Builder, uninhabitedPlanetOffset:flatbuffers.Offset) {
builder.addFieldOffset(20, uninhabitedPlanetOffset, 0);
}
static createUninhabitedPlanetVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset {
builder.startVector(4, data.length, 4);
for (let i = data.length - 1; i >= 0; i--) {
builder.addOffset(data[i]!);
}
return builder.endVector();
}
static startUninhabitedPlanetVector(builder:flatbuffers.Builder, numElems:number) {
builder.startVector(4, numElems, 4);
}
static addUnidentifiedPlanet(builder:flatbuffers.Builder, unidentifiedPlanetOffset:flatbuffers.Offset) {
builder.addFieldOffset(21, unidentifiedPlanetOffset, 0);
}
static createUnidentifiedPlanetVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset {
builder.startVector(4, data.length, 4);
for (let i = data.length - 1; i >= 0; i--) {
builder.addOffset(data[i]!);
}
return builder.endVector();
}
static startUnidentifiedPlanetVector(builder:flatbuffers.Builder, numElems:number) {
builder.startVector(4, numElems, 4);
}
static addLocalFleet(builder:flatbuffers.Builder, localFleetOffset:flatbuffers.Offset) {
builder.addFieldOffset(22, localFleetOffset, 0);
}
static createLocalFleetVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset {
builder.startVector(4, data.length, 4);
for (let i = data.length - 1; i >= 0; i--) {
builder.addOffset(data[i]!);
}
return builder.endVector();
}
static startLocalFleetVector(builder:flatbuffers.Builder, numElems:number) {
builder.startVector(4, numElems, 4);
}
static addLocalGroup(builder:flatbuffers.Builder, localGroupOffset:flatbuffers.Offset) {
builder.addFieldOffset(23, localGroupOffset, 0);
}
static createLocalGroupVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset {
builder.startVector(4, data.length, 4);
for (let i = data.length - 1; i >= 0; i--) {
builder.addOffset(data[i]!);
}
return builder.endVector();
}
static startLocalGroupVector(builder:flatbuffers.Builder, numElems:number) {
builder.startVector(4, numElems, 4);
}
static addOtherGroup(builder:flatbuffers.Builder, otherGroupOffset:flatbuffers.Offset) {
builder.addFieldOffset(24, otherGroupOffset, 0);
}
static createOtherGroupVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset {
builder.startVector(4, data.length, 4);
for (let i = data.length - 1; i >= 0; i--) {
builder.addOffset(data[i]!);
}
return builder.endVector();
}
static startOtherGroupVector(builder:flatbuffers.Builder, numElems:number) {
builder.startVector(4, numElems, 4);
}
static addUnidentifiedGroup(builder:flatbuffers.Builder, unidentifiedGroupOffset:flatbuffers.Offset) {
builder.addFieldOffset(25, unidentifiedGroupOffset, 0);
}
static createUnidentifiedGroupVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset {
builder.startVector(4, data.length, 4);
for (let i = data.length - 1; i >= 0; i--) {
builder.addOffset(data[i]!);
}
return builder.endVector();
}
static startUnidentifiedGroupVector(builder:flatbuffers.Builder, numElems:number) {
builder.startVector(4, numElems, 4);
}
static endReport(builder:flatbuffers.Builder):flatbuffers.Offset {
const offset = builder.endObject();
return offset;
}
static finishReportBuffer(builder:flatbuffers.Builder, offset:flatbuffers.Offset) {
builder.finish(offset);
}
static finishSizePrefixedReportBuffer(builder:flatbuffers.Builder, offset:flatbuffers.Offset) {
builder.finish(offset, undefined, true);
}
static createReport(builder:flatbuffers.Builder, version:bigint, turn:bigint, width:number, height:number, planetCount:number, raceOffset:flatbuffers.Offset, votes:number, voteForOffset:flatbuffers.Offset, playerOffset:flatbuffers.Offset, localScienceOffset:flatbuffers.Offset, otherScienceOffset:flatbuffers.Offset, localShipClassOffset:flatbuffers.Offset, otherShipClassOffset:flatbuffers.Offset, battleOffset:flatbuffers.Offset, bombingOffset:flatbuffers.Offset, incomingGroupOffset:flatbuffers.Offset, localPlanetOffset:flatbuffers.Offset, shipProductionOffset:flatbuffers.Offset, routeOffset:flatbuffers.Offset, otherPlanetOffset:flatbuffers.Offset, uninhabitedPlanetOffset:flatbuffers.Offset, unidentifiedPlanetOffset:flatbuffers.Offset, localFleetOffset:flatbuffers.Offset, localGroupOffset:flatbuffers.Offset, otherGroupOffset:flatbuffers.Offset, unidentifiedGroupOffset:flatbuffers.Offset):flatbuffers.Offset {
Report.startReport(builder);
Report.addVersion(builder, version);
Report.addTurn(builder, turn);
Report.addWidth(builder, width);
Report.addHeight(builder, height);
Report.addPlanetCount(builder, planetCount);
Report.addRace(builder, raceOffset);
Report.addVotes(builder, votes);
Report.addVoteFor(builder, voteForOffset);
Report.addPlayer(builder, playerOffset);
Report.addLocalScience(builder, localScienceOffset);
Report.addOtherScience(builder, otherScienceOffset);
Report.addLocalShipClass(builder, localShipClassOffset);
Report.addOtherShipClass(builder, otherShipClassOffset);
Report.addBattle(builder, battleOffset);
Report.addBombing(builder, bombingOffset);
Report.addIncomingGroup(builder, incomingGroupOffset);
Report.addLocalPlanet(builder, localPlanetOffset);
Report.addShipProduction(builder, shipProductionOffset);
Report.addRoute(builder, routeOffset);
Report.addOtherPlanet(builder, otherPlanetOffset);
Report.addUninhabitedPlanet(builder, uninhabitedPlanetOffset);
Report.addUnidentifiedPlanet(builder, unidentifiedPlanetOffset);
Report.addLocalFleet(builder, localFleetOffset);
Report.addLocalGroup(builder, localGroupOffset);
Report.addOtherGroup(builder, otherGroupOffset);
Report.addUnidentifiedGroup(builder, unidentifiedGroupOffset);
return Report.endReport(builder);
}
unpack(): ReportT {
return new ReportT(
this.version(),
this.turn(),
this.width(),
this.height(),
this.planetCount(),
this.race(),
this.votes(),
this.voteFor(),
this.bb!.createObjList<Player, PlayerT>(this.player.bind(this), this.playerLength()),
this.bb!.createObjList<Science, ScienceT>(this.localScience.bind(this), this.localScienceLength()),
this.bb!.createObjList<OtherScience, OtherScienceT>(this.otherScience.bind(this), this.otherScienceLength()),
this.bb!.createObjList<ShipClass, ShipClassT>(this.localShipClass.bind(this), this.localShipClassLength()),
this.bb!.createObjList<OthersShipClass, OthersShipClassT>(this.otherShipClass.bind(this), this.otherShipClassLength()),
this.bb!.createObjList<UUID, UUIDT>(this.battle.bind(this), this.battleLength()),
this.bb!.createObjList<Bombing, BombingT>(this.bombing.bind(this), this.bombingLength()),
this.bb!.createObjList<IncomingGroup, IncomingGroupT>(this.incomingGroup.bind(this), this.incomingGroupLength()),
this.bb!.createObjList<LocalPlanet, LocalPlanetT>(this.localPlanet.bind(this), this.localPlanetLength()),
this.bb!.createObjList<ShipProduction, ShipProductionT>(this.shipProduction.bind(this), this.shipProductionLength()),
this.bb!.createObjList<Route, RouteT>(this.route.bind(this), this.routeLength()),
this.bb!.createObjList<OtherPlanet, OtherPlanetT>(this.otherPlanet.bind(this), this.otherPlanetLength()),
this.bb!.createObjList<UninhabitedPlanet, UninhabitedPlanetT>(this.uninhabitedPlanet.bind(this), this.uninhabitedPlanetLength()),
this.bb!.createObjList<UnidentifiedPlanet, UnidentifiedPlanetT>(this.unidentifiedPlanet.bind(this), this.unidentifiedPlanetLength()),
this.bb!.createObjList<LocalFleet, LocalFleetT>(this.localFleet.bind(this), this.localFleetLength()),
this.bb!.createObjList<LocalGroup, LocalGroupT>(this.localGroup.bind(this), this.localGroupLength()),
this.bb!.createObjList<OtherGroup, OtherGroupT>(this.otherGroup.bind(this), this.otherGroupLength()),
this.bb!.createObjList<UnidentifiedGroup, UnidentifiedGroupT>(this.unidentifiedGroup.bind(this), this.unidentifiedGroupLength())
);
}
unpackTo(_o: ReportT): void {
_o.version = this.version();
_o.turn = this.turn();
_o.width = this.width();
_o.height = this.height();
_o.planetCount = this.planetCount();
_o.race = this.race();
_o.votes = this.votes();
_o.voteFor = this.voteFor();
_o.player = this.bb!.createObjList<Player, PlayerT>(this.player.bind(this), this.playerLength());
_o.localScience = this.bb!.createObjList<Science, ScienceT>(this.localScience.bind(this), this.localScienceLength());
_o.otherScience = this.bb!.createObjList<OtherScience, OtherScienceT>(this.otherScience.bind(this), this.otherScienceLength());
_o.localShipClass = this.bb!.createObjList<ShipClass, ShipClassT>(this.localShipClass.bind(this), this.localShipClassLength());
_o.otherShipClass = this.bb!.createObjList<OthersShipClass, OthersShipClassT>(this.otherShipClass.bind(this), this.otherShipClassLength());
_o.battle = this.bb!.createObjList<UUID, UUIDT>(this.battle.bind(this), this.battleLength());
_o.bombing = this.bb!.createObjList<Bombing, BombingT>(this.bombing.bind(this), this.bombingLength());
_o.incomingGroup = this.bb!.createObjList<IncomingGroup, IncomingGroupT>(this.incomingGroup.bind(this), this.incomingGroupLength());
_o.localPlanet = this.bb!.createObjList<LocalPlanet, LocalPlanetT>(this.localPlanet.bind(this), this.localPlanetLength());
_o.shipProduction = this.bb!.createObjList<ShipProduction, ShipProductionT>(this.shipProduction.bind(this), this.shipProductionLength());
_o.route = this.bb!.createObjList<Route, RouteT>(this.route.bind(this), this.routeLength());
_o.otherPlanet = this.bb!.createObjList<OtherPlanet, OtherPlanetT>(this.otherPlanet.bind(this), this.otherPlanetLength());
_o.uninhabitedPlanet = this.bb!.createObjList<UninhabitedPlanet, UninhabitedPlanetT>(this.uninhabitedPlanet.bind(this), this.uninhabitedPlanetLength());
_o.unidentifiedPlanet = this.bb!.createObjList<UnidentifiedPlanet, UnidentifiedPlanetT>(this.unidentifiedPlanet.bind(this), this.unidentifiedPlanetLength());
_o.localFleet = this.bb!.createObjList<LocalFleet, LocalFleetT>(this.localFleet.bind(this), this.localFleetLength());
_o.localGroup = this.bb!.createObjList<LocalGroup, LocalGroupT>(this.localGroup.bind(this), this.localGroupLength());
_o.otherGroup = this.bb!.createObjList<OtherGroup, OtherGroupT>(this.otherGroup.bind(this), this.otherGroupLength());
_o.unidentifiedGroup = this.bb!.createObjList<UnidentifiedGroup, UnidentifiedGroupT>(this.unidentifiedGroup.bind(this), this.unidentifiedGroupLength());
}
}
export class ReportT implements flatbuffers.IGeneratedObject {
constructor(
public version: bigint = BigInt('0'),
public turn: bigint = BigInt('0'),
public width: number = 0,
public height: number = 0,
public planetCount: number = 0,
public race: string|Uint8Array|null = null,
public votes: number = 0.0,
public voteFor: string|Uint8Array|null = null,
public player: (PlayerT)[] = [],
public localScience: (ScienceT)[] = [],
public otherScience: (OtherScienceT)[] = [],
public localShipClass: (ShipClassT)[] = [],
public otherShipClass: (OthersShipClassT)[] = [],
public battle: (UUIDT)[] = [],
public bombing: (BombingT)[] = [],
public incomingGroup: (IncomingGroupT)[] = [],
public localPlanet: (LocalPlanetT)[] = [],
public shipProduction: (ShipProductionT)[] = [],
public route: (RouteT)[] = [],
public otherPlanet: (OtherPlanetT)[] = [],
public uninhabitedPlanet: (UninhabitedPlanetT)[] = [],
public unidentifiedPlanet: (UnidentifiedPlanetT)[] = [],
public localFleet: (LocalFleetT)[] = [],
public localGroup: (LocalGroupT)[] = [],
public otherGroup: (OtherGroupT)[] = [],
public unidentifiedGroup: (UnidentifiedGroupT)[] = []
){}
pack(builder:flatbuffers.Builder): flatbuffers.Offset {
const race = (this.race !== null ? builder.createString(this.race!) : 0);
const voteFor = (this.voteFor !== null ? builder.createString(this.voteFor!) : 0);
const player = Report.createPlayerVector(builder, builder.createObjectOffsetList(this.player));
const localScience = Report.createLocalScienceVector(builder, builder.createObjectOffsetList(this.localScience));
const otherScience = Report.createOtherScienceVector(builder, builder.createObjectOffsetList(this.otherScience));
const localShipClass = Report.createLocalShipClassVector(builder, builder.createObjectOffsetList(this.localShipClass));
const otherShipClass = Report.createOtherShipClassVector(builder, builder.createObjectOffsetList(this.otherShipClass));
const battle = builder.createStructOffsetList(this.battle, Report.startBattleVector);
const bombing = Report.createBombingVector(builder, builder.createObjectOffsetList(this.bombing));
const incomingGroup = Report.createIncomingGroupVector(builder, builder.createObjectOffsetList(this.incomingGroup));
const localPlanet = Report.createLocalPlanetVector(builder, builder.createObjectOffsetList(this.localPlanet));
const shipProduction = Report.createShipProductionVector(builder, builder.createObjectOffsetList(this.shipProduction));
const route = Report.createRouteVector(builder, builder.createObjectOffsetList(this.route));
const otherPlanet = Report.createOtherPlanetVector(builder, builder.createObjectOffsetList(this.otherPlanet));
const uninhabitedPlanet = Report.createUninhabitedPlanetVector(builder, builder.createObjectOffsetList(this.uninhabitedPlanet));
const unidentifiedPlanet = Report.createUnidentifiedPlanetVector(builder, builder.createObjectOffsetList(this.unidentifiedPlanet));
const localFleet = Report.createLocalFleetVector(builder, builder.createObjectOffsetList(this.localFleet));
const localGroup = Report.createLocalGroupVector(builder, builder.createObjectOffsetList(this.localGroup));
const otherGroup = Report.createOtherGroupVector(builder, builder.createObjectOffsetList(this.otherGroup));
const unidentifiedGroup = Report.createUnidentifiedGroupVector(builder, builder.createObjectOffsetList(this.unidentifiedGroup));
return Report.createReport(builder,
this.version,
this.turn,
this.width,
this.height,
this.planetCount,
race,
this.votes,
voteFor,
player,
localScience,
otherScience,
localShipClass,
otherShipClass,
battle,
bombing,
incomingGroup,
localPlanet,
shipProduction,
route,
otherPlanet,
uninhabitedPlanet,
unidentifiedPlanet,
localFleet,
localGroup,
otherGroup,
unidentifiedGroup
);
}
}
@@ -0,0 +1,92 @@
// automatically generated by the FlatBuffers compiler, do not modify
/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
import * as flatbuffers from 'flatbuffers';
export class RouteEntry implements flatbuffers.IUnpackableObject<RouteEntryT> {
bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0;
__init(i:number, bb:flatbuffers.ByteBuffer):RouteEntry {
this.bb_pos = i;
this.bb = bb;
return this;
}
static getRootAsRouteEntry(bb:flatbuffers.ByteBuffer, obj?:RouteEntry):RouteEntry {
return (obj || new RouteEntry()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
static getSizePrefixedRootAsRouteEntry(bb:flatbuffers.ByteBuffer, obj?:RouteEntry):RouteEntry {
bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
return (obj || new RouteEntry()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
key():bigint {
const offset = this.bb!.__offset(this.bb_pos, 4);
return offset ? this.bb!.readUint64(this.bb_pos + offset) : BigInt('0');
}
value():string|null
value(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
value(optionalEncoding?:any):string|Uint8Array|null {
const offset = this.bb!.__offset(this.bb_pos, 6);
return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
}
static startRouteEntry(builder:flatbuffers.Builder) {
builder.startObject(2);
}
static addKey(builder:flatbuffers.Builder, key:bigint) {
builder.addFieldInt64(0, key, BigInt('0'));
}
static addValue(builder:flatbuffers.Builder, valueOffset:flatbuffers.Offset) {
builder.addFieldOffset(1, valueOffset, 0);
}
static endRouteEntry(builder:flatbuffers.Builder):flatbuffers.Offset {
const offset = builder.endObject();
return offset;
}
static createRouteEntry(builder:flatbuffers.Builder, key:bigint, valueOffset:flatbuffers.Offset):flatbuffers.Offset {
RouteEntry.startRouteEntry(builder);
RouteEntry.addKey(builder, key);
RouteEntry.addValue(builder, valueOffset);
return RouteEntry.endRouteEntry(builder);
}
unpack(): RouteEntryT {
return new RouteEntryT(
this.key(),
this.value()
);
}
unpackTo(_o: RouteEntryT): void {
_o.key = this.key();
_o.value = this.value();
}
}
export class RouteEntryT implements flatbuffers.IGeneratedObject {
constructor(
public key: bigint = BigInt('0'),
public value: string|Uint8Array|null = null
){}
pack(builder:flatbuffers.Builder): flatbuffers.Offset {
const value = (this.value !== null ? builder.createString(this.value!) : 0);
return RouteEntry.createRouteEntry(builder,
this.key,
value
);
}
}
@@ -0,0 +1,108 @@
// automatically generated by the FlatBuffers compiler, do not modify
/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
import * as flatbuffers from 'flatbuffers';
import { RouteEntry, RouteEntryT } from './route-entry.js';
export class Route implements flatbuffers.IUnpackableObject<RouteT> {
bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0;
__init(i:number, bb:flatbuffers.ByteBuffer):Route {
this.bb_pos = i;
this.bb = bb;
return this;
}
static getRootAsRoute(bb:flatbuffers.ByteBuffer, obj?:Route):Route {
return (obj || new Route()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
static getSizePrefixedRootAsRoute(bb:flatbuffers.ByteBuffer, obj?:Route):Route {
bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
return (obj || new Route()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
planet():bigint {
const offset = this.bb!.__offset(this.bb_pos, 4);
return offset ? this.bb!.readUint64(this.bb_pos + offset) : BigInt('0');
}
route(index: number, obj?:RouteEntry):RouteEntry|null {
const offset = this.bb!.__offset(this.bb_pos, 6);
return offset ? (obj || new RouteEntry()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null;
}
routeLength():number {
const offset = this.bb!.__offset(this.bb_pos, 6);
return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
}
static startRoute(builder:flatbuffers.Builder) {
builder.startObject(2);
}
static addPlanet(builder:flatbuffers.Builder, planet:bigint) {
builder.addFieldInt64(0, planet, BigInt('0'));
}
static addRoute(builder:flatbuffers.Builder, routeOffset:flatbuffers.Offset) {
builder.addFieldOffset(1, routeOffset, 0);
}
static createRouteVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset {
builder.startVector(4, data.length, 4);
for (let i = data.length - 1; i >= 0; i--) {
builder.addOffset(data[i]!);
}
return builder.endVector();
}
static startRouteVector(builder:flatbuffers.Builder, numElems:number) {
builder.startVector(4, numElems, 4);
}
static endRoute(builder:flatbuffers.Builder):flatbuffers.Offset {
const offset = builder.endObject();
return offset;
}
static createRoute(builder:flatbuffers.Builder, planet:bigint, routeOffset:flatbuffers.Offset):flatbuffers.Offset {
Route.startRoute(builder);
Route.addPlanet(builder, planet);
Route.addRoute(builder, routeOffset);
return Route.endRoute(builder);
}
unpack(): RouteT {
return new RouteT(
this.planet(),
this.bb!.createObjList<RouteEntry, RouteEntryT>(this.route.bind(this), this.routeLength())
);
}
unpackTo(_o: RouteT): void {
_o.planet = this.planet();
_o.route = this.bb!.createObjList<RouteEntry, RouteEntryT>(this.route.bind(this), this.routeLength());
}
}
export class RouteT implements flatbuffers.IGeneratedObject {
constructor(
public planet: bigint = BigInt('0'),
public route: (RouteEntryT)[] = []
){}
pack(builder:flatbuffers.Builder): flatbuffers.Offset {
const route = Route.createRouteVector(builder, builder.createObjectOffsetList(this.route));
return Route.createRoute(builder,
this.planet,
route
);
}
}
@@ -0,0 +1,134 @@
// automatically generated by the FlatBuffers compiler, do not modify
/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
import * as flatbuffers from 'flatbuffers';
export class Science implements flatbuffers.IUnpackableObject<ScienceT> {
bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0;
__init(i:number, bb:flatbuffers.ByteBuffer):Science {
this.bb_pos = i;
this.bb = bb;
return this;
}
static getRootAsScience(bb:flatbuffers.ByteBuffer, obj?:Science):Science {
return (obj || new Science()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
static getSizePrefixedRootAsScience(bb:flatbuffers.ByteBuffer, obj?:Science):Science {
bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
return (obj || new Science()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
name():string|null
name(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
name(optionalEncoding?:any):string|Uint8Array|null {
const offset = this.bb!.__offset(this.bb_pos, 4);
return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
}
drive():number {
const offset = this.bb!.__offset(this.bb_pos, 6);
return offset ? this.bb!.readFloat32(this.bb_pos + offset) : 0.0;
}
weapons():number {
const offset = this.bb!.__offset(this.bb_pos, 8);
return offset ? this.bb!.readFloat32(this.bb_pos + offset) : 0.0;
}
shields():number {
const offset = this.bb!.__offset(this.bb_pos, 10);
return offset ? this.bb!.readFloat32(this.bb_pos + offset) : 0.0;
}
cargo():number {
const offset = this.bb!.__offset(this.bb_pos, 12);
return offset ? this.bb!.readFloat32(this.bb_pos + offset) : 0.0;
}
static startScience(builder:flatbuffers.Builder) {
builder.startObject(5);
}
static addName(builder:flatbuffers.Builder, nameOffset:flatbuffers.Offset) {
builder.addFieldOffset(0, nameOffset, 0);
}
static addDrive(builder:flatbuffers.Builder, drive:number) {
builder.addFieldFloat32(1, drive, 0.0);
}
static addWeapons(builder:flatbuffers.Builder, weapons:number) {
builder.addFieldFloat32(2, weapons, 0.0);
}
static addShields(builder:flatbuffers.Builder, shields:number) {
builder.addFieldFloat32(3, shields, 0.0);
}
static addCargo(builder:flatbuffers.Builder, cargo:number) {
builder.addFieldFloat32(4, cargo, 0.0);
}
static endScience(builder:flatbuffers.Builder):flatbuffers.Offset {
const offset = builder.endObject();
return offset;
}
static createScience(builder:flatbuffers.Builder, nameOffset:flatbuffers.Offset, drive:number, weapons:number, shields:number, cargo:number):flatbuffers.Offset {
Science.startScience(builder);
Science.addName(builder, nameOffset);
Science.addDrive(builder, drive);
Science.addWeapons(builder, weapons);
Science.addShields(builder, shields);
Science.addCargo(builder, cargo);
return Science.endScience(builder);
}
unpack(): ScienceT {
return new ScienceT(
this.name(),
this.drive(),
this.weapons(),
this.shields(),
this.cargo()
);
}
unpackTo(_o: ScienceT): void {
_o.name = this.name();
_o.drive = this.drive();
_o.weapons = this.weapons();
_o.shields = this.shields();
_o.cargo = this.cargo();
}
}
export class ScienceT implements flatbuffers.IGeneratedObject {
constructor(
public name: string|Uint8Array|null = null,
public drive: number = 0.0,
public weapons: number = 0.0,
public shields: number = 0.0,
public cargo: number = 0.0
){}
pack(builder:flatbuffers.Builder): flatbuffers.Offset {
const name = (this.name !== null ? builder.createString(this.name!) : 0);
return Science.createScience(builder,
name,
this.drive,
this.weapons,
this.shields,
this.cargo
);
}
}
@@ -0,0 +1,162 @@
// automatically generated by the FlatBuffers compiler, do not modify
/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
import * as flatbuffers from 'flatbuffers';
export class ShipClass implements flatbuffers.IUnpackableObject<ShipClassT> {
bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0;
__init(i:number, bb:flatbuffers.ByteBuffer):ShipClass {
this.bb_pos = i;
this.bb = bb;
return this;
}
static getRootAsShipClass(bb:flatbuffers.ByteBuffer, obj?:ShipClass):ShipClass {
return (obj || new ShipClass()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
static getSizePrefixedRootAsShipClass(bb:flatbuffers.ByteBuffer, obj?:ShipClass):ShipClass {
bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
return (obj || new ShipClass()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
name():string|null
name(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
name(optionalEncoding?:any):string|Uint8Array|null {
const offset = this.bb!.__offset(this.bb_pos, 4);
return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
}
drive():number {
const offset = this.bb!.__offset(this.bb_pos, 6);
return offset ? this.bb!.readFloat32(this.bb_pos + offset) : 0.0;
}
armament():bigint {
const offset = this.bb!.__offset(this.bb_pos, 8);
return offset ? this.bb!.readUint64(this.bb_pos + offset) : BigInt('0');
}
weapons():number {
const offset = this.bb!.__offset(this.bb_pos, 10);
return offset ? this.bb!.readFloat32(this.bb_pos + offset) : 0.0;
}
shields():number {
const offset = this.bb!.__offset(this.bb_pos, 12);
return offset ? this.bb!.readFloat32(this.bb_pos + offset) : 0.0;
}
cargo():number {
const offset = this.bb!.__offset(this.bb_pos, 14);
return offset ? this.bb!.readFloat32(this.bb_pos + offset) : 0.0;
}
mass():number {
const offset = this.bb!.__offset(this.bb_pos, 16);
return offset ? this.bb!.readFloat32(this.bb_pos + offset) : 0.0;
}
static startShipClass(builder:flatbuffers.Builder) {
builder.startObject(7);
}
static addName(builder:flatbuffers.Builder, nameOffset:flatbuffers.Offset) {
builder.addFieldOffset(0, nameOffset, 0);
}
static addDrive(builder:flatbuffers.Builder, drive:number) {
builder.addFieldFloat32(1, drive, 0.0);
}
static addArmament(builder:flatbuffers.Builder, armament:bigint) {
builder.addFieldInt64(2, armament, BigInt('0'));
}
static addWeapons(builder:flatbuffers.Builder, weapons:number) {
builder.addFieldFloat32(3, weapons, 0.0);
}
static addShields(builder:flatbuffers.Builder, shields:number) {
builder.addFieldFloat32(4, shields, 0.0);
}
static addCargo(builder:flatbuffers.Builder, cargo:number) {
builder.addFieldFloat32(5, cargo, 0.0);
}
static addMass(builder:flatbuffers.Builder, mass:number) {
builder.addFieldFloat32(6, mass, 0.0);
}
static endShipClass(builder:flatbuffers.Builder):flatbuffers.Offset {
const offset = builder.endObject();
return offset;
}
static createShipClass(builder:flatbuffers.Builder, nameOffset:flatbuffers.Offset, drive:number, armament:bigint, weapons:number, shields:number, cargo:number, mass:number):flatbuffers.Offset {
ShipClass.startShipClass(builder);
ShipClass.addName(builder, nameOffset);
ShipClass.addDrive(builder, drive);
ShipClass.addArmament(builder, armament);
ShipClass.addWeapons(builder, weapons);
ShipClass.addShields(builder, shields);
ShipClass.addCargo(builder, cargo);
ShipClass.addMass(builder, mass);
return ShipClass.endShipClass(builder);
}
unpack(): ShipClassT {
return new ShipClassT(
this.name(),
this.drive(),
this.armament(),
this.weapons(),
this.shields(),
this.cargo(),
this.mass()
);
}
unpackTo(_o: ShipClassT): void {
_o.name = this.name();
_o.drive = this.drive();
_o.armament = this.armament();
_o.weapons = this.weapons();
_o.shields = this.shields();
_o.cargo = this.cargo();
_o.mass = this.mass();
}
}
export class ShipClassT implements flatbuffers.IGeneratedObject {
constructor(
public name: string|Uint8Array|null = null,
public drive: number = 0.0,
public armament: bigint = BigInt('0'),
public weapons: number = 0.0,
public shields: number = 0.0,
public cargo: number = 0.0,
public mass: number = 0.0
){}
pack(builder:flatbuffers.Builder): flatbuffers.Offset {
const name = (this.name !== null ? builder.createString(this.name!) : 0);
return ShipClass.createShipClass(builder,
name,
this.drive,
this.armament,
this.weapons,
this.shields,
this.cargo,
this.mass
);
}
}
@@ -0,0 +1,148 @@
// automatically generated by the FlatBuffers compiler, do not modify
/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
import * as flatbuffers from 'flatbuffers';
export class ShipProduction implements flatbuffers.IUnpackableObject<ShipProductionT> {
bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0;
__init(i:number, bb:flatbuffers.ByteBuffer):ShipProduction {
this.bb_pos = i;
this.bb = bb;
return this;
}
static getRootAsShipProduction(bb:flatbuffers.ByteBuffer, obj?:ShipProduction):ShipProduction {
return (obj || new ShipProduction()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
static getSizePrefixedRootAsShipProduction(bb:flatbuffers.ByteBuffer, obj?:ShipProduction):ShipProduction {
bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
return (obj || new ShipProduction()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
planet():bigint {
const offset = this.bb!.__offset(this.bb_pos, 4);
return offset ? this.bb!.readUint64(this.bb_pos + offset) : BigInt('0');
}
class_():string|null
class_(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
class_(optionalEncoding?:any):string|Uint8Array|null {
const offset = this.bb!.__offset(this.bb_pos, 6);
return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
}
cost():number {
const offset = this.bb!.__offset(this.bb_pos, 8);
return offset ? this.bb!.readFloat32(this.bb_pos + offset) : 0.0;
}
prodUsed():number {
const offset = this.bb!.__offset(this.bb_pos, 10);
return offset ? this.bb!.readFloat32(this.bb_pos + offset) : 0.0;
}
percent():number {
const offset = this.bb!.__offset(this.bb_pos, 12);
return offset ? this.bb!.readFloat32(this.bb_pos + offset) : 0.0;
}
free():number {
const offset = this.bb!.__offset(this.bb_pos, 14);
return offset ? this.bb!.readFloat32(this.bb_pos + offset) : 0.0;
}
static startShipProduction(builder:flatbuffers.Builder) {
builder.startObject(6);
}
static addPlanet(builder:flatbuffers.Builder, planet:bigint) {
builder.addFieldInt64(0, planet, BigInt('0'));
}
static addClass(builder:flatbuffers.Builder, class_Offset:flatbuffers.Offset) {
builder.addFieldOffset(1, class_Offset, 0);
}
static addCost(builder:flatbuffers.Builder, cost:number) {
builder.addFieldFloat32(2, cost, 0.0);
}
static addProdUsed(builder:flatbuffers.Builder, prodUsed:number) {
builder.addFieldFloat32(3, prodUsed, 0.0);
}
static addPercent(builder:flatbuffers.Builder, percent:number) {
builder.addFieldFloat32(4, percent, 0.0);
}
static addFree(builder:flatbuffers.Builder, free:number) {
builder.addFieldFloat32(5, free, 0.0);
}
static endShipProduction(builder:flatbuffers.Builder):flatbuffers.Offset {
const offset = builder.endObject();
return offset;
}
static createShipProduction(builder:flatbuffers.Builder, planet:bigint, class_Offset:flatbuffers.Offset, cost:number, prodUsed:number, percent:number, free:number):flatbuffers.Offset {
ShipProduction.startShipProduction(builder);
ShipProduction.addPlanet(builder, planet);
ShipProduction.addClass(builder, class_Offset);
ShipProduction.addCost(builder, cost);
ShipProduction.addProdUsed(builder, prodUsed);
ShipProduction.addPercent(builder, percent);
ShipProduction.addFree(builder, free);
return ShipProduction.endShipProduction(builder);
}
unpack(): ShipProductionT {
return new ShipProductionT(
this.planet(),
this.class_(),
this.cost(),
this.prodUsed(),
this.percent(),
this.free()
);
}
unpackTo(_o: ShipProductionT): void {
_o.planet = this.planet();
_o.class_ = this.class_();
_o.cost = this.cost();
_o.prodUsed = this.prodUsed();
_o.percent = this.percent();
_o.free = this.free();
}
}
export class ShipProductionT implements flatbuffers.IGeneratedObject {
constructor(
public planet: bigint = BigInt('0'),
public class_: string|Uint8Array|null = null,
public cost: number = 0.0,
public prodUsed: number = 0.0,
public percent: number = 0.0,
public free: number = 0.0
){}
pack(builder:flatbuffers.Builder): flatbuffers.Offset {
const class_ = (this.class_ !== null ? builder.createString(this.class_!) : 0);
return ShipProduction.createShipProduction(builder,
this.planet,
class_,
this.cost,
this.prodUsed,
this.percent,
this.free
);
}
}
@@ -0,0 +1,92 @@
// automatically generated by the FlatBuffers compiler, do not modify
/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
import * as flatbuffers from 'flatbuffers';
export class TechEntry implements flatbuffers.IUnpackableObject<TechEntryT> {
bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0;
__init(i:number, bb:flatbuffers.ByteBuffer):TechEntry {
this.bb_pos = i;
this.bb = bb;
return this;
}
static getRootAsTechEntry(bb:flatbuffers.ByteBuffer, obj?:TechEntry):TechEntry {
return (obj || new TechEntry()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
static getSizePrefixedRootAsTechEntry(bb:flatbuffers.ByteBuffer, obj?:TechEntry):TechEntry {
bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
return (obj || new TechEntry()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
key():string|null
key(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
key(optionalEncoding?:any):string|Uint8Array|null {
const offset = this.bb!.__offset(this.bb_pos, 4);
return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
}
value():number {
const offset = this.bb!.__offset(this.bb_pos, 6);
return offset ? this.bb!.readFloat32(this.bb_pos + offset) : 0.0;
}
static startTechEntry(builder:flatbuffers.Builder) {
builder.startObject(2);
}
static addKey(builder:flatbuffers.Builder, keyOffset:flatbuffers.Offset) {
builder.addFieldOffset(0, keyOffset, 0);
}
static addValue(builder:flatbuffers.Builder, value:number) {
builder.addFieldFloat32(1, value, 0.0);
}
static endTechEntry(builder:flatbuffers.Builder):flatbuffers.Offset {
const offset = builder.endObject();
return offset;
}
static createTechEntry(builder:flatbuffers.Builder, keyOffset:flatbuffers.Offset, value:number):flatbuffers.Offset {
TechEntry.startTechEntry(builder);
TechEntry.addKey(builder, keyOffset);
TechEntry.addValue(builder, value);
return TechEntry.endTechEntry(builder);
}
unpack(): TechEntryT {
return new TechEntryT(
this.key(),
this.value()
);
}
unpackTo(_o: TechEntryT): void {
_o.key = this.key();
_o.value = this.value();
}
}
export class TechEntryT implements flatbuffers.IGeneratedObject {
constructor(
public key: string|Uint8Array|null = null,
public value: number = 0.0
){}
pack(builder:flatbuffers.Builder): flatbuffers.Offset {
const key = (this.key !== null ? builder.createString(this.key!) : 0);
return TechEntry.createTechEntry(builder,
key,
this.value
);
}
}
@@ -0,0 +1,88 @@
// automatically generated by the FlatBuffers compiler, do not modify
/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
import * as flatbuffers from 'flatbuffers';
export class UnidentifiedGroup implements flatbuffers.IUnpackableObject<UnidentifiedGroupT> {
bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0;
__init(i:number, bb:flatbuffers.ByteBuffer):UnidentifiedGroup {
this.bb_pos = i;
this.bb = bb;
return this;
}
static getRootAsUnidentifiedGroup(bb:flatbuffers.ByteBuffer, obj?:UnidentifiedGroup):UnidentifiedGroup {
return (obj || new UnidentifiedGroup()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
static getSizePrefixedRootAsUnidentifiedGroup(bb:flatbuffers.ByteBuffer, obj?:UnidentifiedGroup):UnidentifiedGroup {
bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
return (obj || new UnidentifiedGroup()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
x():number {
const offset = this.bb!.__offset(this.bb_pos, 4);
return offset ? this.bb!.readFloat32(this.bb_pos + offset) : 0.0;
}
y():number {
const offset = this.bb!.__offset(this.bb_pos, 6);
return offset ? this.bb!.readFloat32(this.bb_pos + offset) : 0.0;
}
static startUnidentifiedGroup(builder:flatbuffers.Builder) {
builder.startObject(2);
}
static addX(builder:flatbuffers.Builder, x:number) {
builder.addFieldFloat32(0, x, 0.0);
}
static addY(builder:flatbuffers.Builder, y:number) {
builder.addFieldFloat32(1, y, 0.0);
}
static endUnidentifiedGroup(builder:flatbuffers.Builder):flatbuffers.Offset {
const offset = builder.endObject();
return offset;
}
static createUnidentifiedGroup(builder:flatbuffers.Builder, x:number, y:number):flatbuffers.Offset {
UnidentifiedGroup.startUnidentifiedGroup(builder);
UnidentifiedGroup.addX(builder, x);
UnidentifiedGroup.addY(builder, y);
return UnidentifiedGroup.endUnidentifiedGroup(builder);
}
unpack(): UnidentifiedGroupT {
return new UnidentifiedGroupT(
this.x(),
this.y()
);
}
unpackTo(_o: UnidentifiedGroupT): void {
_o.x = this.x();
_o.y = this.y();
}
}
export class UnidentifiedGroupT implements flatbuffers.IGeneratedObject {
constructor(
public x: number = 0.0,
public y: number = 0.0
){}
pack(builder:flatbuffers.Builder): flatbuffers.Offset {
return UnidentifiedGroup.createUnidentifiedGroup(builder,
this.x,
this.y
);
}
}
@@ -0,0 +1,102 @@
// automatically generated by the FlatBuffers compiler, do not modify
/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
import * as flatbuffers from 'flatbuffers';
export class UnidentifiedPlanet implements flatbuffers.IUnpackableObject<UnidentifiedPlanetT> {
bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0;
__init(i:number, bb:flatbuffers.ByteBuffer):UnidentifiedPlanet {
this.bb_pos = i;
this.bb = bb;
return this;
}
static getRootAsUnidentifiedPlanet(bb:flatbuffers.ByteBuffer, obj?:UnidentifiedPlanet):UnidentifiedPlanet {
return (obj || new UnidentifiedPlanet()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
static getSizePrefixedRootAsUnidentifiedPlanet(bb:flatbuffers.ByteBuffer, obj?:UnidentifiedPlanet):UnidentifiedPlanet {
bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
return (obj || new UnidentifiedPlanet()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
x():number {
const offset = this.bb!.__offset(this.bb_pos, 4);
return offset ? this.bb!.readFloat32(this.bb_pos + offset) : 0.0;
}
y():number {
const offset = this.bb!.__offset(this.bb_pos, 6);
return offset ? this.bb!.readFloat32(this.bb_pos + offset) : 0.0;
}
number():bigint {
const offset = this.bb!.__offset(this.bb_pos, 8);
return offset ? this.bb!.readUint64(this.bb_pos + offset) : BigInt('0');
}
static startUnidentifiedPlanet(builder:flatbuffers.Builder) {
builder.startObject(3);
}
static addX(builder:flatbuffers.Builder, x:number) {
builder.addFieldFloat32(0, x, 0.0);
}
static addY(builder:flatbuffers.Builder, y:number) {
builder.addFieldFloat32(1, y, 0.0);
}
static addNumber(builder:flatbuffers.Builder, number:bigint) {
builder.addFieldInt64(2, number, BigInt('0'));
}
static endUnidentifiedPlanet(builder:flatbuffers.Builder):flatbuffers.Offset {
const offset = builder.endObject();
return offset;
}
static createUnidentifiedPlanet(builder:flatbuffers.Builder, x:number, y:number, number:bigint):flatbuffers.Offset {
UnidentifiedPlanet.startUnidentifiedPlanet(builder);
UnidentifiedPlanet.addX(builder, x);
UnidentifiedPlanet.addY(builder, y);
UnidentifiedPlanet.addNumber(builder, number);
return UnidentifiedPlanet.endUnidentifiedPlanet(builder);
}
unpack(): UnidentifiedPlanetT {
return new UnidentifiedPlanetT(
this.x(),
this.y(),
this.number()
);
}
unpackTo(_o: UnidentifiedPlanetT): void {
_o.x = this.x();
_o.y = this.y();
_o.number = this.number();
}
}
export class UnidentifiedPlanetT implements flatbuffers.IGeneratedObject {
constructor(
public x: number = 0.0,
public y: number = 0.0,
public number: bigint = BigInt('0')
){}
pack(builder:flatbuffers.Builder): flatbuffers.Offset {
return UnidentifiedPlanet.createUnidentifiedPlanet(builder,
this.x,
this.y,
this.number
);
}
}
@@ -0,0 +1,176 @@
// automatically generated by the FlatBuffers compiler, do not modify
/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
import * as flatbuffers from 'flatbuffers';
export class UninhabitedPlanet implements flatbuffers.IUnpackableObject<UninhabitedPlanetT> {
bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0;
__init(i:number, bb:flatbuffers.ByteBuffer):UninhabitedPlanet {
this.bb_pos = i;
this.bb = bb;
return this;
}
static getRootAsUninhabitedPlanet(bb:flatbuffers.ByteBuffer, obj?:UninhabitedPlanet):UninhabitedPlanet {
return (obj || new UninhabitedPlanet()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
static getSizePrefixedRootAsUninhabitedPlanet(bb:flatbuffers.ByteBuffer, obj?:UninhabitedPlanet):UninhabitedPlanet {
bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
return (obj || new UninhabitedPlanet()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
x():number {
const offset = this.bb!.__offset(this.bb_pos, 4);
return offset ? this.bb!.readFloat32(this.bb_pos + offset) : 0.0;
}
y():number {
const offset = this.bb!.__offset(this.bb_pos, 6);
return offset ? this.bb!.readFloat32(this.bb_pos + offset) : 0.0;
}
number():bigint {
const offset = this.bb!.__offset(this.bb_pos, 8);
return offset ? this.bb!.readUint64(this.bb_pos + offset) : BigInt('0');
}
size():number {
const offset = this.bb!.__offset(this.bb_pos, 10);
return offset ? this.bb!.readFloat32(this.bb_pos + offset) : 0.0;
}
name():string|null
name(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
name(optionalEncoding?:any):string|Uint8Array|null {
const offset = this.bb!.__offset(this.bb_pos, 12);
return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
}
resources():number {
const offset = this.bb!.__offset(this.bb_pos, 14);
return offset ? this.bb!.readFloat32(this.bb_pos + offset) : 0.0;
}
capital():number {
const offset = this.bb!.__offset(this.bb_pos, 16);
return offset ? this.bb!.readFloat32(this.bb_pos + offset) : 0.0;
}
material():number {
const offset = this.bb!.__offset(this.bb_pos, 18);
return offset ? this.bb!.readFloat32(this.bb_pos + offset) : 0.0;
}
static startUninhabitedPlanet(builder:flatbuffers.Builder) {
builder.startObject(8);
}
static addX(builder:flatbuffers.Builder, x:number) {
builder.addFieldFloat32(0, x, 0.0);
}
static addY(builder:flatbuffers.Builder, y:number) {
builder.addFieldFloat32(1, y, 0.0);
}
static addNumber(builder:flatbuffers.Builder, number:bigint) {
builder.addFieldInt64(2, number, BigInt('0'));
}
static addSize(builder:flatbuffers.Builder, size:number) {
builder.addFieldFloat32(3, size, 0.0);
}
static addName(builder:flatbuffers.Builder, nameOffset:flatbuffers.Offset) {
builder.addFieldOffset(4, nameOffset, 0);
}
static addResources(builder:flatbuffers.Builder, resources:number) {
builder.addFieldFloat32(5, resources, 0.0);
}
static addCapital(builder:flatbuffers.Builder, capital:number) {
builder.addFieldFloat32(6, capital, 0.0);
}
static addMaterial(builder:flatbuffers.Builder, material:number) {
builder.addFieldFloat32(7, material, 0.0);
}
static endUninhabitedPlanet(builder:flatbuffers.Builder):flatbuffers.Offset {
const offset = builder.endObject();
return offset;
}
static createUninhabitedPlanet(builder:flatbuffers.Builder, x:number, y:number, number:bigint, size:number, nameOffset:flatbuffers.Offset, resources:number, capital:number, material:number):flatbuffers.Offset {
UninhabitedPlanet.startUninhabitedPlanet(builder);
UninhabitedPlanet.addX(builder, x);
UninhabitedPlanet.addY(builder, y);
UninhabitedPlanet.addNumber(builder, number);
UninhabitedPlanet.addSize(builder, size);
UninhabitedPlanet.addName(builder, nameOffset);
UninhabitedPlanet.addResources(builder, resources);
UninhabitedPlanet.addCapital(builder, capital);
UninhabitedPlanet.addMaterial(builder, material);
return UninhabitedPlanet.endUninhabitedPlanet(builder);
}
unpack(): UninhabitedPlanetT {
return new UninhabitedPlanetT(
this.x(),
this.y(),
this.number(),
this.size(),
this.name(),
this.resources(),
this.capital(),
this.material()
);
}
unpackTo(_o: UninhabitedPlanetT): void {
_o.x = this.x();
_o.y = this.y();
_o.number = this.number();
_o.size = this.size();
_o.name = this.name();
_o.resources = this.resources();
_o.capital = this.capital();
_o.material = this.material();
}
}
export class UninhabitedPlanetT implements flatbuffers.IGeneratedObject {
constructor(
public x: number = 0.0,
public y: number = 0.0,
public number: bigint = BigInt('0'),
public size: number = 0.0,
public name: string|Uint8Array|null = null,
public resources: number = 0.0,
public capital: number = 0.0,
public material: number = 0.0
){}
pack(builder:flatbuffers.Builder): flatbuffers.Offset {
const name = (this.name !== null ? builder.createString(this.name!) : 0);
return UninhabitedPlanet.createUninhabitedPlanet(builder,
this.x,
this.y,
this.number,
this.size,
name,
this.resources,
this.capital,
this.material
);
}
}
@@ -12,11 +12,20 @@ layout owns:
header view-menu naturally drops the overlay even if `mobileTool`
was set on a previous tap.
Phase 11 adds the per-game `GameStateStore` instance owned by this
layout: it constructs the `GalaxyClient`, fetches the matching lobby
record to discover `current_turn`, then loads the report. The store
is shared with descendants via `setContext("gameState", ...)` so the
header turn counter, the map view, and later inspector tabs all read
from the same snapshot.
State preservation across active-view switches works for free
because SvelteKit keeps this layout instance mounted while children
swap.
swap; navigating between games unmounts and remounts the layout, so
the next game's snapshot is loaded fresh.
-->
<script lang="ts">
import { onDestroy, onMount, setContext } from "svelte";
import { page } from "$app/state";
import Header from "$lib/header/header.svelte";
import Sidebar from "$lib/sidebar/sidebar.svelte";
@@ -24,6 +33,13 @@ swap.
import Calculator from "$lib/sidebar/calculator-tab.svelte";
import Order from "$lib/sidebar/order-tab.svelte";
import type { MobileTool } from "$lib/sidebar/types";
import { GameStateStore, GAME_STATE_CONTEXT_KEY } from "$lib/game-state.svelte";
import { session } from "$lib/session-store.svelte";
import { loadStore } from "../../../platform/store/index";
import { loadCore } from "../../../platform/core/index";
import { createEdgeGatewayClient } from "../../../api/connect";
import { GalaxyClient } from "../../../api/galaxy-client";
import { GATEWAY_BASE_URL, GATEWAY_RESPONSE_PUBLIC_KEY } from "$lib/env";
let { children } = $props();
@@ -36,9 +52,54 @@ swap.
isOnMap ? mobileTool : "map",
);
const gameState = new GameStateStore();
setContext(GAME_STATE_CONTEXT_KEY, gameState);
function toggleSidebar(): void {
sidebarOpen = !sidebarOpen;
}
async function sha256(payload: Uint8Array): Promise<Uint8Array> {
const digest = await crypto.subtle.digest("SHA-256", payload as BufferSource);
return new Uint8Array(digest);
}
onMount(() => {
(async (): Promise<void> => {
if (
session.keypair === null ||
session.deviceSessionId === null ||
GATEWAY_RESPONSE_PUBLIC_KEY.length === 0
) {
return;
}
const keypair = session.keypair;
const deviceSessionId = session.deviceSessionId;
try {
const [{ cache }, core] = await Promise.all([loadStore(), loadCore()]);
const client = new GalaxyClient({
core,
edge: createEdgeGatewayClient(GATEWAY_BASE_URL),
signer: (canonical) => keypair.sign(canonical),
sha256,
deviceSessionId,
gatewayResponsePublicKey: GATEWAY_RESPONSE_PUBLIC_KEY,
});
await gameState.init({ client, cache, gameId });
} catch (err) {
gameState.failBootstrap(describeBootstrapError(err));
}
})();
});
onDestroy(() => {
gameState.dispose();
});
function describeBootstrapError(err: unknown): string {
if (err instanceof Error) return err.message;
return "request failed";
}
</script>
<div class="game-shell" data-testid="game-shell">