Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 | 1960x 1960x 1960x 28x 24x 3x 3x 1x 29x 29x 29x 29x 1x 1x 1x 1x 29x 29x 28x 1960x 1960x 29x 28x 28x 28x 28x 29x 29x 29x 29x 29x 29x 29x 29x 29x 29x 1x | /**
* LiPrecisionTargetingOverlay.tsx
*
* Targeting reticle and vital point display for Li (Fire) stance precision strikes.
* Shows available vital points, targeting accuracy, and precision feedback.
*
* Features:
* - Dynamic targeting reticle with crosshair
* - Vital points in range with distance indicators
* - Real-time accuracy meter
* - Korean cyberpunk aesthetic with neon glow effects
* - Bilingual text (Korean/English)
*
* Performance: Optimized for 60fps with minimal DOM updates
*
* @module components/screens/combat/components/effects/LiPrecisionTargetingOverlay
* @korean 리괘정밀조준오버레이
*/
import React, { useMemo, useEffect } from "react";
import { KOREAN_VITAL_POINTS } from "../../../../../systems/vitalpoint/KoreanVitalPoints";
import { KOREAN_COLORS, SPACING } from "../../../../../types/constants";
import { FONT_SIZES } from "../../../../../types/constants/typography";
import {
formatBilingualText,
getEnhancedKoreanOverlayStyles,
} from "../../../../../utils/koreanThemeHelpers";
import {
getNeonGlowEffect,
getNeonTextShadow,
} from "../../../../../utils/visualEffects";
import { hexToRgbaString } from "../../../../../utils/colorUtils";
/**
* Props for LiPrecisionTargetingOverlay component
*/
export interface LiPrecisionTargetingOverlayProps {
/** Whether the player is currently in Li stance */
readonly isLiStance: boolean;
/** Current targeting accuracy (0.0 to 1.0) */
readonly accuracy: number;
/** Player position for range calculation [x, y] */
readonly playerPosition: readonly [number, number];
/** Maximum targeting range in meters */
readonly maxRange?: number;
/** Currently selected/hovered vital point ID */
readonly selectedVitalPointId: string | null;
/** Callback when vital point is selected */
readonly onVitalPointSelect?: (vitalPointId: string) => void;
/** Whether on mobile device */
readonly isMobile: boolean;
}
/**
* Calculate distance between two positions
*/
function calculateDistance(
pos1: readonly [number, number],
pos2: { x: number; y: number }
): number {
const dx = pos1[0] - pos2.x;
const dy = pos1[1] - pos2.y;
return Math.sqrt(dx * dx + dy * dy);
}
/**
* Get accuracy color based on precision level
*/
function getAccuracyColor(accuracy: number): string {
if (accuracy >= 0.9) return hexToRgbaString(KOREAN_COLORS.POSITIVE_GREEN, 1.0);
if (accuracy >= 0.7) return hexToRgbaString(KOREAN_COLORS.ACCENT_GOLD, 1.0);
Iif (accuracy >= 0.5) return hexToRgbaString(KOREAN_COLORS.WARNING_ORANGE, 1.0);
return hexToRgbaString(KOREAN_COLORS.ACCENT_RED, 1.0);
}
/**
* LiPrecisionTargetingOverlay Component
*
* Displays targeting UI for Li stance precision strikes with vital point overlay
*/
export const LiPrecisionTargetingOverlay: React.FC<LiPrecisionTargetingOverlayProps> =
React.memo(
({
isLiStance,
accuracy,
playerPosition,
maxRange = 3.0,
selectedVitalPointId,
onVitalPointSelect,
isMobile,
}) => {
// Inject keyframe animation once globally (persists across component instances)
useEffect(() => {
const styleId = "li-precision-targeting-keyframes";
// Check if already injected globally - if so, don't remove on unmount
const alreadyExists = document.getElementById(styleId);
if (alreadyExists) return;
const style = document.createElement("style");
style.id = styleId;
style.textContent = `
@keyframes pulse-reticle {
0%, 100% {
transform: scale(1);
opacity: 0.8;
}
50% {
transform: scale(1.05);
opacity: 1.0;
}
}
`;
document.head.appendChild(style);
// Don't remove on unmount - leave it for other instances
// Style persists globally to avoid re-injection
}, []);
// Filter vital points in range (hooks must be called unconditionally)
const vitalPointsInRange = useMemo(() => {
if (!isLiStance) return [];
return KOREAN_VITAL_POINTS.filter((vp) => {
const distance = calculateDistance(playerPosition, vp.position);
return distance <= maxRange;
})
.sort((a, b) => {
// Sort by distance (closest first)
const distA = calculateDistance(playerPosition, a.position);
const distB = calculateDistance(playerPosition, b.position);
return distA - distB;
})
.slice(0, isMobile ? 3 : 5); // Limit to 3 on mobile, 5 on desktop
}, [isLiStance, playerPosition, maxRange, isMobile]);
// Only show when in Li stance
if (!isLiStance) return null;
// Accuracy percentage
const accuracyPercent = Math.round(accuracy * 100);
const accuracyColor = getAccuracyColor(accuracy);
// Container styles
const containerStyle: React.CSSProperties = {
position: "absolute",
top: 0,
left: 0,
right: 0,
bottom: 0,
pointerEvents: "none",
zIndex: 100,
display: "flex",
flexDirection: "column",
alignItems: "center",
justifyContent: "center",
gap: SPACING.md,
};
// Targeting reticle styles
const reticleContainerStyle: React.CSSProperties = {
position: "relative",
width: isMobile ? "120px" : "150px",
height: isMobile ? "120px" : "150px",
display: "flex",
alignItems: "center",
justifyContent: "center",
};
const reticleStyle: React.CSSProperties = {
width: "100%",
height: "100%",
border: `2px solid ${hexToRgbaString(KOREAN_COLORS.TRIGRAM_LI_PRIMARY, 0.8)}`,
borderRadius: "50%",
boxShadow: getNeonGlowEffect(KOREAN_COLORS.TRIGRAM_LI_PRIMARY, "medium", true),
animation: "pulse-reticle 2s ease-in-out infinite",
};
const crosshairHorizontalStyle: React.CSSProperties = {
position: "absolute",
top: "50%",
left: "10%",
right: "10%",
height: "2px",
backgroundColor: hexToRgbaString(KOREAN_COLORS.TRIGRAM_LI_PRIMARY, 0.8),
transform: "translateY(-50%)",
boxShadow: getNeonGlowEffect(KOREAN_COLORS.TRIGRAM_LI_PRIMARY, "subtle", false),
};
const crosshairVerticalStyle: React.CSSProperties = {
position: "absolute",
left: "50%",
top: "10%",
bottom: "10%",
width: "2px",
backgroundColor: hexToRgbaString(KOREAN_COLORS.TRIGRAM_LI_PRIMARY, 0.8),
transform: "translateX(-50%)",
boxShadow: getNeonGlowEffect(KOREAN_COLORS.TRIGRAM_LI_PRIMARY, "subtle", false),
};
const centerDotStyle: React.CSSProperties = {
position: "absolute",
top: "50%",
left: "50%",
width: "8px",
height: "8px",
borderRadius: "50%",
backgroundColor: hexToRgbaString(KOREAN_COLORS.TRIGRAM_LI_PRIMARY, 1.0),
transform: "translate(-50%, -50%)",
boxShadow: getNeonGlowEffect(KOREAN_COLORS.TRIGRAM_LI_PRIMARY, "strong", true),
};
// Accuracy meter styles
const accuracyMeterStyle: React.CSSProperties = {
...getEnhancedKoreanOverlayStyles({
opacity: 0.85,
glowIntensity: "medium",
includeGradient: false,
includeBackdropBlur: true,
depthLayers: 2,
}),
padding: isMobile ? SPACING.xs : SPACING.sm,
borderRadius: "8px",
display: "flex",
flexDirection: "column",
alignItems: "center",
gap: SPACING.xs,
};
const accuracyLabelStyle: React.CSSProperties = {
fontSize: isMobile ? `${FONT_SIZES.tiny}px` : `${FONT_SIZES.small}px`,
color: hexToRgbaString(KOREAN_COLORS.TEXT_SECONDARY, 1.0),
textShadow: getNeonTextShadow(KOREAN_COLORS.TEXT_SECONDARY, "subtle"),
fontWeight: 500,
letterSpacing: "0.5px",
};
const accuracyValueStyle: React.CSSProperties = {
fontSize: isMobile ? `${FONT_SIZES.large}px` : `${FONT_SIZES.xlarge}px`,
color: accuracyColor,
textShadow: getNeonTextShadow(
accuracy >= 0.9
? KOREAN_COLORS.POSITIVE_GREEN
: accuracy >= 0.7
? KOREAN_COLORS.ACCENT_GOLD
: KOREAN_COLORS.ACCENT_RED,
"strong"
),
fontWeight: 700,
letterSpacing: "1px",
};
// Vital points list styles
const vitalPointsListStyle: React.CSSProperties = {
...getEnhancedKoreanOverlayStyles({
opacity: 0.85,
glowIntensity: "medium",
includeGradient: false,
includeBackdropBlur: true,
depthLayers: 2,
}),
padding: isMobile ? SPACING.xs : SPACING.sm,
borderRadius: "8px",
display: "flex",
flexDirection: "column",
gap: SPACING.xs,
maxWidth: isMobile ? "200px" : "280px",
};
const vitalPointHeaderStyle: React.CSSProperties = {
fontSize: isMobile ? `${FONT_SIZES.tiny}px` : `${FONT_SIZES.small}px`,
color: hexToRgbaString(KOREAN_COLORS.TRIGRAM_LI_PRIMARY, 1.0),
textShadow: getNeonTextShadow(KOREAN_COLORS.TRIGRAM_LI_PRIMARY, "medium"),
fontWeight: 600,
textAlign: "center",
borderBottom: `1px solid ${hexToRgbaString(KOREAN_COLORS.TRIGRAM_LI_PRIMARY, 0.3)}`,
paddingBottom: SPACING.xs,
};
return (
<div style={containerStyle}>
{/* Targeting Reticle */}
<div style={reticleContainerStyle}>
<div style={reticleStyle}>
<div style={crosshairHorizontalStyle} />
<div style={crosshairVerticalStyle} />
<div style={centerDotStyle} />
</div>
</div>
{/* Accuracy Meter */}
<div style={accuracyMeterStyle}>
<div style={accuracyLabelStyle}>
{formatBilingualText("정밀도", "Precision")}
</div>
<div style={accuracyValueStyle}>{accuracyPercent}%</div>
</div>
{/* Vital Points in Range */}
{vitalPointsInRange.length > 0 && (
<div style={vitalPointsListStyle}>
<div style={vitalPointHeaderStyle}>
{formatBilingualText("사정거리 내 급소", "Vital Points in Range")}
</div>
{vitalPointsInRange.map((vp) => {
const distance = calculateDistance(playerPosition, vp.position);
const isSelected = vp.id === selectedVitalPointId;
const vitalPointItemStyle: React.CSSProperties = {
fontSize: isMobile ? "10px" : `${FONT_SIZES.tiny}px`,
color: isSelected
? hexToRgbaString(KOREAN_COLORS.ACCENT_GOLD, 1.0)
: hexToRgbaString(KOREAN_COLORS.TEXT_PRIMARY, 1.0),
textShadow: isSelected
? getNeonTextShadow(KOREAN_COLORS.ACCENT_GOLD, "strong")
: getNeonTextShadow(KOREAN_COLORS.TEXT_PRIMARY, "subtle"),
fontWeight: isSelected ? 600 : 400,
display: "flex",
justifyContent: "space-between",
alignItems: "center",
padding: SPACING.xs,
borderRadius: "4px",
backgroundColor: isSelected
? hexToRgbaString(KOREAN_COLORS.ACCENT_GOLD, 0.15)
: "transparent",
border: isSelected
? `1px solid ${hexToRgbaString(KOREAN_COLORS.ACCENT_GOLD, 0.5)}`
: "1px solid transparent",
transition: "all 0.2s ease-in-out",
cursor: onVitalPointSelect ? "pointer" : "default",
pointerEvents: onVitalPointSelect ? "auto" : "none",
};
const distanceStyle: React.CSSProperties = {
fontSize: isMobile ? "9px" : "11px",
color: hexToRgbaString(KOREAN_COLORS.TEXT_TERTIARY, 0.8),
fontWeight: 500,
};
return (
<div
key={vp.id}
style={vitalPointItemStyle}
{...(onVitalPointSelect && {
onClick: () => onVitalPointSelect(vp.id),
onKeyDown: (e: React.KeyboardEvent<HTMLDivElement>) => {
if (e.key === "Enter" || e.key === " ") {
e.preventDefault();
onVitalPointSelect(vp.id);
}
},
role: "button" as const,
tabIndex: 0,
})}
>
<span>
{formatBilingualText(vp.names.korean, vp.names.english)}
</span>
<span style={distanceStyle}>{distance.toFixed(1)}m</span>
</div>
);
})}
</div>
)}
</div>
);
}
);
LiPrecisionTargetingOverlay.displayName = "LiPrecisionTargetingOverlay";
|