import React from 'react' import { useScale } from '../../context/ScaleContext' import type { EntityDisplayArea, InventoryTypeDefinition } from '../../types' import { ENTITY_PLACEHOLDER_IMAGES } from './defaultEntityImages' interface EntityDisplayProps { area: EntityDisplayArea placeholder: NonNullable /** When true, draw layout debug bounds instead of the default image (ignored if renderEntity is set). */ debug?: boolean renderEntity?: ((width: number, height: number) => React.ReactNode) | null } export function EntityDisplay({ area, placeholder, debug = false, renderEntity, }: EntityDisplayProps) { const { scale } = useScale() if (renderEntity === null) return null const w = area.width * scale const h = area.height * scale let content: React.ReactNode if (renderEntity) { content = renderEntity(w, h) } else if (debug) { content = (
) } else { const image = ENTITY_PLACEHOLDER_IMAGES[placeholder] if (!image) return null content = ( ) } return (
{content}
) }