diff --git a/src/components/Armor/components/ShotDisplay.tsx b/src/components/Armor/components/ShotDisplay.tsx index 172279a7e..147cb71cf 100644 --- a/src/components/Armor/components/ShotDisplay.tsx +++ b/src/components/Armor/components/ShotDisplay.tsx @@ -26,6 +26,9 @@ const LENGTH_INFINITY = 4; export function ShotDisplay() { const shot = useTankopediaTemporary((state) => state.shot); + const hasMultipleLayers = shot?.some( + (layer, index) => index !== 0 && layer.type !== null, + ); console.log(shot); @@ -40,6 +43,9 @@ export function ShotDisplay() { J_HAT.angleTo(layer.shellNormal), ), ); + const nextLayer = shot[index + 1] as ShotLayerGap | undefined; + const trueStatus = + nextLayer?.status === 'wasted' ? 'blocked' : layer.status; return ( <> @@ -52,16 +58,16 @@ export function ShotDisplay() { - {shot.length > 1 && ( + {hasMultipleLayers && ( ({ - // ...i, - // ...(i.angle ? { angle: radToDeg(i.angle) } : {}), - // })), - // null, - // 2, - // ), - // ); - function filterIntersections(intersectionsRaw: Intersection[]) { const intersectionsAll = intersectionsRaw.filter( ({ object }) => object.userData.type !== undefined, @@ -183,12 +172,20 @@ export function SpacedArmorSceneComponent({ let loopIndex = 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({ type: null, - distance: (shot.at(-1) as ShotLayerBase).point.distanceTo( - intersections[0].point, - ), + status: wasted ? 'wasted' : 'nominal', + distance, }); + + if (wasted) return; } for (const intersection of intersections) { @@ -202,11 +199,20 @@ export function SpacedArmorSceneComponent({ if (layerIndex !== 0 && startingIndex === 0) { const previousIntersection = intersections[layerIndex - 1]; + const distance = + intersection.distance - previousIntersection.distance; + if (explosive) + remainingPenetration -= + 0.5 * remainingPenetration * distance; + const wasted = remainingPenetration < 0; + shot.push({ type: null, - distance: - intersection.distance - previousIntersection.distance, + status: wasted ? 'wasted' : 'nominal', + distance, }); + + if (wasted) return; } if (intersection.object.userData.type === ArmorType.External) { diff --git a/src/stores/tankopedia.ts b/src/stores/tankopedia.ts index c83f6d8fe..0d9137415 100644 --- a/src/stores/tankopedia.ts +++ b/src/stores/tankopedia.ts @@ -65,6 +65,7 @@ interface ShotLayerNonExternal extends ShotLayerBase { export interface ShotLayerGap { type: null; + status: 'nominal' | 'wasted'; distance: number; }