From 68273ea2958c57c98fbe0135290e99ec487583d9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tr=C3=A8sAbhi?= <43380238+tresabhi@users.noreply.github.com>
Date: Fri, 9 Feb 2024 23:27:47 -0600
Subject: [PATCH] feat: simplified shell stats
---
.vscode/settings.json | 1 +
.../Characteristics/components/Modules.tsx | 21 +++
.../[id]/components/Characteristics/index.tsx | 157 ++++++++++--------
src/core/blitzkrieg/equipmentDefinitions.ts | 2 -
4 files changed, 107 insertions(+), 74 deletions(-)
diff --git a/.vscode/settings.json b/.vscode/settings.json
index e0a5302e1..b2a9e4d06 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -56,6 +56,7 @@
"krieg",
"Leaderboard",
"leaderboards",
+ "lerp",
"LINEARSIZE",
"loddist",
"lods",
diff --git a/src/app/tools/tankopedia/[id]/components/Characteristics/components/Modules.tsx b/src/app/tools/tankopedia/[id]/components/Characteristics/components/Modules.tsx
index 789581d4e..3e75879aa 100644
--- a/src/app/tools/tankopedia/[id]/components/Characteristics/components/Modules.tsx
+++ b/src/app/tools/tankopedia/[id]/components/Characteristics/components/Modules.tsx
@@ -102,6 +102,27 @@ export function Modules() {
);
})}
+
+
+ {protagonist.gun.shells.map((shell, index) => {
+ return (
+ {
+ mutateDuel((draft) => {
+ draft.protagonist!.shell = shell;
+ });
+ }}
+ />
+ );
+ })}
+
);
diff --git a/src/app/tools/tankopedia/[id]/components/Characteristics/index.tsx b/src/app/tools/tankopedia/[id]/components/Characteristics/index.tsx
index 4bc4a6045..dfb0abff0 100644
--- a/src/app/tools/tankopedia/[id]/components/Characteristics/index.tsx
+++ b/src/app/tools/tankopedia/[id]/components/Characteristics/index.tsx
@@ -1,14 +1,12 @@
-import { Flex, Heading } from '@radix-ui/themes';
-import { use } from 'react';
-import { isExplosive } from '../../../../../../core/blitz/isExplosive';
+import { Flex, Heading, Slider, Text, TextField } from '@radix-ui/themes';
+import { debounce } from 'lodash';
+import { use, useEffect, useRef, useState } from 'react';
+import { lerp } from 'three/src/math/MathUtils';
import { resolveNearPenetration } from '../../../../../../core/blitz/resolveNearPenetration';
import { modelDefinitions } from '../../../../../../core/blitzkrieg/modelDefinitions';
import { normalizeBoundingBox } from '../../../../../../core/blitzkrieg/normalizeBoundingBox';
import { resolveDpm } from '../../../../../../core/blitzkrieg/resolveDpm';
-import {
- GUN_TYPE_NAMES,
- SHELL_NAMES,
-} from '../../../../../../core/blitzkrieg/tankDefinitions';
+import { GUN_TYPE_NAMES } from '../../../../../../core/blitzkrieg/tankDefinitions';
import { unionBoundingBox } from '../../../../../../core/blitzkrieg/unionBoundingBox';
import { useEquipment } from '../../../../../../core/blitzkrieg/useEquipmentEquipped';
import { useDuel } from '../../../../../../stores/duel';
@@ -43,6 +41,7 @@ export function Characteristics() {
stockTrack.weight +
stockTurret.weight +
stockGun.weight;
+ const [penetrationDistance, setPenetrationDistance] = useState(0);
const hasRammer = useEquipment(100);
const hasCalibratedShells = useEquipment(103);
const hasEnhancedGunLayingDrive = useEquipment(104);
@@ -56,12 +55,19 @@ export function Characteristics() {
const hasCamouflageNet = useEquipment(115);
const hasImprovedVerticalStabilizer = useEquipment(122);
const hasImprovedSuspension = useEquipment(123);
+ const penetrationDistanceInput = useRef(null);
/**
* TODO:
* - Improved Ventilation
*/
+ useEffect(() => {
+ if (penetrationDistanceInput.current) {
+ penetrationDistanceInput.current.value = `${penetrationDistance}`;
+ }
+ }, [penetrationDistance]);
+
return (
@@ -209,75 +215,82 @@ export function Characteristics() {
{shell.caliber}
-
- {gun.shells.map((shell) => (
+ {typeof shell.penetration !== 'number' && (
+
+ )}
+ {typeof shell.penetration === 'number' && (
+
+ {resolveNearPenetration(shell.penetration)}
+
+ )}
+ {typeof shell.penetration !== 'number' && (
<>
-
+ Distance
+ {
+ setPenetrationDistance(value);
+ }, 500)}
+ />
+
+ {
+ setPenetrationDistance(
+ Math.min(
+ parseInt(penetrationDistanceInput.current!.value),
+ 500,
+ ),
+ );
+ }}
+ onKeyDown={(event) => {
+ if (event.key === 'Enter') {
+ event.currentTarget.blur();
+ }
+ }}
+ />
+ m
+
+
+
- {resolveNearPenetration(shell.penetration) *
- (hasCalibratedShells
- ? isExplosive(shell.type)
- ? 1.1
- : 1.05
- : 1)}
-
- {typeof shell.penetration !== 'number' && (
-
- {(hasSupercharger
- ? shell.penetration[1] +
- 0.5 * (shell.penetration[0] - shell.penetration[1])
- : shell.penetration[1]) *
- (hasCalibratedShells
- ? isExplosive(shell.type)
- ? 1.1
- : 1.05
- : 1)}
-
- )}
+ {lerp(
+ shell.penetration[0],
+ shell.penetration[1],
+ penetrationDistance / 500,
+ )}
+
>
- ))}
-
- {gun.shells.map((shell) => (
-
- {shell.damage.armor}
-
- ))}
-
- {gun.shells.map((shell, index) => (
-
- {shell.damage.module}
-
- ))}
-
- {gun.shells.map((shell) => (
-
- {shell.speed * (hasSupercharger ? 1.3 : 1)}
-
- ))}
+ )}
+
+ {shell.damage.armor}
+
+
+ {shell.damage.module}
+
+
+ {shell.speed * (hasSupercharger ? 1.3 : 1)}
+
(
asset('definitions/equipment.cdon.lz4'),
);
-
-equipmentDefinitions.then(console.log);