mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-11-19 11:53:25 +01:00
feat: united duel data
This commit is contained in:
1 parent
da767213cb
commit
7e92f8ac50
23 files changed
+249
-249
No files matched your search
@@ -4,33 +4,29 @@ import { applyPitchYawLimits } from '../../../../../../core/blitz/applyPitchYawL
|
||||
import { modelDefinitions } from '../../../../../../core/blitzkrieg/modelDefinitions';
|
||||
import { modelTransformEvent } from '../../../../../../core/blitzkrieg/modelTransform';
|
||||
import { useEquipment } from '../../../../../../hooks/useEquipment';
|
||||
import { useDuel } from '../../../../../../stores/duel';
|
||||
import {
|
||||
mutateTankopediaTemporary,
|
||||
useTankopediaTemporary,
|
||||
} from '../../../../../../stores/tankopedia';
|
||||
import { mutateDuel, useDuel } from '../../../../../../stores/duel';
|
||||
import { useTankopediaPersistent } from '../../../../../../stores/tankopedia';
|
||||
import { QuickEquipmentButton } from './components/QuickEquipmentButton';
|
||||
|
||||
export function RotationInputs() {
|
||||
const protagonist = useDuel((state) => state.protagonist!);
|
||||
const physical = useTankopediaTemporary((state) => state.model.pose);
|
||||
const awaitedModelDefinitions = use(modelDefinitions);
|
||||
const turretYawInput = useRef<HTMLInputElement>(null);
|
||||
const gunPitchInput = useRef<HTMLInputElement>(null);
|
||||
const mode = useTankopediaTemporary((state) => state.mode);
|
||||
const hasCalibratedShells = useEquipment(103);
|
||||
const mode = useTankopediaPersistent((state) => state.mode);
|
||||
const hasCalibratedShells = useEquipment(103, true);
|
||||
const hasEnhancedArmor = useEquipment(110);
|
||||
|
||||
useEffect(() => {
|
||||
turretYawInput.current!.value = `${-Math.round(
|
||||
physical.yaw * (180 / Math.PI),
|
||||
protagonist.yaw * (180 / Math.PI),
|
||||
)}`;
|
||||
}, [physical.yaw]);
|
||||
}, [protagonist.yaw]);
|
||||
useEffect(() => {
|
||||
gunPitchInput.current!.value = `${-Math.round(
|
||||
physical.pitch * (180 / Math.PI),
|
||||
protagonist.pitch * (180 / Math.PI),
|
||||
)}`;
|
||||
}, [physical.pitch]);
|
||||
}, [protagonist.pitch]);
|
||||
|
||||
const tankModelDefinition = awaitedModelDefinitions[protagonist.tank.id];
|
||||
const turretModelDefinition =
|
||||
@@ -68,18 +64,18 @@ export function RotationInputs() {
|
||||
Yaw
|
||||
</TextField.Slot>
|
||||
<TextField.Input
|
||||
defaultValue={Math.round(physical.yaw * (180 / Math.PI))}
|
||||
defaultValue={Math.round(protagonist.yaw * (180 / Math.PI))}
|
||||
onBlur={() => {
|
||||
const [pitch, yaw] = applyPitchYawLimits(
|
||||
physical.pitch,
|
||||
protagonist.pitch,
|
||||
-Number(turretYawInput.current?.value) * (Math.PI / 180),
|
||||
gunModelDefinition.pitch,
|
||||
turretModelDefinition.yaw,
|
||||
);
|
||||
modelTransformEvent.emit({ pitch, yaw });
|
||||
mutateTankopediaTemporary((state) => {
|
||||
state.model.pose.pitch = pitch;
|
||||
state.model.pose.yaw = yaw;
|
||||
useDuel((state) => {
|
||||
state.protagonist!.pitch = pitch;
|
||||
state.protagonist!.yaw = yaw;
|
||||
});
|
||||
turretYawInput.current!.value = `${Math.round(
|
||||
yaw * (180 / Math.PI),
|
||||
@@ -116,18 +112,18 @@ export function RotationInputs() {
|
||||
Pitch
|
||||
</TextField.Slot>
|
||||
<TextField.Input
|
||||
defaultValue={-Math.round(physical.pitch * (180 / Math.PI))}
|
||||
defaultValue={-Math.round(protagonist.pitch * (180 / Math.PI))}
|
||||
onBlur={() => {
|
||||
const [pitch, yaw] = applyPitchYawLimits(
|
||||
-Number(gunPitchInput.current?.value) * (Math.PI / 180),
|
||||
physical.yaw,
|
||||
protagonist.yaw,
|
||||
gunModelDefinition.pitch,
|
||||
turretModelDefinition.yaw,
|
||||
);
|
||||
modelTransformEvent.emit({ pitch, yaw });
|
||||
mutateTankopediaTemporary((state) => {
|
||||
state.model.pose.pitch = pitch;
|
||||
state.model.pose.yaw = yaw;
|
||||
mutateDuel((state) => {
|
||||
state.protagonist!.pitch = pitch;
|
||||
state.protagonist!.yaw = yaw;
|
||||
});
|
||||
gunPitchInput.current!.value = `${Math.round(
|
||||
pitch * (180 / Math.PI),
|
||||
@@ -158,8 +154,8 @@ export function RotationInputs() {
|
||||
equipment={103}
|
||||
active={hasCalibratedShells}
|
||||
onClick={() => {
|
||||
mutateTankopediaTemporary((draft) => {
|
||||
draft.equipmentMatrix[0][0] = hasCalibratedShells ? 0 : 1;
|
||||
mutateDuel((draft) => {
|
||||
draft.antagonist!.equipment[0][0] = hasCalibratedShells ? 0 : 1;
|
||||
});
|
||||
}}
|
||||
/>
|
||||
@@ -167,8 +163,8 @@ export function RotationInputs() {
|
||||
equipment={110}
|
||||
active={hasEnhancedArmor}
|
||||
onClick={() => {
|
||||
mutateTankopediaTemporary((draft) => {
|
||||
draft.equipmentMatrix[1][1] = hasEnhancedArmor ? 0 : -1;
|
||||
mutateDuel((draft) => {
|
||||
draft.protagonist!.equipment[1][1] = hasEnhancedArmor ? 0 : -1;
|
||||
});
|
||||
}}
|
||||
/>
|
||||
|
||||
Reference in new issue
Block a user