������ 14/16/20/40/44: vehicle, ����, ����������, damage floaters, ��������� #20

Merged
min merged 30 commits from feat/vehicle-task14 into main 2026-06-07 14:09:59 +00:00
Showing only changes of commit 5f789764a6 - Show all commits

View File

@ -64,7 +64,7 @@ export class InventoryUI {
add(itemId, count = 1) {
const def = this._def(itemId);
let left = count;
// 1) долить в существующие стаки (grid, потом hotbar)
// 1) долить в существующие стаки (сначала hotbar — он на виду, потом grid)
const fill = (arr) => {
for (let i = 0; i < arr.length && left > 0; i++) {
const s = arr[i];
@ -75,14 +75,14 @@ export class InventoryUI {
}
}
};
fill(this.grid); fill(this.hotbar);
// 2) в пустые слоты (grid, потом hotbar)
fill(this.hotbar); fill(this.grid);
// 2) в пустые слоты (сначала hotbar — собранное видно сразу, потом grid)
const place = (arr) => {
for (let i = 0; i < arr.length && left > 0; i++) {
if (!arr[i]) { const take = Math.min(def.maxStack, left); arr[i] = { itemId, count: take }; left -= take; }
}
};
place(this.grid); place(this.hotbar);
place(this.hotbar); place(this.grid);
const added = count - left;
if (added > 0) { this._emit('added', { itemId, count: added }); this._changed(); }
return { added, overflow: left };
@ -194,7 +194,7 @@ export class InventoryUI {
mountHotbar() {
if (this.hotbarRoot) return;
const r = document.createElement('div');
r.style.cssText = 'position:absolute;left:50%;bottom:14px;transform:translateX(-50%);z-index:48;display:flex;gap:6px;pointer-events:auto;font-family:Inter,system-ui,sans-serif';
r.style.cssText = 'position:absolute;left:50%;bottom:64px;transform:translateX(-50%);z-index:48;display:flex;gap:6px;pointer-events:auto;font-family:Inter,system-ui,sans-serif';
this._parent().appendChild(r); this.hotbarRoot = r;
this._renderHotbar();
}