migrate compare and tankopedia loadout to new data-driven components, splitting the old monolithic loadout and compare UI into smaller pieces and adding shared Table, Dialog and Scroller primitives

This commit is contained in:
tresabhi committed 2026-11-14 01:17:38 -06:00
1 parent 287aba853f
commit c311a6ab8b
111 files changed
+4009 -3917

No files matched your search

@@ -4,8 +4,8 @@ import { nameToArmorId } from "../core/blitzkit/nameToArmorId";
import { resolveArmor } from "../core/blitzkit/resolveThickness";
import { useArmor } from "../hooks/useArmor";
import { useConsumable } from "../hooks/useConsumable";
import { DuelModule, useDuel } from "../hooks/useDuel";
import { useDuelModel } from "../hooks/useDuelModel";
import { useDuelModels } from "../hooks/useDuelModels";
import { useDuelModules } from "../hooks/useDuelModules";
import { useTankTransform } from "../hooks/useTankTransform";
import { toThreeVector } from "../three/toThreeVector";
import { PrimaryArmorSceneComponent } from "./PrimaryArmorSceneComponent";
@@ -13,22 +13,21 @@ import { PrimaryArmorSceneComponent } from "./PrimaryArmorSceneComponent";
export const PrimaryArmorScene = memo(() => {
const turretContainer = useRef<Group>(null!);
const gunContainer = useRef<Group>(null!);
const tank = useDuel("protagonist", DuelModule.Tank);
const track = useDuel("protagonist", DuelModule.Track);
const turret = useDuel("protagonist", DuelModule.Turret);
const gun = useDuel("protagonist", DuelModule.Gun);
const armorGltf = useArmor(tank.id).gltf;
const protagonist = useDuelModules("protagonist");
const armorGltf = useArmor(protagonist.tank.id).gltf;
const armorNodes = Object.values(armorGltf.nodes);
const tankModelDefinition = useDuelModel("protagonist");
const trackModelDefinition = tankModelDefinition.tracks[track.id];
const turretModelDefinition = tankModelDefinition.turrets[turret.id];
const gunModelDefinition = turretModelDefinition.guns[gun.id];
const hullOrigin = toThreeVector(trackModelDefinition.origin);
const turretOrigin = toThreeVector(tankModelDefinition.turret_origin);
const gunOrigin = toThreeVector(turretModelDefinition.gun_origin);
const models = useDuelModels("protagonist");
const hullOrigin = toThreeVector(models.track.origin);
const turretOrigin = toThreeVector(models.tank.turret_origin);
const gunOrigin = toThreeVector(models.turret.gun_origin);
const isDynamicArmorActive = useConsumable("protagonist", 73);
useTankTransform(track, turret, turretContainer, gunContainer);
useTankTransform(
protagonist.track,
protagonist.turret,
turretContainer,
gunContainer,
);
return (
<>
@@ -38,7 +37,7 @@ export const PrimaryArmorScene = memo(() => {
const isVisible = isHull;
const armorId = nameToArmorId(node.name);
const { spaced, thickness } = resolveArmor(
tankModelDefinition.armor!,
models.tank.armor!,
armorId,
);
@@ -64,14 +63,12 @@ export const PrimaryArmorScene = memo(() => {
<group ref={turretContainer}>
{armorNodes.map((node) => {
const isCurrentTurret = node.name.startsWith(
`turret_${turretModelDefinition.model_id
.toString()
.padStart(2, "0")}`,
`turret_${models.turret.model_id.toString().padStart(2, "0")}`,
);
const isVisible = isCurrentTurret;
const armorId = nameToArmorId(node.name);
const { spaced, thickness } = resolveArmor(
turretModelDefinition.armor!,
models.turret.armor!,
armorId,
);
@@ -100,12 +97,12 @@ export const PrimaryArmorScene = memo(() => {
<group ref={gunContainer}>
{armorNodes.map((node) => {
const isCurrentGun = node.name.startsWith(
`gun_${gunModelDefinition.model_id.toString().padStart(2, "0")}`,
`gun_${models.gun.model_id.toString().padStart(2, "0")}`,
);
const isVisible = isCurrentGun;
const armorId = nameToArmorId(node.name);
const { spaced, thickness } = resolveArmor(
gunModelDefinition.armor!,
models.gun.armor!,
armorId,
);