Feat: Add swap, move, & drop items in quick slots
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user