Files
blitzkit/packages/website/src/stores/tankopedia.ts
T

152 lines
3.5 KiB
TypeScript
Raw Normal View History

2026-10-15 00:38:01 -05:00
import { createDefaultEnvironment, type TankEnvironment } from "@blitzkit/core";
2026-10-31 13:38:57 -05:00
import type { TankDefinition } from "@blitzkit/protos";
2026-09-27 17:04:15 -05:00
import { Soapstone } from "soapstone";
2026-09-30 17:36:51 -05:00
import type { Vector3 } from "three";
2026-09-23 10:25:47 -05:00
import { api } from "../api/dynamic";
2026-09-27 16:46:22 -05:00
import type { ArmorType } from "../components/SpacedArmorScene";
import type { ExternalModuleVariant } from "../components/SpacedArmorSceneComponent";
2026-09-23 10:22:57 -05:00
import { createTankState } from "../tankopedia/createTankState";
import type { TankState } from "../tankopedia/tankState";
import { App } from "./app";
2026-10-31 13:41:41 -05:00
import { TankopediaDisplay } from "./tankopediaPersistent/constants";
2024-07-09 14:43:33 -05:00
export interface ShotLayerBase {
index: number;
thickness: number;
point: Vector3;
surfaceNormal: Vector3;
2025-09-01 22:56:39 -05:00
status: "blocked" | "penetration" | "ricochet";
2024-07-09 14:43:33 -05:00
}
interface ShotLayerExternal extends ShotLayerBase {
type: ArmorType.External;
variant: ExternalModuleVariant;
}
export interface ShotLayerNonExternal extends ShotLayerBase {
type: Exclude<ArmorType, ArmorType.External>;
angle: number;
thicknessAngled: number;
}
export interface ShotLayerGap {
type: null;
2025-09-01 22:56:39 -05:00
status: "penetration" | "blocked";
2024-07-09 14:43:33 -05:00
distance: number;
}
export type ShotLayer = ShotLayerExternal | ShotLayerNonExternal | ShotLayerGap;
export type Shot = {
containsGaps: boolean;
damage: number;
2024-07-23 21:01:32 -05:00
splashRadius?: number;
penetrationChance?: number;
2024-07-09 14:43:33 -05:00
in: {
surfaceNormal: Vector3;
status: ShotStatus;
layers: ShotLayer[];
};
out?: {
surfaceNormal: Vector3;
status: ShotStatus;
layers: ShotLayer[];
};
};
2025-09-01 22:56:39 -05:00
export type ShotStatus = "penetration" | "blocked" | "ricochet" | "splash";
2024-07-09 14:43:33 -05:00
export type ArmorPiercingLayer =
| {
distance: number;
nominal: number;
angled: number;
ricochet: boolean;
2025-09-01 22:56:39 -05:00
type: "core" | "spaced" | "external";
2024-07-09 14:43:33 -05:00
}
| {
2025-09-01 22:56:39 -05:00
type: "gap";
2024-07-09 14:43:33 -05:00
gap: number;
};
2024-11-12 20:58:05 -06:00
export enum TankopediaRelativeAgainst {
2026-10-11 15:44:42 -05:00
ClassAndTier,
2024-11-12 20:58:05 -06:00
Tier,
All,
}
interface LoaderState<Type> {
requested: Type;
loaded: Type;
}
2026-10-31 13:48:15 -05:00
type HighlightArmor = {
editingPlate: boolean;
name: string;
point: Vector3;
thickness: number;
color: string;
} & (
| {
type: ArmorType.Primary | ArmorType.Spaced;
thicknessAngled: number;
angle: number;
}
| { type: ArmorType.External }
);
2025-09-01 22:56:39 -05:00
interface Tankopedia {
2025-04-14 19:26:41 -05:00
disturbed: boolean;
2025-04-15 00:35:12 -05:00
revealed: boolean;
2026-09-22 16:13:27 -05:00
protagonist: TankState;
2026-09-23 17:37:52 -05:00
antagonist: TankState;
2026-10-01 15:52:14 -05:00
environment: TankEnvironment;
2026-09-22 16:13:27 -05:00
2026-10-11 15:44:42 -05:00
relative_against: TankopediaRelativeAgainst;
loaders: {
2026-10-31 13:38:57 -05:00
display: LoaderState<TankopediaDisplay>;
model: LoaderState<boolean>;
skin: LoaderState<number | undefined>;
attachment: LoaderState<number | undefined>;
};
2026-10-31 13:38:57 -05:00
2026-10-31 13:48:15 -05:00
shot?: Shot;
highlightArmor?: HighlightArmor;
2026-10-31 13:38:57 -05:00
// editStatic: boolean;
2026-10-31 13:48:15 -05:00
2026-10-31 13:38:57 -05:00
// xpMultiplier: (typeof XP_MULTIPLIERS)[number];
// customShell?: ShellDefinition;
// statSearch?: string;
2024-09-21 20:26:58 -05:00
}
2024-09-22 21:12:18 -05:00
2026-09-22 16:13:27 -05:00
const skills = await api.skills();
2024-10-18 11:20:52 -05:00
2026-09-30 17:36:51 -05:00
export const Tankopedia = new Soapstone<Tankopedia, [TankDefinition]>(
(tank) => ({
disturbed: false,
revealed: false,
2026-09-22 16:13:27 -05:00
2026-09-30 17:36:51 -05:00
protagonist: createTankState(tank),
antagonist: createTankState(tank),
2026-10-15 00:38:01 -05:00
environment: createDefaultEnvironment(skills),
2026-09-27 16:26:28 -05:00
2026-10-11 15:44:42 -05:00
relative_against: TankopediaRelativeAgainst.ClassAndTier,
2026-10-31 13:38:57 -05:00
loaders: {
2026-10-31 13:41:41 -05:00
display: {
requested: TankopediaDisplay.Model,
loaded: TankopediaDisplay.Model,
},
2026-10-31 13:38:57 -05:00
model: { requested: App.state.autoLoadModels, loaded: false },
skin: { requested: undefined, loaded: undefined },
attachment: { requested: undefined, loaded: undefined },
},
2026-10-11 00:34:39 -05:00
2026-09-30 17:36:51 -05:00
editStatic: false,
xpMultiplier: 1,
}),
);