mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-11-25 15:13:14 +01:00
119 lines
4.0 KiB
TypeScript
119 lines
4.0 KiB
TypeScript
import { Flex } from "@radix-ui/themes";
|
|
import { useEffect } from "react";
|
|
import { awaitableEquipmentDefinitions } from "../../../../../core/awaitables/equipmentDefinitions";
|
|
import { awaitableProvisionDefinitions } from "../../../../../core/awaitables/provisionDefinitions";
|
|
import { applyPitchYawLimits } from "../../../../../core/blitz/applyPitchYawLimits";
|
|
import { modelTransformEvent } from "../../../../../core/blitzkit/modelTransform";
|
|
import { tankCharacteristics } from "../../../../../core/blitzkit/tankCharacteristics";
|
|
import { useEquipment } from "../../../../../hooks/useEquipment";
|
|
import { useTankModelDefinition } from "../../../../../hooks/useTankModelDefinition";
|
|
import { Duel } from "../../../../../stores/duel";
|
|
import { Tankopedia } from "../../../../../stores/tankopedia";
|
|
import type { MaybeSkeletonComponentProps } from "../../../../../types/maybeSkeletonComponentProps";
|
|
import { Crew } from "./components/Crew";
|
|
import { Firepower } from "./components/Firepower";
|
|
import { Maneuverability } from "./components/Maneuverability";
|
|
import { Survivability } from "./components/Survivability";
|
|
|
|
const [equipmentDefinitions, provisionDefinitions] = await Promise.all([
|
|
awaitableEquipmentDefinitions,
|
|
awaitableProvisionDefinitions,
|
|
]);
|
|
|
|
export function Characteristics({ skeleton }: MaybeSkeletonComponentProps) {
|
|
const crewSkills = Tankopedia.use((state) => state.skills);
|
|
const provisions = Duel.use((state) => state.protagonist.provisions);
|
|
const consumables = Duel.use((state) => state.protagonist.consumables);
|
|
const camouflage = Duel.use((state) => state.protagonist.camouflage);
|
|
const assaultDistance = Duel.use(
|
|
(state) => state.protagonist.assaultDistance
|
|
);
|
|
const equipmentMatrix = Duel.use(
|
|
(state) => state.protagonist.equipmentMatrix
|
|
);
|
|
const { tank, turret, gun, engine, track, shell } = Duel.use(
|
|
(state) => state.protagonist
|
|
);
|
|
const stockEngine = tank.engines[0];
|
|
const stockTrack = tank.tracks[0];
|
|
const stockTurret = tank.turrets[0];
|
|
const stockGun = stockTurret.guns[0];
|
|
const tankModelDefinition = useTankModelDefinition();
|
|
const turretModelDefinition = tankModelDefinition.turrets[turret.id];
|
|
const gunModelDefinition = turretModelDefinition.guns[gun.id];
|
|
const stats = tankCharacteristics(
|
|
{
|
|
tank,
|
|
camouflage,
|
|
consumables,
|
|
crewSkills,
|
|
engine,
|
|
equipmentMatrix,
|
|
gun,
|
|
provisions,
|
|
shell,
|
|
turret,
|
|
track,
|
|
stockEngine,
|
|
stockGun,
|
|
stockTrack,
|
|
stockTurret,
|
|
applyReactiveArmor: false,
|
|
applyDynamicArmor: false,
|
|
applySpallLiner: false,
|
|
assaultDistance,
|
|
},
|
|
{
|
|
tankModelDefinition,
|
|
equipmentDefinitions: equipmentDefinitions,
|
|
provisionDefinitions: provisionDefinitions,
|
|
}
|
|
);
|
|
|
|
const hasImprovedVerticalStabilizer = useEquipment(122);
|
|
const hasDownImprovedVerticalStabilizer = useEquipment(124);
|
|
|
|
useEffect(() => {
|
|
const [pitch, yaw] = applyPitchYawLimits(
|
|
modelTransformEvent.last!.pitch,
|
|
modelTransformEvent.last!.yaw,
|
|
gunModelDefinition.pitch,
|
|
turretModelDefinition.yaw,
|
|
hasImprovedVerticalStabilizer,
|
|
hasDownImprovedVerticalStabilizer
|
|
);
|
|
|
|
modelTransformEvent.dispatch({ pitch, yaw });
|
|
}, [hasImprovedVerticalStabilizer, hasDownImprovedVerticalStabilizer]);
|
|
|
|
return (
|
|
<Flex
|
|
gap="8"
|
|
direction={{ initial: "column", md: "row" }}
|
|
align={{ initial: "center", sm: "start" }}
|
|
width={{ initial: "100%", sm: "auto" }}
|
|
>
|
|
<Firepower skeleton={skeleton} stats={stats} />
|
|
|
|
<Flex
|
|
gap="8"
|
|
direction={{ initial: "column", lg: "row" }}
|
|
align={{ initial: "center", sm: "start" }}
|
|
width={{ initial: "100%", sm: "auto" }}
|
|
>
|
|
<Maneuverability stats={stats} />
|
|
|
|
<Flex
|
|
gap="8"
|
|
direction="column"
|
|
align={{ initial: "center", sm: "start" }}
|
|
width={{ initial: "100%", sm: "auto" }}
|
|
>
|
|
<Survivability stats={stats} />
|
|
<Crew stats={stats} />
|
|
</Flex>
|
|
</Flex>
|
|
</Flex>
|
|
);
|
|
}
|