mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-11-20 04:14:12 +01:00
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:
111 files changed
+4009
-3917
No files matched your search
@@ -8,8 +8,8 @@ import { resolveArmor } from "../core/blitzkit/resolveThickness";
|
||||
import { controlsEnabledEvent } from "../core/controlsEnabled";
|
||||
import { useArmor } from "../hooks/useArmor";
|
||||
import { useConsumable } from "../hooks/useConsumable";
|
||||
import { DuelModule, getDuel, useDuel } from "../hooks/useDuel";
|
||||
import { useDuelModel } from "../hooks/useDuelModel";
|
||||
import { useDuelModels } from "../hooks/useDuelModels";
|
||||
import { getDuelModules, useDuelModules } from "../hooks/useDuelModules";
|
||||
import { hasEquipment } from "../hooks/useEquipment";
|
||||
import { useModel } from "../hooks/useModel";
|
||||
import { useTankTransform } from "../hooks/useTankTransform";
|
||||
@@ -31,28 +31,22 @@ export const TankStaticArmor = memo<ArmorSceneProps>(({ thicknessRange }) => {
|
||||
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 protagonist = useDuelModules("protagonist");
|
||||
|
||||
const { gltf: armorGltf } = useArmor(tank.id);
|
||||
const { gltf: modelGltf } = useModel(tank.id);
|
||||
const { gltf: armorGltf } = useArmor(protagonist.tank.id);
|
||||
const { gltf: modelGltf } = useModel(protagonist.tank.id);
|
||||
const armorNodes = Object.values(armorGltf.nodes);
|
||||
const modelNodes = Object.values(modelGltf.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 canvas = useThree((state) => state.gl.domElement);
|
||||
|
||||
const maskOrigin =
|
||||
gunModelDefinition.mask === undefined
|
||||
models.gun.mask === undefined
|
||||
? undefined
|
||||
: gunModelDefinition.mask + hullOrigin.y + turretOrigin.y + gunOrigin.y;
|
||||
: models.gun.mask + hullOrigin.y + turretOrigin.y + gunOrigin.y;
|
||||
const showPrimaryArmor = TankopediaPersistent.use(
|
||||
(state) => state.showPrimaryArmor,
|
||||
);
|
||||
@@ -64,7 +58,12 @@ export const TankStaticArmor = memo<ArmorSceneProps>(({ thicknessRange }) => {
|
||||
);
|
||||
const isDynamicArmorActive = useConsumable("protagonist", 73);
|
||||
|
||||
useTankTransform(track, turret, turretContainer, gunContainer);
|
||||
useTankTransform(
|
||||
protagonist.track,
|
||||
protagonist.turret,
|
||||
turretContainer,
|
||||
gunContainer,
|
||||
);
|
||||
|
||||
return (
|
||||
<>
|
||||
@@ -74,7 +73,7 @@ export const TankStaticArmor = memo<ArmorSceneProps>(({ thicknessRange }) => {
|
||||
const isVisible = isHull;
|
||||
const armorId = nameToArmorId(node.name);
|
||||
const { spaced, thickness } = resolveArmor(
|
||||
tankModelDefinition.armor!,
|
||||
models.tank.armor!,
|
||||
armorId,
|
||||
);
|
||||
|
||||
@@ -115,7 +114,7 @@ export const TankStaticArmor = memo<ArmorSceneProps>(({ thicknessRange }) => {
|
||||
thicknessRange={thicknessRange}
|
||||
key={node.uuid}
|
||||
type={ArmorType.External}
|
||||
thickness={trackModelDefinition.thickness}
|
||||
thickness={models.track.thickness}
|
||||
variant="track"
|
||||
node={node}
|
||||
onPointerDown={(event) => event.stopPropagation()}
|
||||
@@ -126,12 +125,12 @@ export const TankStaticArmor = memo<ArmorSceneProps>(({ thicknessRange }) => {
|
||||
<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,
|
||||
);
|
||||
|
||||
@@ -164,7 +163,7 @@ export const TankStaticArmor = memo<ArmorSceneProps>(({ thicknessRange }) => {
|
||||
window.addEventListener("pointerup", handlePointerUp);
|
||||
}
|
||||
function handlePointerMove(event: PointerEvent) {
|
||||
const protagonist = getDuel("protagonist", DuelModule.Tank);
|
||||
const protagonist = getDuelModules("protagonist").tank;
|
||||
|
||||
const hasImprovedVerticalStabilizer = hasEquipment(
|
||||
122,
|
||||
@@ -185,8 +184,8 @@ export const TankStaticArmor = memo<ArmorSceneProps>(({ thicknessRange }) => {
|
||||
modelTransformEvent.last!.pitch,
|
||||
modelTransformEvent.last!.yaw +
|
||||
delta.x * (Math.PI / boundingRect.width),
|
||||
gunModelDefinition.pitch!,
|
||||
turretModelDefinition.yaw,
|
||||
models.gun.pitch!,
|
||||
models.turret.yaw,
|
||||
hasImprovedVerticalStabilizer,
|
||||
hasDownImprovedVerticalStabilizer,
|
||||
);
|
||||
@@ -217,12 +216,12 @@ export const TankStaticArmor = memo<ArmorSceneProps>(({ thicknessRange }) => {
|
||||
<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,
|
||||
);
|
||||
|
||||
@@ -254,7 +253,7 @@ export const TankStaticArmor = memo<ArmorSceneProps>(({ thicknessRange }) => {
|
||||
window.addEventListener("pointerup", handlePointerUp);
|
||||
}
|
||||
function handlePointerMove(event: PointerEvent) {
|
||||
const protagonist = getDuel("protagonist", DuelModule.Tank);
|
||||
const protagonist = getDuelModules("protagonist").tank;
|
||||
|
||||
const hasImprovedVerticalStabilizer = hasEquipment(
|
||||
122,
|
||||
@@ -275,8 +274,8 @@ export const TankStaticArmor = memo<ArmorSceneProps>(({ thicknessRange }) => {
|
||||
delta.y * (Math.PI / boundingRect.height),
|
||||
modelTransformEvent.last!.yaw +
|
||||
delta.x * (Math.PI / boundingRect.width),
|
||||
gunModelDefinition.pitch!,
|
||||
turretModelDefinition.yaw,
|
||||
models.gun.pitch!,
|
||||
models.turret.yaw,
|
||||
hasImprovedVerticalStabilizer,
|
||||
hasDownImprovedVerticalStabilizer,
|
||||
);
|
||||
@@ -305,10 +304,10 @@ export const TankStaticArmor = memo<ArmorSceneProps>(({ thicknessRange }) => {
|
||||
})}
|
||||
|
||||
{modelNodes.map((node) => {
|
||||
const gunString = `gun_${gunModelDefinition.model_id
|
||||
const gunString = `gun_${models.gun.model_id
|
||||
.toString()
|
||||
.padStart(2, "0")}`;
|
||||
const isCurrentGun = gunModelDefinition.mask
|
||||
const isCurrentGun = models.gun.mask
|
||||
? node.name.startsWith(gunString)
|
||||
: node.name === gunString;
|
||||
const isVisible = isCurrentGun;
|
||||
@@ -332,7 +331,7 @@ export const TankStaticArmor = memo<ArmorSceneProps>(({ thicknessRange }) => {
|
||||
window.addEventListener("pointerup", handlePointerUp);
|
||||
}
|
||||
function handlePointerMove(event: PointerEvent) {
|
||||
const protagonist = getDuel("protagonist", DuelModule.Tank);
|
||||
const protagonist = getDuelModules("protagonist").tank;
|
||||
|
||||
const hasImprovedVerticalStabilizer = hasEquipment(
|
||||
122,
|
||||
@@ -353,8 +352,8 @@ export const TankStaticArmor = memo<ArmorSceneProps>(({ thicknessRange }) => {
|
||||
delta.y * (Math.PI / boundingRect.height),
|
||||
modelTransformEvent.last!.yaw +
|
||||
delta.x * (Math.PI / boundingRect.width),
|
||||
gunModelDefinition.pitch!,
|
||||
turretModelDefinition.yaw,
|
||||
models.gun.pitch!,
|
||||
models.turret.yaw,
|
||||
hasImprovedVerticalStabilizer,
|
||||
hasDownImprovedVerticalStabilizer,
|
||||
);
|
||||
@@ -373,7 +372,7 @@ export const TankStaticArmor = memo<ArmorSceneProps>(({ thicknessRange }) => {
|
||||
thicknessRange={thicknessRange}
|
||||
key={node.uuid}
|
||||
type={ArmorType.External}
|
||||
thickness={gunModelDefinition.thickness}
|
||||
thickness={models.gun.thickness}
|
||||
variant="gun"
|
||||
node={node}
|
||||
clip={
|
||||
|
||||
Reference in new issue
Block a user