import { useSyncExternalStore } from "react"; import { activeDungeonEncounterRevision, subscribeDungeonEncounterSnapshots, } from "../game/dungeonEncounterRuntime"; import { activeDungeonInteractionCandidate, interactWithActiveDungeonObject, } from "../game/dungeonWorldInteraction"; import { useGameStore } from "../game/store"; import { useInputBindingLabels } from "../input/useInputBindingLabels"; export function DungeonInteractionPrompt({ interaction, onInteract }: { interaction?: { prompt: string; name: string; label: string } | null; onInteract?: () => void; } = {}) { const label = useInputBindingLabels(); const playerPosition = useGameStore((state) => state.playerPosition); const inputMode = useGameStore((state) => state.inputMode); const overlay = useGameStore((state) => state.overlay); useSyncExternalStore( subscribeDungeonEncounterSnapshots, activeDungeonEncounterRevision, activeDungeonEncounterRevision, ); void playerPosition; const local = interaction === undefined && !overlay ? activeDungeonInteractionCandidate() : null; const candidate = interaction ?? (local ? { prompt: local.object.interaction!.prompt, name: local.object.name, label: local.state.label } : null); if (!candidate) return null; return ( ); }