mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-24 20:19:49 +02:00
SpacedArmorSubExternal
This commit is contained in:
1 parent
5d7482b158
commit
f17ac2b575
2 files changed
+32
-25
No files matched your search
@@ -23,9 +23,9 @@ import { hasEquipment } from "../../hooks/useEquipment";
|
|||||||
import { Tankopedia } from "../../stores/tankopedia";
|
import { Tankopedia } from "../../stores/tankopedia";
|
||||||
import { TankopediaPersistent } from "../../stores/tankopediaPersistent";
|
import { TankopediaPersistent } from "../../stores/tankopediaPersistent";
|
||||||
import { transitionEvent } from "../Lighting";
|
import { transitionEvent } from "../Lighting";
|
||||||
|
import { spacedArmorRenderTarget } from "./PrimaryArmorRenderTarget";
|
||||||
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";
|
||||||
import { spacedArmorRenderTarget } from "./PrimaryArmorRenderTarget";
|
|
||||||
|
|
||||||
interface PrimaryArmorSceneComponentProps {
|
interface PrimaryArmorSceneComponentProps {
|
||||||
thickness: number;
|
thickness: number;
|
||||||
|
|||||||
@@ -7,12 +7,15 @@ import {
|
|||||||
Plane,
|
Plane,
|
||||||
ShaderMaterial,
|
ShaderMaterial,
|
||||||
} from "three";
|
} from "three";
|
||||||
import type { ArmorUserData, ExternalModuleVariant } 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,
|
||||||
|
ExternalModuleVariant,
|
||||||
|
} 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";
|
||||||
|
|
||||||
@@ -49,47 +52,51 @@ export function SpacedArmorSubExternal({
|
|||||||
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;
|
||||||
}
|
}
|
||||||
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;
|
||||||
}
|
}
|
||||||
@@ -99,17 +106,17 @@ export function SpacedArmorSubExternal({
|
|||||||
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