mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-24 03:59:50 +02:00
SpacedArmorSubSpaced
This commit is contained in:
1 parent
f17ac2b575
commit
19dbd8ca2e
1 file changed
+28
-24
@@ -7,12 +7,12 @@ import {
|
|||||||
type Object3D,
|
type Object3D,
|
||||||
} from "three";
|
} from "three";
|
||||||
import { degToRad } from "three/src/math/MathUtils.js";
|
import { degToRad } from "three/src/math/MathUtils.js";
|
||||||
import type { ArmorUserData } from "../SpacedArmorSceneComponent";
|
|
||||||
import { hasEquipment } from "../../core/blitzkit/hasEquipment";
|
|
||||||
import { jsxTree } from "../../core/blitzkit/jsxTree";
|
import { jsxTree } from "../../core/blitzkit/jsxTree";
|
||||||
import { Duel } from "../../stores/duel";
|
import { DuelModule, getDuel } from "../../hooks/useDuel";
|
||||||
|
import { hasEquipment } from "../../hooks/useEquipment";
|
||||||
import { Tankopedia } from "../../stores/tankopedia";
|
import { Tankopedia } from "../../stores/tankopedia";
|
||||||
import { ArmorType } from "./SpacedArmorScene";
|
import { ArmorType } from "../SpacedArmorScene";
|
||||||
|
import type { ArmorUserData } from "../SpacedArmorSceneComponent";
|
||||||
import fragmentShader from "./shaders/fragment.glsl?raw";
|
import fragmentShader from "./shaders/fragment.glsl?raw";
|
||||||
import vertexShader from "./shaders/vertex.glsl?raw";
|
import vertexShader from "./shaders/vertex.glsl?raw";
|
||||||
|
|
||||||
@@ -51,7 +51,8 @@ export function SpacedArmorSubSpaced({
|
|||||||
function handleShellChange() {
|
function handleShellChange() {
|
||||||
const tankopediaEphemeral = Tankopedia.state;
|
const tankopediaEphemeral = Tankopedia.state;
|
||||||
const shell =
|
const shell =
|
||||||
tankopediaEphemeral.customShell ?? Duel.state.antagonist.shell;
|
tankopediaEphemeral.customShell ??
|
||||||
|
getDuel("antagonist", DuelModule.Shell);
|
||||||
|
|
||||||
material.uniforms.penetration.value = shell.penetration!.near;
|
material.uniforms.penetration.value = shell.penetration!.near;
|
||||||
material.uniforms.caliber.value = shell.caliber;
|
material.uniforms.caliber.value = shell.caliber;
|
||||||
@@ -63,43 +64,46 @@ export function SpacedArmorSubSpaced({
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
function handleProtagonistEquipmentChange() {
|
function handleProtagonistEquipmentChange() {
|
||||||
const equipment = Duel.state.protagonist.equipmentMatrix;
|
const protagonist = getDuel("protagonist", DuelModule.Tank);
|
||||||
|
|
||||||
const hasEnhancedArmor = hasEquipment(
|
const hasEnhancedArmor = hasEquipment(
|
||||||
110,
|
110,
|
||||||
Duel.state.protagonist.tank.equipment_preset,
|
protagonist.equipment_preset,
|
||||||
equipment,
|
Tankopedia.state.protagonist.equipment,
|
||||||
);
|
);
|
||||||
const equalizer =
|
const equalizer =
|
||||||
(Duel.state.equalize
|
(Tankopedia.state.equalize
|
||||||
? Duel.state.protagonist.tank.equalizer?.armor
|
? protagonist.equalizer?.armor
|
||||||
: undefined) ?? 1;
|
: undefined) ?? 1;
|
||||||
|
|
||||||
material.uniforms.thickness.value =
|
material.uniforms.thickness.value =
|
||||||
thickness * (hasEnhancedArmor ? 1.04 : 1) * equalizer;
|
thickness * (hasEnhancedArmor ? 1.04 : 1) * equalizer;
|
||||||
}
|
}
|
||||||
function handleAntagonistEquipmentChange() {
|
function handleAntagonistEquipmentChange() {
|
||||||
const equipment = Duel.state.antagonist.equipmentMatrix;
|
const antagonist = getDuel("antagonist", DuelModule.Tank);
|
||||||
|
|
||||||
const tankopediaEphemeral = Tankopedia.state;
|
const tankopediaEphemeral = Tankopedia.state;
|
||||||
const shell =
|
const shell =
|
||||||
tankopediaEphemeral.customShell ?? Duel.state.antagonist.shell;
|
tankopediaEphemeral.customShell ??
|
||||||
|
getDuel("antagonist", DuelModule.Shell);
|
||||||
const penetration = shell.penetration!.near;
|
const penetration = shell.penetration!.near;
|
||||||
const hasCalibratedShells = hasEquipment(
|
const hasCalibratedShells = hasEquipment(
|
||||||
103,
|
103,
|
||||||
Duel.state.antagonist.tank.equipment_preset,
|
antagonist.equipment_preset,
|
||||||
equipment,
|
Tankopedia.state.antagonist.equipment,
|
||||||
);
|
);
|
||||||
const equalize =
|
const equalize =
|
||||||
(Duel.state.equalize
|
(Tankopedia.state.equalize
|
||||||
? Duel.state.antagonist.tank.equalizer?.penetration
|
? antagonist.equalizer?.penetration
|
||||||
: undefined) ?? 1;
|
: undefined) ?? 1;
|
||||||
|
|
||||||
material.uniforms.penetration.value =
|
material.uniforms.penetration.value =
|
||||||
penetration *
|
penetration *
|
||||||
resolvePenetrationCoefficient(
|
resolvePenetrationCoefficient(
|
||||||
hasCalibratedShells,
|
hasCalibratedShells,
|
||||||
Duel.state.equalize,
|
Tankopedia.state.equalize,
|
||||||
shell.type,
|
shell.type,
|
||||||
Duel.state.antagonist.tank.equalizer,
|
antagonist.equalizer,
|
||||||
) *
|
) *
|
||||||
equalize;
|
equalize;
|
||||||
}
|
}
|
||||||
@@ -109,17 +113,17 @@ export function SpacedArmorSubSpaced({
|
|||||||
handleAntagonistEquipmentChange();
|
handleAntagonistEquipmentChange();
|
||||||
|
|
||||||
const unsubscribes = [
|
const unsubscribes = [
|
||||||
Duel.on((state) => state.antagonist.shell, handleShellChange),
|
Tankopedia.on((state) => state.antagonist.shell, handleShellChange),
|
||||||
Tankopedia.on((state) => state.customShell, handleShellChange),
|
Tankopedia.on((state) => state.customShell, handleShellChange),
|
||||||
Duel.on(
|
Tankopedia.on(
|
||||||
(state) => state.protagonist.equipmentMatrix,
|
(state) => state.protagonist.equipment,
|
||||||
handleProtagonistEquipmentChange,
|
handleProtagonistEquipmentChange,
|
||||||
),
|
),
|
||||||
Duel.on(
|
Tankopedia.on(
|
||||||
(state) => state.antagonist.equipmentMatrix,
|
(state) => state.antagonist.equipment,
|
||||||
handleAntagonistEquipmentChange,
|
handleAntagonistEquipmentChange,
|
||||||
),
|
),
|
||||||
Duel.on(
|
Tankopedia.on(
|
||||||
(state) => state.equalize,
|
(state) => state.equalize,
|
||||||
() => {
|
() => {
|
||||||
handleProtagonistEquipmentChange();
|
handleProtagonistEquipmentChange();
|
||||||
|
|||||||
Reference in new issue
Block a user