mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-24 03:59:50 +02:00
feat: he mechanics
This commit is contained in:
1 parent
bf6991ce06
commit
fa8922e0a6
3 files changed
+33
-20
No files matched your search
@@ -26,6 +26,9 @@ const LENGTH_INFINITY = 4;
|
|||||||
|
|
||||||
export function ShotDisplay() {
|
export function ShotDisplay() {
|
||||||
const shot = useTankopediaTemporary((state) => state.shot);
|
const shot = useTankopediaTemporary((state) => state.shot);
|
||||||
|
const hasMultipleLayers = shot?.some(
|
||||||
|
(layer, index) => index !== 0 && layer.type !== null,
|
||||||
|
);
|
||||||
|
|
||||||
console.log(shot);
|
console.log(shot);
|
||||||
|
|
||||||
@@ -40,6 +43,9 @@ export function ShotDisplay() {
|
|||||||
J_HAT.angleTo(layer.shellNormal),
|
J_HAT.angleTo(layer.shellNormal),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
const nextLayer = shot[index + 1] as ShotLayerGap | undefined;
|
||||||
|
const trueStatus =
|
||||||
|
nextLayer?.status === 'wasted' ? 'blocked' : layer.status;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@@ -52,16 +58,16 @@ export function ShotDisplay() {
|
|||||||
<Card
|
<Card
|
||||||
style={{
|
style={{
|
||||||
backgroundColor:
|
backgroundColor:
|
||||||
layer.status === 'penetration'
|
trueStatus === 'penetration'
|
||||||
? '#00ff0080'
|
? '#00ff0080'
|
||||||
: layer.status === 'blocked'
|
: trueStatus === 'blocked'
|
||||||
? '#ff000080'
|
? '#ff000080'
|
||||||
: '#ffff0080',
|
: '#ffff0080',
|
||||||
border: 'none',
|
border: 'none',
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Inset>
|
<Inset>
|
||||||
{shot.length > 1 && (
|
{hasMultipleLayers && (
|
||||||
<Text
|
<Text
|
||||||
style={{
|
style={{
|
||||||
width: '100%',
|
width: '100%',
|
||||||
|
|||||||
@@ -92,6 +92,7 @@ export function SpacedArmorSceneComponent({
|
|||||||
const hasEnhancedArmor = await hasEquipment(110);
|
const hasEnhancedArmor = await hasEquipment(110);
|
||||||
const thicknessCoefficient = hasEnhancedArmor ? 1.04 : 1;
|
const thicknessCoefficient = hasEnhancedArmor ? 1.04 : 1;
|
||||||
const shell = useDuel.getState().antagonist!.shell;
|
const shell = useDuel.getState().antagonist!.shell;
|
||||||
|
const explosive = isExplosive(shell.type);
|
||||||
const penetration =
|
const penetration =
|
||||||
resolveNearPenetration(shell.penetration) *
|
resolveNearPenetration(shell.penetration) *
|
||||||
(hasCalibratedShells
|
(hasCalibratedShells
|
||||||
@@ -117,18 +118,6 @@ export function SpacedArmorSceneComponent({
|
|||||||
0,
|
0,
|
||||||
);
|
);
|
||||||
|
|
||||||
// console.clear();
|
|
||||||
// console.log(
|
|
||||||
// JSON.stringify(
|
|
||||||
// shot.map((i) => ({
|
|
||||||
// ...i,
|
|
||||||
// ...(i.angle ? { angle: radToDeg(i.angle) } : {}),
|
|
||||||
// })),
|
|
||||||
// null,
|
|
||||||
// 2,
|
|
||||||
// ),
|
|
||||||
// );
|
|
||||||
|
|
||||||
function filterIntersections(intersectionsRaw: Intersection[]) {
|
function filterIntersections(intersectionsRaw: Intersection[]) {
|
||||||
const intersectionsAll = intersectionsRaw.filter(
|
const intersectionsAll = intersectionsRaw.filter(
|
||||||
({ object }) => object.userData.type !== undefined,
|
({ object }) => object.userData.type !== undefined,
|
||||||
@@ -183,12 +172,20 @@ export function SpacedArmorSceneComponent({
|
|||||||
let loopIndex = 0;
|
let loopIndex = 0;
|
||||||
|
|
||||||
if (layerIndex !== 0 && intersections.length > 0) {
|
if (layerIndex !== 0 && intersections.length > 0) {
|
||||||
|
const distance = (
|
||||||
|
shot.at(-1) as ShotLayerBase
|
||||||
|
).point.distanceTo(intersections[0].point);
|
||||||
|
if (explosive)
|
||||||
|
remainingPenetration -= 0.5 * remainingPenetration * distance;
|
||||||
|
const wasted = remainingPenetration < 0;
|
||||||
|
|
||||||
shot.push({
|
shot.push({
|
||||||
type: null,
|
type: null,
|
||||||
distance: (shot.at(-1) as ShotLayerBase).point.distanceTo(
|
status: wasted ? 'wasted' : 'nominal',
|
||||||
intersections[0].point,
|
distance,
|
||||||
),
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (wasted) return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const intersection of intersections) {
|
for (const intersection of intersections) {
|
||||||
@@ -202,11 +199,20 @@ export function SpacedArmorSceneComponent({
|
|||||||
|
|
||||||
if (layerIndex !== 0 && startingIndex === 0) {
|
if (layerIndex !== 0 && startingIndex === 0) {
|
||||||
const previousIntersection = intersections[layerIndex - 1];
|
const previousIntersection = intersections[layerIndex - 1];
|
||||||
|
const distance =
|
||||||
|
intersection.distance - previousIntersection.distance;
|
||||||
|
if (explosive)
|
||||||
|
remainingPenetration -=
|
||||||
|
0.5 * remainingPenetration * distance;
|
||||||
|
const wasted = remainingPenetration < 0;
|
||||||
|
|
||||||
shot.push({
|
shot.push({
|
||||||
type: null,
|
type: null,
|
||||||
distance:
|
status: wasted ? 'wasted' : 'nominal',
|
||||||
intersection.distance - previousIntersection.distance,
|
distance,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (wasted) return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (intersection.object.userData.type === ArmorType.External) {
|
if (intersection.object.userData.type === ArmorType.External) {
|
||||||
|
|||||||
@@ -65,6 +65,7 @@ interface ShotLayerNonExternal extends ShotLayerBase {
|
|||||||
|
|
||||||
export interface ShotLayerGap {
|
export interface ShotLayerGap {
|
||||||
type: null;
|
type: null;
|
||||||
|
status: 'nominal' | 'wasted';
|
||||||
distance: number;
|
distance: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user