feat: make items in backpack draggable to and from quickslot

This commit is contained in:
Peter Stockings
2026-01-21 15:18:42 +11:00
parent a11f86d23b
commit ff6b6bfb73
5 changed files with 273 additions and 24 deletions

View File

@@ -272,8 +272,21 @@ export class GameScene extends Phaser.Scene {
const item = this.itemManager.getItem(player, data.itemId);
if (!item) return;
// Drop position is simply on the player's current tile
const dropPos = { x: player.pos.x, y: player.pos.y };
// Determine drop position based on pointer or player pos
let dropPos = { x: player.pos.x, y: player.pos.y };
if (data.pointerX !== undefined && data.pointerY !== undefined) {
const tilePos = this.getPointerTilePos({ x: data.pointerX, y: data.pointerY } as Phaser.Input.Pointer);
// Limit drop distance to 1 tile from player for balance/fairness
const dx = Math.sign(tilePos.x - player.pos.x);
const dy = Math.sign(tilePos.y - player.pos.y);
const targetX = player.pos.x + dx;
const targetY = player.pos.y + dy;
if (inBounds(this.world, targetX, targetY) && !isBlocked(this.world, targetX, targetY, this.entityManager)) {
dropPos = { x: targetX, y: targetY };
}
}
// Remove from inventory and spawn in world
if (this.itemManager.removeFromInventory(player, data.itemId)) {