mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-24 03:59:50 +02:00
feat: explosion radius
This commit is contained in:
1 parent
696b5a54b8
commit
395240394f
1 file changed
+43
-1
+43
-1
@@ -16,6 +16,7 @@ import { TankopediaEphemeral } from '../../../../../../stores/tankopediaEphemera
|
|||||||
|
|
||||||
export function CustomShellButton() {
|
export function CustomShellButton() {
|
||||||
const customShell = TankopediaEphemeral.use((state) => state.customShell);
|
const customShell = TankopediaEphemeral.use((state) => state.customShell);
|
||||||
|
const gun = Duel.use((state) => state.protagonist.gun);
|
||||||
const antagonistShell = Duel.use((state) => state.antagonist.shell);
|
const antagonistShell = Duel.use((state) => state.antagonist.shell);
|
||||||
const mutateTankopediaEphemeral = TankopediaEphemeral.useMutation();
|
const mutateTankopediaEphemeral = TankopediaEphemeral.useMutation();
|
||||||
|
|
||||||
@@ -65,17 +66,27 @@ export function CustomShellButton() {
|
|||||||
case ShellType.AP: {
|
case ShellType.AP: {
|
||||||
modified.normalization = 5;
|
modified.normalization = 5;
|
||||||
modified.ricochet = 70;
|
modified.ricochet = 70;
|
||||||
|
modified.explosion_radius = undefined;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ShellType.APCR: {
|
case ShellType.APCR: {
|
||||||
modified.normalization = 2;
|
modified.normalization = 2;
|
||||||
modified.ricochet = 70;
|
modified.ricochet = 70;
|
||||||
|
modified.explosion_radius = undefined;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ShellType.HEAT:
|
case ShellType.HEAT: {
|
||||||
|
modified.normalization = undefined;
|
||||||
|
modified.ricochet = undefined;
|
||||||
|
modified.explosion_radius = undefined;
|
||||||
|
}
|
||||||
case ShellType.HE: {
|
case ShellType.HE: {
|
||||||
modified.normalization = undefined;
|
modified.normalization = undefined;
|
||||||
modified.ricochet = undefined;
|
modified.ricochet = undefined;
|
||||||
|
modified.explosion_radius =
|
||||||
|
gun.gun_type!.value.base.shells.find(
|
||||||
|
(shell) => shell.type === ShellType.HE,
|
||||||
|
)?.explosion_radius ?? 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -207,6 +218,37 @@ export function CustomShellButton() {
|
|||||||
</Flex>
|
</Flex>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
{customShell.type === ShellType.HE && (
|
||||||
|
<Flex align="center" justify="between" gap="4">
|
||||||
|
<Text>Explosion radius</Text>
|
||||||
|
<TextField.Root
|
||||||
|
style={{ maxWidth: '6rem' }}
|
||||||
|
defaultValue={customShell.explosion_radius ?? 0}
|
||||||
|
type="number"
|
||||||
|
onChange={(event: ChangeEvent<HTMLInputElement>) => {
|
||||||
|
mutateTankopediaEphemeral((draft) => {
|
||||||
|
draft.customShell!.explosion_radius =
|
||||||
|
event.target.valueAsNumber;
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
onFocus={(event) => event.target.select()}
|
||||||
|
onKeyDown={(event) => {
|
||||||
|
event.stopPropagation();
|
||||||
|
|
||||||
|
if (event.key === 'Enter') {
|
||||||
|
(event.target as HTMLInputElement).blur();
|
||||||
|
} else if (event.key === 'Escape') {
|
||||||
|
(event.target as HTMLInputElement).valueAsNumber =
|
||||||
|
customShell.explosion_radius ?? 1;
|
||||||
|
(event.target as HTMLInputElement).blur();
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<TextField.Slot side="right">m</TextField.Slot>
|
||||||
|
</TextField.Root>
|
||||||
|
</Flex>
|
||||||
|
)}
|
||||||
</Flex>
|
</Flex>
|
||||||
|
|
||||||
<Flex justify="end" mt="6" gap="2">
|
<Flex justify="end" mt="6" gap="2">
|
||||||
|
|||||||
Reference in new issue
Block a user