Feat: Add swap, move, & drop items in quick slots

This commit is contained in:
Peter Stockings
2026-01-21 14:33:29 +11:00
parent 219c1c8899
commit 9196c49976
2 changed files with 124 additions and 1 deletions

View File

@@ -263,6 +263,29 @@ export class GameScene extends Phaser.Scene {
}
});
this.events.on("drop-item", (data: { itemId: string, pointerX: number, pointerY: number }) => {
if (!this.awaitingPlayer) return;
const player = this.world.actors.get(this.playerId) as CombatantActor;
if (!player || !player.inventory) return;
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 };
// Remove from inventory and spawn in world
if (this.itemManager.removeFromInventory(player, data.itemId)) {
this.itemManager.spawnItem(item, dropPos);
const quantityText = (item.quantity && item.quantity > 1) ? ` x${item.quantity}` : "";
this.dungeonRenderer.showFloatingText(player.pos.x, player.pos.y, `Dropped ${item.name}${quantityText}`, "#aaaaaa");
this.emitUIUpdate();
}
});
// Right Clicks to cancel targeting
this.input.on('pointerdown', (p: Phaser.Input.Pointer) => {
if (p.rightButtonDown() && this.targetingSystem.isActive) {