import { requireDungeonDefinition } from "../game/dungeonRegistry"; import { useGameStore } from "../game/store"; export function DungeonMapGraphic({ position, yaw, compact = false, dungeonId }: { position: readonly [number, number, number]; yaw: number; compact?: boolean; dungeonId?: string; }) { const activeDungeonId = useGameStore((state) => state.activeDungeonId); const dungeon = requireDungeonDefinition(dungeonId ?? activeDungeonId); const { width: viewWidth, height: viewHeight, padding, contours } = dungeon.presentation.map; const width = Math.max(1, dungeon.bounds.max[0] - dungeon.bounds.min[0]); const depth = Math.max(1, dungeon.bounds.max[2] - dungeon.bounds.min[2]); const project = (point: readonly [number, number, number]): readonly [number, number] => [ padding + ((point[0] - dungeon.bounds.min[0]) / width) * (viewWidth - padding * 2), padding + ((point[2] - dungeon.bounds.min[2]) / depth) * (viewHeight - padding * 2), ]; const [playerX, playerY] = project(position); const headingX = Math.sin(yaw) * 12; const headingY = Math.cos(yaw) * 12; const id = `${dungeon.id}-${compact ? "companion" : "dialog"}-map`; return ( {contours.map((path, index) => ( ))} {!compact && dungeon.roamingPacks.map((pack) => { const points = pack.waypoints.map((waypoint) => project(waypoint).join(",")).join(" "); const [startX, startY] = project(pack.waypoints[0]); return {pack.name}; })} {dungeon.areas.map((checkpoint, index) => { const [x, y] = project(checkpoint.center); return {checkpoint.name}; })} ); }