fix: shell invalidation

This commit is contained in:
tresabhi committed 2024-11-10 21:57:19 -06:00
1 parent 5cf8e48747
commit 4584490b0d
1 file changed
+17 -7
@@ -76,8 +76,14 @@ export function PrimaryArmorSceneComponent({
material.uniforms.damage.value = shell.armor_damage; material.uniforms.damage.value = shell.armor_damage;
material.uniforms.explosionRadius.value = shell.explosion_radius; material.uniforms.explosionRadius.value = shell.explosion_radius;
await handleProtagonistEquipmentChange(duel.protagonist.equipmentMatrix); await handleProtagonistEquipmentChange(
await handleAntagonistEquipmentChange(duel.antagonist.equipmentMatrix); duel.protagonist.equipmentMatrix,
true,
);
await handleAntagonistEquipmentChange(
duel.antagonist.equipmentMatrix,
true,
);
// console.log('handleShellChange'); // console.log('handleShellChange');
@@ -96,6 +102,7 @@ export function PrimaryArmorSceneComponent({
} }
async function handleProtagonistEquipmentChange( async function handleProtagonistEquipmentChange(
equipment: EquipmentMatrix, equipment: EquipmentMatrix,
noInvalidate = false,
) { ) {
const duel = duelStore.getState(); const duel = duelStore.getState();
const hasEnhancedArmor = await hasEquipment( const hasEnhancedArmor = await hasEquipment(
@@ -107,9 +114,12 @@ export function PrimaryArmorSceneComponent({
? thickness * 1.03 ? thickness * 1.03
: thickness; : thickness;
// invalidate(); if (!noInvalidate) invalidate();
} }
async function handleAntagonistEquipmentChange(equipment: EquipmentMatrix) { async function handleAntagonistEquipmentChange(
equipment: EquipmentMatrix,
noInvalidate = false,
) {
const duel = duelStore.getState(); const duel = duelStore.getState();
const tankopediaEphemeral = tankopediaEphemeralStore.getState(); const tankopediaEphemeral = tankopediaEphemeralStore.getState();
const shell = tankopediaEphemeral.customShell ?? duel.antagonist.shell; const shell = tankopediaEphemeral.customShell ?? duel.antagonist.shell;
@@ -124,7 +134,7 @@ export function PrimaryArmorSceneComponent({
penetration * penetration *
resolvePenetrationCoefficient(hasCalibratedShells, shell.type); resolvePenetrationCoefficient(hasCalibratedShells, shell.type);
invalidate(); if (!noInvalidate) invalidate();
} }
handleShellChange(); handleShellChange();
@@ -153,11 +163,11 @@ export function PrimaryArmorSceneComponent({
duelStore.subscribe( duelStore.subscribe(
(state) => state.protagonist.equipmentMatrix, (state) => state.protagonist.equipmentMatrix,
handleProtagonistEquipmentChange, (equipment) => handleProtagonistEquipmentChange(equipment),
), ),
duelStore.subscribe( duelStore.subscribe(
(state) => state.antagonist.equipmentMatrix, (state) => state.antagonist.equipmentMatrix,
handleAntagonistEquipmentChange, (equipment) => handleAntagonistEquipmentChange(equipment),
), ),
]; ];