import React from 'react'; import Icon from './Icon'; /** * Hotbar — панель из 5 слотов инвентаря внизу экрана. Активный слот * подсвечен синим градиентом Рублокса. Клик и цифры 1-5 переключают. * * Видимая в Play. В редакторе скрыта. * * Props: * visible — bool * slots — массив элементов: { id, kind, modelTypeId, name, params } | null * activeIndex — индекс выделенного слота * onSelect(i) — переключить активный слот */ function Hotbar({ visible, slots = [], activeIndex = 0, onSelect, mobileMode = false }) { if (!visible) return null; const SLOT_COUNT = 5; const cells = []; for (let i = 0; i < SLOT_COUNT; i++) { const item = slots[i] || null; const active = i === activeIndex; cells.push(
onSelect?.(i)} style={{ width: 60, height: 60, background: active ? 'linear-gradient(135deg, rgba(51, 87, 255, 0.45) 0%, rgba(30, 45, 165, 0.55) 100%)' : 'rgba(255, 255, 255, 0.04)', border: active ? '2px solid #3357ff' : '2px solid rgba(255, 255, 255, 0.10)', borderRadius: 12, boxSizing: 'border-box', position: 'relative', cursor: 'pointer', display: 'flex', alignItems: 'center', justifyContent: 'center', color: '#f1f5fb', transition: 'all 200ms cubic-bezier(0.34, 1.56, 0.64, 1)', pointerEvents: 'auto', boxShadow: active ? '0 8px 20px rgba(51, 87, 255, 0.45), 0 0 0 4px rgba(51, 87, 255, 0.18), inset 0 1px 0 rgba(255,255,255,0.12)' : 'inset 0 1px 0 rgba(255,255,255,0.04)', transform: active ? 'translateY(-3px) scale(1.05)' : 'translateY(0) scale(1)', }} title={item ? item.name : `Слот ${i + 1}`} > {/* Цифра слота сверху-слева */}
{i + 1}
{/* Содержимое слота — иконка-эмодзи + название */} {item ? (
{item.name}
) : ( /* Пустой слот — лёгкая точка-плейсхолдер */
)}
); } return (
{cells}
); } /** Имя иконки (для ) по виду предмета. */ function iconForItem(item) { if (!item) return 'box'; if (item.kind === 'weapon') { if (item.modelTypeId?.startsWith('blaster')) return 'crosshair'; if (item.modelTypeId?.includes('sword')) return 'sword'; if (item.modelTypeId?.includes('spear')) return 'sword'; if (item.modelTypeId?.includes('bow')) return 'target'; return 'sword'; } if (item.kind === 'tool') return 'wrench'; if (item.kind === 'potion') return 'flask'; return 'box'; } export default Hotbar;