import type { CSSProperties } from "react"; import type { Vector3Tuple } from "../game/dungeonManifest"; import { DungeonMapGraphic } from "./DungeonMapGraphic"; import { useInputBindingLabels } from "../input/useInputBindingLabels"; import { useGameStore } from "../game/store"; import { requireDungeonDefinition } from "../game/dungeonRegistry"; import { wowDungeonMapFor, wowMapFloorFor, wowMapHeading } from "../game/wowDungeonMap"; export interface MinimapProps { position: Vector3Tuple; yaw: number; areaName: string; distanceTravelled?: number; rotationMode?: "north-up" | "player-up"; onOpenMap: () => void; } export function Minimap({ position, yaw, areaName, distanceTravelled = 0, rotationMode = "north-up", onOpenMap, }: MinimapProps) { const bindingLabel = useInputBindingLabels(); const inputMode = useGameStore((state) => state.inputMode); const dungeonId = useGameStore((state) => state.activeDungeonId); const map = wowDungeonMapFor(requireDungeonDefinition(dungeonId)); const direction = map ? wowMapHeading(map, wowMapFloorFor(map, position), position, yaw) : null; const compassYaw = direction ? Math.atan2(direction[0], -direction[1]) : yaw; const mapKey = bindingLabel(inputMode === "gamepad" ? "controller" : "pc", "map"); const heading = ((Math.round((compassYaw * 180) / Math.PI) % 360) + 360) % 360; return (
{areaName} {Math.round(distanceTravelled)} m explored · {mapKey !== "Unbound" && {mapKey}} map
); }