Throw item

This commit is contained in:
2024-09-22 14:40:53 -07:00
parent 490f0d17d2
commit 84ee313ce5
9 changed files with 30 additions and 34 deletions

View File

@@ -237,6 +237,9 @@ public partial class InventoryMenu : Control, IInventoryMenu
{
foreach (var item in ItemSlots)
ItemsPage.RemoveChildEx(item);
ItemDescriptionTitle.Text = string.Empty;
ItemEffectLabel.Text = string.Empty;
}
private void PopulatePlayerInfo()
@@ -408,23 +411,22 @@ public partial class InventoryMenu : Control, IInventoryMenu
{
var currentItem = ItemSlots[_currentIndex].Item;
if (currentItem is IThrowableItem throwable)
{
throwable.Throw();
Game.ThrowItem(currentItem);
GameRepo.PlayerData.Inventory.Remove(currentItem);
if (_currentIndex >= ItemSlots.Length - 1)
_currentIndex--;
if (_currentIndex <= 0)
_currentIndex = 0;
if (_currentIndex >= ItemSlots.Length - 1)
_currentIndex--;
if (_currentIndex <= 0)
_currentIndex = 0;
EmitSignal(SignalName.ClosedMenu);
}
EmitSignal(SignalName.ClosedMenu);
}
private async void DropButtonPressed()
{
var currentItem = ItemSlots[_currentIndex].Item;
Game.DropItem(currentItem);
GameRepo.PlayerData.Inventory.Remove(currentItem);
if (_currentIndex >= ItemSlots.Length - 1)
_currentIndex--;