fix: some linting for new proto 3

This commit is contained in:
TrèsAbhi committed 2024-10-05 16:44:07 -05:00
1 parent 79bc259565
commit f14ca394b5
29 files changed
+522 -418

No files matched your search

@@ -28,8 +28,8 @@ export function DynamicArmorSwitcher() {
draft.protagonist.consumables =
draft.protagonist.consumables.filter((id) => id !== 73);
} else {
if (draft.protagonist.consumables.length === tank.consumables) {
draft.protagonist.consumables[tank.consumables - 1] = 73;
if (draft.protagonist.consumables.length === tank.maxConsumables) {
draft.protagonist.consumables[tank.maxConsumables - 1] = 73;
} else {
draft.protagonist.consumables.push(73);
}
@@ -20,8 +20,9 @@ export function QuickInputs() {
const tankModelDefinition = useTankModelDefinition();
const turretModelDefinition =
tankModelDefinition.turrets[protagonist.turret.id];
const gunModelDefinition = turretModelDefinition.guns[protagonist.gun.id];
const initialGunPitch = tankModelDefinition.turretRotation?.pitch ?? 0;
const gunModelDefinition =
turretModelDefinition.guns[protagonist.gun.gunType!.value.base.id];
const initialGunPitch = tankModelDefinition.initialTurretRotation?.pitch ?? 0;
const hasImprovedVerticalStabilizer = useEquipment(122);
useEffect(() => {
@@ -43,7 +44,8 @@ export function QuickInputs() {
if (!pitchInput.current || !yawInput.current) return;
pitchInput.current.value = (
-radToDeg(pitch) + (tankModelDefinition.turretRotation?.pitch ?? 0)
-radToDeg(pitch) +
(tankModelDefinition.initialTurretRotation?.pitch ?? 0)
).toFixed(1);
if (yaw === undefined) return;
@@ -1,7 +1,6 @@
import {
asset,
imgur,
resolveNearPenetration,
resolvePenetrationCoefficient,
TIER_ROMAN_NUMERALS,
uniqueGuns,
@@ -105,7 +104,7 @@ export function Options({ thicknessRange, canvas }: OptionsProps) {
resolvePenetrationCoefficient(
hasCalibratedShells,
antagonistShell.type,
) * resolveNearPenetration(antagonistShell.penetration)
) * antagonistShell.penetration.near
).toFixed(0)}
mm
</Text>
@@ -130,7 +129,11 @@ export function Options({ thicknessRange, canvas }: OptionsProps) {
mr="2"
mb="1"
>
{TIER_ROMAN_NUMERALS[antagonistGun.tier]}
{
TIER_ROMAN_NUMERALS[
antagonistGun.gunType!.value.base.tier
]
}
</Text>
<img
@@ -149,19 +152,25 @@ export function Options({ thicknessRange, canvas }: OptionsProps) {
<Flex gap="2">
{[...antagonistUniqueGuns]
.reverse()
.map(({ gun, turret }, index) => (
.map(({ gun, turret }) => (
<ModuleButton
module="gun"
key={gun.id}
key={gun.gunType!.value.base.id}
onClick={() =>
mutateDuel((draft) => {
draft.antagonist.turret = turret;
draft.antagonist.gun = gun;
draft.antagonist.shell = gun.shells[0];
draft.antagonist.shell =
gun.gunType!.value.base.shells[0];
})
}
selected={gun.id === antagonistGun.id}
discriminator={TIER_ROMAN_NUMERALS[gun.tier]}
selected={
gun.gunType!.value.base.id ===
antagonistGun.gunType!.value.base.id
}
discriminator={
TIER_ROMAN_NUMERALS[gun.gunType!.value.base.tier]
}
/>
))}
</Flex>
@@ -175,36 +184,40 @@ export function Options({ thicknessRange, canvas }: OptionsProps) {
}}
overflow="hidden"
>
{antagonistGun.shells.map((thisShell, shellIndex) => (
<IconButton
color={thisShell.id === antagonistShell.id ? undefined : 'gray'}
variant="soft"
key={thisShell.id}
size={{ initial: '2', sm: '3' }}
radius="none"
style={{
marginTop: shellIndex === 0 ? 0 : -1,
}}
onClick={() => {
invalidate();
mutateDuel((draft) => {
draft.antagonist.shell = thisShell;
});
mutateTankopediaEphemeral((draft) => {
draft.shot = undefined;
});
}}
>
<img
alt={thisShell.name}
src={asset(`icons/shells/${thisShell.icon}.webp`)}
{antagonistGun.gunType!.value.base.shells.map(
(thisShell, shellIndex) => (
<IconButton
color={
thisShell.id === antagonistShell.id ? undefined : 'gray'
}
variant="soft"
key={thisShell.id}
size={{ initial: '2', sm: '3' }}
radius="none"
style={{
width: '50%',
height: '50%',
marginTop: shellIndex === 0 ? 0 : -1,
}}
/>
</IconButton>
))}
onClick={() => {
invalidate();
mutateDuel((draft) => {
draft.antagonist.shell = thisShell;
});
mutateTankopediaEphemeral((draft) => {
draft.shot = undefined;
});
}}
>
<img
alt={thisShell.name}
src={asset(`icons/shells/${thisShell.icon}.webp`)}
style={{
width: '50%',
height: '50%',
}}
/>
</IconButton>
),
)}
</Flex>
<Flex
@@ -318,7 +331,8 @@ export function Options({ thicknessRange, canvas }: OptionsProps) {
draft.antagonist.turret = tank.turrets.at(-1)!;
draft.antagonist.gun =
draft.antagonist.turret.guns.at(-1)!;
draft.antagonist.shell = draft.antagonist.gun.shells[0];
draft.antagonist.shell =
draft.antagonist.gun.gunType!.value.base.shells[0];
});
setAntagonistSelectorOpen(false);
}}
@@ -1,4 +1,4 @@
import { modelDefinitions } from '@blitzkit/core';
import { fetchModelDefinitions } from '@blitzkit/core';
import { OrbitControls } from '@react-three/drei';
import { useThree } from '@react-three/fiber';
import { useEffect, useRef, useState } from 'react';
@@ -7,7 +7,6 @@ import { OrbitControls as OrbitControlsClass } from 'three-stdlib';
import { applyPitchYawLimits } from '../../../../../../core/blitz/applyPitchYawLimits';
import { hasEquipment } from '../../../../../../core/blitzkit/hasEquipment';
import { Pose, poseEvent } from '../../../../../../core/blitzkit/pose';
import { useAwait } from '../../../../../../hooks/useAwait';
import { Duel } from '../../../../../../stores/duel';
import { TankopediaEphemeral } from '../../../../../../stores/tankopediaEphemeral';
@@ -18,20 +17,21 @@ const poseDistances: Record<Pose, number> = {
[Pose.Default]: -1,
};
const modelDefinitions = await fetchModelDefinitions();
export function Controls() {
const duelStore = Duel.useStore();
const tankopediaEphemeralStore = TankopediaEphemeral.useStore();
const camera = useThree((state) => state.camera);
const canvas = useThree((state) => state.gl.domElement);
const orbitControls = useRef<OrbitControlsClass>(null);
const awaitedModelDefinitions = useAwait(modelDefinitions);
const protagonist = Duel.use((state) => state.protagonist);
const antagonist = Duel.use((state) => state.antagonist);
const protagonistModelDefinition =
awaitedModelDefinitions[protagonist.tank.id];
modelDefinitions.models[protagonist.tank.id];
const protagonistTrackModelDefinition =
awaitedModelDefinitions[protagonist.tank.id].tracks[protagonist.track.id];
const antagonistModelDefinition = awaitedModelDefinitions[antagonist.tank.id];
modelDefinitions.models[protagonist.tank.id].tracks[protagonist.track.id];
const antagonistModelDefinition = modelDefinitions.models[antagonist.tank.id];
const protagonistTurretModelDefinition =
protagonistModelDefinition.turrets[protagonist.turret.id];
const antagonistTurretModelDefinition =