mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-22 19:19:52 +02:00
feat: synx quick equipment
This commit is contained in:
1 parent
b8beb6e8be
commit
0b12f65949
19 files changed
+69
-61
No files matched your search
@@ -3,7 +3,7 @@ import { use } from 'react';
|
||||
import { ConsumableButton } from '../../../../../../../components/ModuleButtons/ConsumableButton';
|
||||
import { checkConsumableProvisionInclusivity } from '../../../../../../../core/blitzkrieg/checkConsumableProvisionInclusivity';
|
||||
import { consumableDefinitions } from '../../../../../../../core/blitzkrieg/consumableDefinitions';
|
||||
import { useEquipment } from '../../../../../../../core/blitzkrieg/useEquipment';
|
||||
import { useEquipment } from '../../../../../../../hooks/useEquipment';
|
||||
import { useDuel } from '../../../../../../../stores/duel';
|
||||
import {
|
||||
mutateTankopediaTemporary,
|
||||
|
||||
@@ -17,10 +17,10 @@ import {
|
||||
GUN_TYPE_NAMES,
|
||||
} from '../../../../../../core/blitzkrieg/tankDefinitions';
|
||||
import { unionBoundingBox } from '../../../../../../core/blitzkrieg/unionBoundingBox';
|
||||
import { useConsumable } from '../../../../../../core/blitzkrieg/useConsumable';
|
||||
import { useEquipment } from '../../../../../../core/blitzkrieg/useEquipment';
|
||||
import { useProvision } from '../../../../../../core/blitzkrieg/useProvision';
|
||||
import { useProvisions } from '../../../../../../core/blitzkrieg/useProvisions';
|
||||
import { useConsumable } from '../../../../../../hooks/useConsumable';
|
||||
import { useEquipment } from '../../../../../../hooks/useEquipment';
|
||||
import { useProvision } from '../../../../../../hooks/useProvision';
|
||||
import { useProvisions } from '../../../../../../hooks/useProvisions';
|
||||
import { useDuel } from '../../../../../../stores/duel';
|
||||
import { useTankopediaTemporary } from '../../../../../../stores/tankopedia';
|
||||
import { Info } from './components/Info';
|
||||
|
||||
@@ -3,10 +3,10 @@ import { use, useEffect, useRef } from 'react';
|
||||
import { applyPitchYawLimits } from '../../../../../../core/blitz/applyPitchYawLimits';
|
||||
import { modelDefinitions } from '../../../../../../core/blitzkrieg/modelDefinitions';
|
||||
import { modelTransformEvent } from '../../../../../../core/blitzkrieg/modelTransform';
|
||||
import { useEquipment } from '../../../../../../hooks/useEquipment';
|
||||
import { useDuel } from '../../../../../../stores/duel';
|
||||
import mutateTankopediaPersistent, {
|
||||
import {
|
||||
mutateTankopediaTemporary,
|
||||
useTankopediaPersistent,
|
||||
useTankopediaTemporary,
|
||||
} from '../../../../../../stores/tankopedia';
|
||||
import { QuickEquipmentButton } from './components/QuickEquipmentButton';
|
||||
@@ -17,8 +17,9 @@ export function RotationInputs() {
|
||||
const awaitedModelDefinitions = use(modelDefinitions);
|
||||
const turretYawInput = useRef<HTMLInputElement>(null);
|
||||
const gunPitchInput = useRef<HTMLInputElement>(null);
|
||||
const equipment = useTankopediaPersistent((state) => state.model.equipment);
|
||||
const mode = useTankopediaTemporary((state) => state.mode);
|
||||
const hasCalibratedShells = useEquipment(103);
|
||||
const hasEnhancedArmor = useEquipment(110);
|
||||
|
||||
useEffect(() => {
|
||||
turretYawInput.current!.value = `${-Math.round(
|
||||
@@ -155,21 +156,19 @@ export function RotationInputs() {
|
||||
<Flex gap="4">
|
||||
<QuickEquipmentButton
|
||||
equipment={103}
|
||||
active={equipment.calibratedShells}
|
||||
active={hasCalibratedShells}
|
||||
onClick={() => {
|
||||
mutateTankopediaPersistent((draft) => {
|
||||
draft.model.equipment.calibratedShells =
|
||||
!draft.model.equipment.calibratedShells;
|
||||
mutateTankopediaTemporary((draft) => {
|
||||
draft.equipmentMatrix[0][0] = hasCalibratedShells ? 0 : 1;
|
||||
});
|
||||
}}
|
||||
/>
|
||||
<QuickEquipmentButton
|
||||
equipment={110}
|
||||
active={equipment.enhancedArmor}
|
||||
active={hasEnhancedArmor}
|
||||
onClick={() => {
|
||||
mutateTankopediaPersistent((draft) => {
|
||||
draft.model.equipment.enhancedArmor =
|
||||
!draft.model.equipment.enhancedArmor;
|
||||
mutateTankopediaTemporary((draft) => {
|
||||
draft.equipmentMatrix[1][1] = hasEnhancedArmor ? 0 : -1;
|
||||
});
|
||||
}}
|
||||
/>
|
||||
|
||||
@@ -21,13 +21,13 @@ import { getArchivedLatestSeasonNumber } from '../core/blitzkrieg/getArchivedLat
|
||||
import getArchivedRatingsInfo from '../core/blitzkrieg/getArchivedRatingsInfo';
|
||||
import { getArchivedRatingsLeaderboard } from '../core/blitzkrieg/getArchivedRatingsLeaderboard';
|
||||
import getArchivedRatingsMidnightLeaderboard from '../core/blitzkrieg/getArchivedRatingsMidnightLeaderboard';
|
||||
import { UserError } from '../core/blitzkrieg/userError';
|
||||
import addRegionChoices from '../core/discord/addRegionChoices';
|
||||
import addUsernameChoices from '../core/discord/addUsernameChoices';
|
||||
import autocompleteUsername from '../core/discord/autocompleteUsername';
|
||||
import embedNegative from '../core/discord/embedNegative';
|
||||
import resolvePlayerFromCommand from '../core/discord/resolvePlayerFromCommand';
|
||||
import { CommandRegistryRaw } from '../events/interactionCreate';
|
||||
import { UserError } from '../hooks/userError';
|
||||
|
||||
export interface RatingsPlayer {
|
||||
spa_id: number;
|
||||
|
||||
@@ -14,12 +14,15 @@ import { canRicochet } from '../../../../core/blitz/canRicochet';
|
||||
import { canSplash } from '../../../../core/blitz/canSplash';
|
||||
import { isExplosive } from '../../../../core/blitz/isExplosive';
|
||||
import { resolveNearPenetration } from '../../../../core/blitz/resolveNearPenetration';
|
||||
import { hasEquipment } from '../../../../core/blitzkrieg/hasEquipment';
|
||||
import { useAwait } from '../../../../hooks/useAwait';
|
||||
import { useDuel } from '../../../../stores/duel';
|
||||
import {
|
||||
ArmorPiercingLayer,
|
||||
Shot,
|
||||
mutateTankopediaTemporary,
|
||||
useTankopediaPersistent,
|
||||
useTankopediaTemporary,
|
||||
} from '../../../../stores/tankopedia';
|
||||
import { externalModuleMaskRenderTarget } from '../ExternalModuleMask';
|
||||
import { spacedArmorDepthRenderTarget } from '../SpacedArmorDepth';
|
||||
@@ -52,19 +55,22 @@ export function ArmorMesh({
|
||||
const surfaceNormal = new Vector3();
|
||||
const mesh = useRef<Mesh>(null);
|
||||
const scene = useThree((state) => state.scene);
|
||||
const hasCalibratedShells = useAwait(hasEquipment(103));
|
||||
const hasEnhancedArmor = useAwait(hasEquipment(110));
|
||||
|
||||
useEffect(() => {
|
||||
function updateQuickEquipments() {
|
||||
const equipment = useTankopediaPersistent.getState().model.equipment;
|
||||
async function updateQuickEquipments() {
|
||||
const shell = useDuel.getState().antagonist!.shell;
|
||||
const nearPenetration = resolveNearPenetration(shell.penetration);
|
||||
const hasCalibratedShells = await hasEquipment(103);
|
||||
const hasEnhancedArmor = await hasEquipment(110);
|
||||
|
||||
if (material.current) {
|
||||
material.current.uniforms.thickness.value =
|
||||
thickness * (equipment.enhancedArmor ? 1.04 : 1);
|
||||
thickness * (hasEnhancedArmor ? 1.04 : 1);
|
||||
material.current.uniforms.penetration.value =
|
||||
nearPenetration *
|
||||
(equipment.calibratedShells ? (explosionCapable ? 1.1 : 1.05) : 1);
|
||||
(hasCalibratedShells ? (isExplosive(shell.type) ? 1.1 : 1.05) : 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,8 +93,8 @@ export function ArmorMesh({
|
||||
}
|
||||
|
||||
const unsubscribes = [
|
||||
useTankopediaPersistent.subscribe(
|
||||
(state) => state.model.equipment,
|
||||
useTankopediaTemporary.subscribe(
|
||||
(state) => state.equipmentMatrix,
|
||||
updateQuickEquipments,
|
||||
),
|
||||
useDuel.subscribe(
|
||||
@@ -145,7 +151,7 @@ export function ArmorMesh({
|
||||
} satisfies ArmorMeshUserData
|
||||
}
|
||||
ref={mesh}
|
||||
onClick={(event) => {
|
||||
onClick={async (event) => {
|
||||
// if (useTankopediaTemporary.getState().mode !== 'armor') return;
|
||||
|
||||
shellNormal.copy(
|
||||
@@ -154,16 +160,12 @@ export function ArmorMesh({
|
||||
surfaceNormal
|
||||
.copy(event.normal!)
|
||||
.applyQuaternion(event.object.getWorldQuaternion(new Quaternion()));
|
||||
const equipment = useTankopediaPersistent.getState().model.equipment;
|
||||
const angle = Math.acos(surfaceNormal.dot(shellNormal));
|
||||
const shell = useDuel.getState().antagonist!.shell;
|
||||
const hasCalibratedShells = await hasEquipment(103);
|
||||
const resolvedPenetration =
|
||||
resolveNearPenetration(shell.penetration) *
|
||||
(equipment.calibratedShells
|
||||
? isExplosive(shell.type)
|
||||
? 1.1
|
||||
: 1.05
|
||||
: 1);
|
||||
(hasCalibratedShells ? (isExplosive(shell.type) ? 1.1 : 1.05) : 1);
|
||||
const indexedObjects = new Set<ArmorMeshUserData['type']>();
|
||||
const intersections = event.intersections
|
||||
.filter(({ object }) => Boolean(object.userData.type))
|
||||
@@ -188,7 +190,8 @@ export function ArmorMesh({
|
||||
) + 1,
|
||||
);
|
||||
const coreArmorMesh = intersectionsTillFirstCoreArmor.at(-1)!.object;
|
||||
const thicknessCoefficient = equipment.enhancedArmor ? 1.04 : 1;
|
||||
const hasEnhancedArmor = await hasEquipment(110);
|
||||
const thicknessCoefficient = hasEnhancedArmor ? 1.04 : 1;
|
||||
|
||||
if (mesh.current !== (coreArmorMesh as unknown as Mesh)) return;
|
||||
|
||||
@@ -405,18 +408,12 @@ export function ArmorMesh({
|
||||
canRicochet: { value: ricochetCapable },
|
||||
canSplash: { value: canSplash(initialShell.type) },
|
||||
thickness: {
|
||||
value:
|
||||
thickness *
|
||||
(initialTankopedia.model.equipment.enhancedArmor ? 1.04 : 1),
|
||||
value: thickness * (hasEnhancedArmor ? 1.04 : 1),
|
||||
},
|
||||
penetration: {
|
||||
value:
|
||||
resolveNearPenetration(initialShell.penetration) *
|
||||
(initialTankopedia.model.equipment.calibratedShells
|
||||
? explosionCapable
|
||||
? 1.1
|
||||
: 1.05
|
||||
: 1),
|
||||
(hasCalibratedShells ? (explosionCapable ? 1.1 : 1.05) : 1),
|
||||
},
|
||||
caliber: { value: initialShell.caliber },
|
||||
ricochetAngle: { value: degToRad(initialShell.ricochet ?? 90) },
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Region } from '../../constants/regions';
|
||||
import { WARGAMING_APPLICATION_ID } from '../../constants/wargamingApplicationID';
|
||||
import { UserError } from '../../hooks/userError';
|
||||
import { TanksStats } from '../../types/tanksStats';
|
||||
import { UserError } from '../blitzkrieg/userError';
|
||||
import fetchBlitz from './fetchBlitz';
|
||||
|
||||
export default async function getTankStats(region: Region, id: number) {
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { go } from 'fuzzysort';
|
||||
import { UserError } from '../../hooks/userError';
|
||||
import {
|
||||
tankDefinitions,
|
||||
tanksDefinitionsArray,
|
||||
} from '../blitzkrieg/tankDefinitions';
|
||||
import { UserError } from '../blitzkrieg/userError';
|
||||
|
||||
export default async function resolveTankId(tank: string | number) {
|
||||
const number = typeof tank === 'string' ? parseInt(tank) : tank;
|
||||
|
||||
@@ -25,3 +25,5 @@ export interface EquipmentDefinitions {
|
||||
export const equipmentDefinitions = fetchCdonLz4<EquipmentDefinitions>(
|
||||
asset('definitions/equipment.cdon.lz4'),
|
||||
);
|
||||
|
||||
equipmentDefinitions.then(console.log);
|
||||
@@ -0,0 +1,20 @@
|
||||
import { useDuel } from '../../stores/duel';
|
||||
import { useTankopediaTemporary } from '../../stores/tankopedia';
|
||||
import { equipmentDefinitions } from './equipmentDefinitions';
|
||||
|
||||
export async function hasEquipment(id: number) {
|
||||
const awaitedEquipmentDefinitions = await equipmentDefinitions;
|
||||
const protagonist = useDuel.getState().protagonist!;
|
||||
const equipmentRows =
|
||||
awaitedEquipmentDefinitions.presets[protagonist.tank.equipment];
|
||||
const equipmentMatrix = useTankopediaTemporary.getState().equipmentMatrix;
|
||||
|
||||
return equipmentRows.some((equipmentRow, rowIndex) => {
|
||||
return equipmentRow.some((equipment, columnIndex) => {
|
||||
const choice = equipmentMatrix[rowIndex][columnIndex];
|
||||
if (choice === 0) return false;
|
||||
const equipped = equipment[choice === -1 ? 0 : 1];
|
||||
return equipped === id;
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -17,5 +17,3 @@ export interface ProvisionDefinitions {
|
||||
export const provisionDefinitions = fetchCdonLz4<ProvisionDefinitions>(
|
||||
asset('definitions/provisions.cdon.lz4'),
|
||||
);
|
||||
|
||||
provisionDefinitions.then(console.log);
|
||||
@@ -1,7 +1,7 @@
|
||||
import { ChatInputCommandInteraction } from 'discord.js';
|
||||
import { Region } from '../../constants/regions';
|
||||
import { UserError } from '../../hooks/userError';
|
||||
import searchClansAcrossRegions from '../blitz/searchClansAcrossRegions';
|
||||
import { UserError } from '../blitzkrieg/userError';
|
||||
import { serverAndIdPattern } from './resolvePlayerFromCommand';
|
||||
|
||||
export default async function resolveClanFromCommand(
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { CacheType, ChatInputCommandInteraction } from 'discord.js';
|
||||
import markdownEscape from 'markdown-escape';
|
||||
import { Region } from '../../constants/regions';
|
||||
import { UserError } from '../../hooks/userError';
|
||||
import searchPlayersAcrossRegions from '../blitz/searchPlayersAcrossRegions';
|
||||
import { getBlitzFromDiscord } from '../blitzkrieg/discordBlitz';
|
||||
import { UserError } from '../blitzkrieg/userError';
|
||||
|
||||
export const serverAndIdPattern = /(com|eu|asia)\/[0-9]+/;
|
||||
|
||||
|
||||
@@ -9,12 +9,12 @@ import {
|
||||
} from 'discord.js';
|
||||
import { commands } from '..';
|
||||
import discord from '../../../../discord.json' assert { type: 'json' };
|
||||
import { UserError } from '../../../core/blitzkrieg/userError';
|
||||
import buttonLink from '../../../core/discord/buttonLink';
|
||||
import embedNegative from '../../../core/discord/embedNegative';
|
||||
import embedWarning from '../../../core/discord/embedWarning';
|
||||
import normalizeInteractionReturnable from '../../../core/discord/normalizeInteractionReturnable';
|
||||
import { psa } from '../../../core/discord/psa';
|
||||
import { UserError } from '../../../hooks/userError';
|
||||
|
||||
export default async function handleChatInputCommand(
|
||||
interaction: ChatInputCommandInteraction<CacheType>,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { useTankopediaTemporary } from '../../stores/tankopedia';
|
||||
import { useTankopediaTemporary } from '../stores/tankopedia';
|
||||
|
||||
export function useConsumable(id: number) {
|
||||
const consumables = useTankopediaTemporary((state) => state.consumables);
|
||||
@@ -1,7 +1,7 @@
|
||||
import { use, useMemo } from 'react';
|
||||
import { useDuel } from '../../stores/duel';
|
||||
import { useTankopediaTemporary } from '../../stores/tankopedia';
|
||||
import { equipmentDefinitions } from './equipmentDefinitions';
|
||||
import { equipmentDefinitions } from '../core/blitzkrieg/equipmentDefinitions';
|
||||
import { useDuel } from '../stores/duel';
|
||||
import { useTankopediaTemporary } from '../stores/tankopedia';
|
||||
|
||||
export function useEquipment(id: number) {
|
||||
const awaitedEquipmentDefinitions = use(equipmentDefinitions);
|
||||
@@ -1,4 +1,4 @@
|
||||
import { useTankopediaTemporary } from '../../stores/tankopedia';
|
||||
import { useTankopediaTemporary } from '../stores/tankopedia';
|
||||
|
||||
export function useProvision(id: number) {
|
||||
const provisions = useTankopediaTemporary((state) => state.provisions);
|
||||
@@ -1,6 +1,6 @@
|
||||
import { use } from 'react';
|
||||
import { useTankopediaTemporary } from '../../stores/tankopedia';
|
||||
import { provisionDefinitions } from './provisionDefinitions';
|
||||
import { provisionDefinitions } from '../core/blitzkrieg/provisionDefinitions';
|
||||
import { useTankopediaTemporary } from '../stores/tankopedia';
|
||||
|
||||
export function useProvisions() {
|
||||
const provisions = useTankopediaTemporary((state) => state.provisions);
|
||||
File renamed without changes.
@@ -29,10 +29,6 @@ export interface DuelMember {
|
||||
}
|
||||
interface TankopediaPersistent {
|
||||
model: {
|
||||
equipment: {
|
||||
enhancedArmor: boolean;
|
||||
calibratedShells: boolean;
|
||||
};
|
||||
visual: {
|
||||
environment: (typeof ENVIRONMENTS)[number];
|
||||
controlsEnabled: boolean;
|
||||
@@ -134,10 +130,6 @@ export const useTankopediaPersistent = create<TankopediaPersistent>()(
|
||||
persist(
|
||||
subscribeWithSelector<TankopediaPersistent>(() => ({
|
||||
model: {
|
||||
equipment: {
|
||||
enhancedArmor: false,
|
||||
calibratedShells: false,
|
||||
},
|
||||
visual: {
|
||||
environment: 'warehouse',
|
||||
controlsEnabled: true,
|
||||
|
||||
Reference in new issue
Block a user