feat: rename core armor to primary armor

This commit is contained in:
TrèsAbhi committed 2024-07-29 20:46:57 -05:00
1 parent b1685bcc12
commit 3889c0f75d
13 files changed
+57 -50

No files matched your search

@@ -15,8 +15,8 @@ export function Thicknesses({ thicknessRange }: ThicknessesProps) {
const showSpacedArmor = TankopediaPersistent.use(
(state) => state.model.visual.showSpacedArmor,
);
const showCoreArmor = TankopediaPersistent.use(
(state) => state.model.visual.showCoreArmor,
const showPrimaryArmor = TankopediaPersistent.use(
(state) => state.model.visual.showPrimaryArmor,
);
const mutateTankopediaPersistent = TankopediaPersistent.useMutation();
const mutateTankopediaEphemeral = TankopediaEphemeral.useMutation();
@@ -35,11 +35,11 @@ export function Thicknesses({ thicknessRange }: ThicknessesProps) {
<Flex
height="64px"
gap="2"
style={{ opacity: showCoreArmor ? 1 : 0.5, cursor: 'pointer' }}
style={{ opacity: showPrimaryArmor ? 1 : 0.5, cursor: 'pointer' }}
onClick={() => {
mutateTankopediaPersistent((draft) => {
draft.model.visual.showCoreArmor =
!draft.model.visual.showCoreArmor;
draft.model.visual.showPrimaryArmor =
!draft.model.visual.showPrimaryArmor;
});
mutateTankopediaEphemeral((draft) => {
draft.highlightArmor = undefined;
@@ -51,8 +51,8 @@ export function Thicknesses({ thicknessRange }: ThicknessesProps) {
{thicknessRange.quartile.toFixed(0)}
</Text>
<Flex gap="1">
{showCoreArmor ? <EyeOpenIcon /> : <EyeClosedIcon />}
<Text size="1">Core</Text>
{showPrimaryArmor ? <EyeOpenIcon /> : <EyeClosedIcon />}
<Text size="1">Primary</Text>
</Flex>
<Text color="gray" size="1">
0
@@ -8,10 +8,10 @@ import { useModelDefinitions } from '../../../hooks/useModelDefinitions';
import { useTankTransform } from '../../../hooks/useTankTransform';
import * as Duel from '../../../stores/duel';
import * as TankopediaPersistent from '../../../stores/tankopediaPersistent';
import { CoreArmorSceneComponent } from './CoreArmorSceneComponent';
import { ModelTankWrapper } from './ModelTankWrapper';
import { PrimaryArmorSceneComponent } from './PrimaryArmorSceneComponent';
export const CoreArmorScene = memo(() => {
export const PrimaryArmorScene = memo(() => {
const wrapper = useRef<Group>(null);
const modelDefinitions = useModelDefinitions();
const turretContainer = useRef<Group>(null);
@@ -49,7 +49,7 @@ export const CoreArmorScene = memo(() => {
if (!isVisible || spaced || thickness === undefined) return null;
return (
<CoreArmorSceneComponent
<PrimaryArmorSceneComponent
key={node.uuid}
thickness={thickness}
node={node}
@@ -75,7 +75,7 @@ export const CoreArmorScene = memo(() => {
return (
<group position={hullOrigin}>
<group key={node.uuid} position={turretOrigin}>
<CoreArmorSceneComponent
<PrimaryArmorSceneComponent
key={node.uuid}
thickness={thickness}
node={node}
@@ -105,7 +105,10 @@ export const CoreArmorScene = memo(() => {
key={node.uuid}
position={turretOrigin.clone().add(gunOrigin)}
>
<CoreArmorSceneComponent thickness={thickness} node={node} />
<PrimaryArmorSceneComponent
thickness={thickness}
node={node}
/>
</group>
</group>
);
@@ -15,7 +15,7 @@ import fragmentShader from './shaders/fragment.glsl';
import vertexShader from './shaders/vertex.glsl';
import { spacedArmorRenderTarget } from './target';
interface CoreArmorSceneComponentProps {
interface PrimaryArmorSceneComponentProps {
thickness: number;
node: Object3D;
}
@@ -24,10 +24,10 @@ const excludeMaterial = new MeshBasicMaterial({
colorWrite: false,
});
export function CoreArmorSceneComponent({
export function PrimaryArmorSceneComponent({
node,
thickness,
}: CoreArmorSceneComponentProps) {
}: PrimaryArmorSceneComponentProps) {
const tankopediaPersistentStore = TankopediaPersistent.useStore();
const duelStore = Duel.useStore();
const material = new ShaderMaterial({
@@ -45,8 +45,8 @@ void main() {
// world space in meters
vec4 spacedArmorDepthFragment = texture2D(spacedArmorDepth, screenCoordinates);
float spacedArmorDistance = depthToDistance(spacedArmorDepthFragment.r);
float coreArmorDistance = depthToDistance(gl_FragCoord.z);
float distanceFromSpacedArmor = coreArmorDistance - spacedArmorDistance;
float primaryArmorDistance = depthToDistance(gl_FragCoord.z);
float distanceFromSpacedArmor = primaryArmorDistance - spacedArmorDistance;
if (canSplash && isUnderSpacedArmor) {
float spacedArmorThickness = spacedArmorBufferFragment.r * penetration;
@@ -14,7 +14,7 @@ import { ArmorType } from './SpacedArmorScene';
import { ExternalModuleVariant } from './SpacedArmorSceneComponent';
export const layerTypeNames: Record<ArmorType | 'null', string> = {
[ArmorType.Core]: 'Core',
[ArmorType.Primary]: 'Primary',
[ArmorType.Spaced]: 'Spaced',
[ArmorType.External]: 'External',
null: 'Gap',
@@ -50,7 +50,7 @@ function LayerEntry({
<Text size="1" color="gray" style={{ width: 12 }}>
{layerIndex}
</Text>
<Text size="2" color={shotStatusColor} style={{ width: 47 }}>
<Text size="2" color={shotStatusColor} style={{ width: 48 }}>
{layerName}
</Text>
@@ -74,7 +74,8 @@ function LayerEntry({
</Text>
)}
{(layer.type === ArmorType.Core || layer.type === ArmorType.Spaced) && (
{(layer.type === ArmorType.Primary ||
layer.type === ArmorType.Spaced) && (
<>
<Text size="2" color={shotStatusColor} style={{ width: 80 }}>
{Math.round(layer.thicknessAngled).toLocaleString()}
@@ -140,7 +141,7 @@ export function ShotDisplayCard({ shot, ...props }: ShotDisplayCardProps) {
layerName={layerName}
shotStatusColor={shotStatusColor}
angle={
layer.type === ArmorType.Core ||
layer.type === ArmorType.Primary ||
layer.type === ArmorType.Spaced
? layer.angle
: undefined
@@ -206,7 +207,7 @@ export function ShotDisplayCard({ shot, ...props }: ShotDisplayCardProps) {
layerName={layerName}
shotStatusColor={shotStatusColor}
angle={
layer.type === ArmorType.Core ||
layer.type === ArmorType.Primary ||
layer.type === ArmorType.Spaced
? layer.angle
: undefined
@@ -12,7 +12,7 @@ import { ModelTankWrapper } from './ModelTankWrapper';
import { SpacedArmorSceneComponent } from './SpacedArmorSceneComponent';
export enum ArmorType {
Core,
Primary,
Spaced,
External,
}
@@ -67,7 +67,7 @@ export const SpacedArmorScene = memo<SpacedArmorSceneProps>(({ scene }) => {
<SpacedArmorSceneComponent
scene={scene}
key={node.uuid}
type={spaced ? ArmorType.Spaced : ArmorType.Core}
type={spaced ? ArmorType.Spaced : ArmorType.Primary}
thickness={thickness}
node={node}
/>
@@ -114,7 +114,7 @@ export const SpacedArmorScene = memo<SpacedArmorSceneProps>(({ scene }) => {
<SpacedArmorSceneComponent
scene={scene}
key={node.uuid}
type={spaced ? ArmorType.Spaced : ArmorType.Core}
type={spaced ? ArmorType.Spaced : ArmorType.Primary}
thickness={thickness}
node={node}
/>
@@ -145,7 +145,7 @@ export const SpacedArmorScene = memo<SpacedArmorSceneProps>(({ scene }) => {
>
<SpacedArmorSceneComponent
scene={scene}
type={spaced ? ArmorType.Spaced : ArmorType.Core}
type={spaced ? ArmorType.Spaced : ArmorType.Primary}
thickness={thickness}
node={node}
/>
@@ -105,7 +105,7 @@ export function SpacedArmorSceneComponent({
let depthWrite = true;
switch (props.type) {
case ArmorType.Core:
case ArmorType.Primary:
color = new Color(-((1 - x) ** 2) + 1, -(x ** 2) + 1, 0);
opacity = 1;
break;
@@ -280,7 +280,7 @@ export function SpacedArmorSceneComponent({
} else {
noDuplicateIntersections.push(intersection);
if (intersection.object.userData.type === ArmorType.Core) {
if (intersection.object.userData.type === ArmorType.Primary) {
break;
}
}
@@ -289,7 +289,7 @@ export function SpacedArmorSceneComponent({
if (
!allowRicochet &&
!noDuplicateIntersections.some((intersection) => {
intersection.object.userData.type === ArmorType.Core;
intersection.object.userData.type === ArmorType.Primary;
})
) {
return null;
@@ -386,7 +386,7 @@ export function SpacedArmorSceneComponent({
point: intersection.point,
surfaceNormal: intersection.face!.normal,
status:
shell.type === ShellType.HE && layer.type !== ArmorType.Core
shell.type === ShellType.HE && layer.type !== ArmorType.Primary
? 'blocked'
: blocked
? 'blocked'
@@ -416,7 +416,7 @@ export function SpacedArmorSceneComponent({
if (shell.type === ShellType.HE) {
const totalSpacedArmorThickness = shot.in.layers.reduce(
(acc, layer) => {
if (layer.type === null || layer.type === ArmorType.Core) {
if (layer.type === null || layer.type === ArmorType.Primary) {
return acc;
}
@@ -515,14 +515,14 @@ export function SpacedArmorSceneComponent({
return (
<>
{props.type === ArmorType.Core &&
{props.type === ArmorType.Primary &&
jsxTree(
node,
{
renderOrder: 0,
material: omitMaterial,
userData: {
type: ArmorType.Core,
type: ArmorType.Primary,
thickness,
} satisfies ArmorUserData,
async onClick(event) {
+9 -6
View File
@@ -1,18 +1,21 @@
import { createPortal, useFrame } from '@react-three/fiber';
import { memo, useState } from 'react';
import { DepthTexture, Scene, Vector2 } from 'three';
import { CoreArmorScene } from './components/CoreArmorScene';
import { spacedArmorRenderTarget } from './components/CoreArmorSceneComponent/target';
import { PrimaryArmorScene } from './components/PrimaryArmorScene';
import { spacedArmorRenderTarget } from './components/PrimaryArmorSceneComponent/target';
import { SpacedArmorScene } from './components/SpacedArmorScene';
export const Armor = memo(() => {
const [spacedArmorScene] = useState(() => new Scene());
const [coreArmorScene] = useState(() => new Scene());
const [primaryArmorScene] = useState(() => new Scene());
const spacedArmorPortal = createPortal(
<SpacedArmorScene scene={spacedArmorScene} />,
spacedArmorScene,
);
const coreArmorPortal = createPortal(<CoreArmorScene />, coreArmorScene);
const primaryArmorPortal = createPortal(
<PrimaryArmorScene />,
primaryArmorScene,
);
const renderSize = new Vector2();
const newRenderSize = new Vector2();
@@ -40,13 +43,13 @@ export const Armor = memo(() => {
gl.render(scene, camera);
gl.clearDepth();
gl.render(coreArmorScene, camera);
gl.render(primaryArmorScene, camera);
}, 1);
return (
<>
{spacedArmorPortal}
{coreArmorPortal}
{primaryArmorPortal}
</>
);
});
@@ -48,8 +48,8 @@ export const StaticArmorScene = memo<StaticArmorSceneProps>(
gunModelDefinition.mask === undefined
? undefined
: gunModelDefinition.mask + hullOrigin.y + turretOrigin.y + gunOrigin.y;
const showCoreArmor = TankopediaPersistent.use(
(state) => state.model.visual.showCoreArmor,
const showPrimaryArmor = TankopediaPersistent.use(
(state) => state.model.visual.showPrimaryArmor,
);
const showSpacedArmor = TankopediaPersistent.use(
(state) => state.model.visual.showSpacedArmor,
@@ -75,7 +75,7 @@ export const StaticArmorScene = memo<StaticArmorSceneProps>(
if (
!isVisible ||
thickness === undefined ||
(!showCoreArmor && !spaced) ||
(!showPrimaryArmor && !spaced) ||
(!showSpacedArmor && spaced)
)
return null;
@@ -86,7 +86,7 @@ export const StaticArmorScene = memo<StaticArmorSceneProps>(
thicknessRange={thicknessRange}
static
key={node.uuid}
type={spaced ? ArmorType.Spaced : ArmorType.Core}
type={spaced ? ArmorType.Spaced : ArmorType.Primary}
thickness={thickness}
node={node}
/>
@@ -130,7 +130,7 @@ export const StaticArmorScene = memo<StaticArmorSceneProps>(
if (
!isVisible ||
thickness === undefined ||
(!showCoreArmor && !spaced) ||
(!showPrimaryArmor && !spaced) ||
(!showSpacedArmor && spaced)
)
return null;
@@ -143,7 +143,7 @@ export const StaticArmorScene = memo<StaticArmorSceneProps>(
thicknessRange={thicknessRange}
static
key={node.uuid}
type={spaced ? ArmorType.Spaced : ArmorType.Core}
type={spaced ? ArmorType.Spaced : ArmorType.Primary}
thickness={thickness}
node={node}
/>
@@ -167,7 +167,7 @@ export const StaticArmorScene = memo<StaticArmorSceneProps>(
if (
!isVisible ||
thickness === undefined ||
(!showCoreArmor && !spaced) ||
(!showPrimaryArmor && !spaced) ||
(!showSpacedArmor && spaced)
)
return null;
@@ -182,7 +182,7 @@ export const StaticArmorScene = memo<StaticArmorSceneProps>(
name={node.name}
thicknessRange={thicknessRange}
static
type={spaced ? ArmorType.Spaced : ArmorType.Core}
type={spaced ? ArmorType.Spaced : ArmorType.Primary}
thickness={thickness}
node={node}
/>
+1 -1
View File
@@ -18,7 +18,7 @@ interface TankopediaEphemeral {
color: string;
} & (
| {
type: ArmorType.Core | ArmorType.Spaced;
type: ArmorType.Primary | ArmorType.Spaced;
thicknessAngled: number;
angle: number;
}
+2 -2
View File
@@ -23,7 +23,7 @@ export interface TankopediaPersistent {
showEnvironment: boolean;
showSpacedArmor: boolean;
showExternalModules: boolean;
showCoreArmor: boolean;
showPrimaryArmor: boolean;
};
};
sort: {
@@ -50,7 +50,7 @@ export const { Provider, use, useMutation, useStore } = createNextSafeStore(
visual: {
showSpacedArmor: true,
showExternalModules: true,
showCoreArmor: true,
showPrimaryArmor: true,
wireframe: false,
opaque: false,
environment: ENVIRONMENTS[0],