2026-09-23 17:37:52 -05:00
|
|
|
import { createDefaultSkills } from "@blitzkit/core";
|
2026-09-30 17:36:51 -05:00
|
|
|
import type { ShellDefinition, 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";
|
2025-09-01 22:56:39 -05:00
|
|
|
import type { XP_MULTIPLIERS } from "../components/Tankopedia/TechTreeSection";
|
2026-09-23 10:22:57 -05:00
|
|
|
import { createTankState } from "../tankopedia/createTankState";
|
|
|
|
|
import type { TankState } from "../tankopedia/tankState";
|
2025-09-01 22:56:39 -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;
|
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 {
|
|
|
|
|
Class,
|
|
|
|
|
Tier,
|
|
|
|
|
All,
|
|
|
|
|
}
|
|
|
|
|
|
2026-10-01 15:52:14 -05:00
|
|
|
export interface TankEnvironment {
|
|
|
|
|
equalize: boolean;
|
2026-10-04 17:57:12 -05:00
|
|
|
distance: number;
|
2026-10-01 15:52:14 -05:00
|
|
|
}
|
|
|
|
|
|
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
|
|
|
|
2024-09-21 20:26:58 -05:00
|
|
|
shot?: Shot;
|
|
|
|
|
skills: Record<string, number>;
|
2024-11-12 20:58:05 -06:00
|
|
|
relativeAgainst: TankopediaRelativeAgainst;
|
2024-09-21 20:26:58 -05:00
|
|
|
editStatic: boolean;
|
|
|
|
|
highlightArmor?: {
|
|
|
|
|
editingPlate: boolean;
|
|
|
|
|
name: string;
|
|
|
|
|
point: Vector3;
|
|
|
|
|
thickness: number;
|
|
|
|
|
color: string;
|
|
|
|
|
} & (
|
|
|
|
|
| {
|
|
|
|
|
type: ArmorType.Primary | ArmorType.Spaced;
|
|
|
|
|
thicknessAngled: number;
|
|
|
|
|
angle: number;
|
|
|
|
|
}
|
|
|
|
|
| { type: ArmorType.External }
|
2024-09-14 18:32:36 -05:00
|
|
|
);
|
2024-09-21 20:26:58 -05:00
|
|
|
xpMultiplier: (typeof XP_MULTIPLIERS)[number];
|
2024-11-10 20:50:46 -06:00
|
|
|
customShell?: ShellDefinition;
|
2025-11-26 21:10:03 -06:00
|
|
|
requestedDisplay: TankopediaDisplay;
|
2024-12-01 20:23:23 -06:00
|
|
|
display: TankopediaDisplay;
|
2025-04-24 22:04:33 -05:00
|
|
|
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();
|
|
|
|
|
const models = await api.models();
|
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),
|
|
|
|
|
model: models.models[tank.id],
|
2026-09-22 16:13:27 -05:00
|
|
|
|
2026-10-04 17:57:12 -05:00
|
|
|
environment: { equalize: false, distance: 0 },
|
2026-09-27 16:26:28 -05:00
|
|
|
|
2026-09-30 17:36:51 -05:00
|
|
|
relativeAgainst: TankopediaRelativeAgainst.Class,
|
|
|
|
|
editStatic: false,
|
|
|
|
|
skills: createDefaultSkills(skills),
|
|
|
|
|
xpMultiplier: 1,
|
|
|
|
|
requestedDisplay: TankopediaDisplay.Model,
|
|
|
|
|
display: TankopediaDisplay.Model,
|
|
|
|
|
}),
|
|
|
|
|
);
|