Auto Pickup

This commit is contained in:
Marco 2025-03-28 15:38:55 +01:00
commit 488d02ef81
24 changed files with 148 additions and 19 deletions

View file

@ -52,6 +52,11 @@ public partial class InventoryManager : Node2D
return _itemsDict.TryGetValue(key, out item);
}
public LootItem FindItemInDb(string key)
{
return ItemsDatabase.GetLootItem(key);
}
public bool HasItems(IList<string> itemKeys)
{
return itemKeys.Aggregate(false, (current, item) => current || GetItemCount(item) > 0);
@ -87,6 +92,19 @@ public partial class InventoryManager : Node2D
}
public bool CanAddItem(string itemKey)
{
var found = TryGetItem(itemKey, out var itm);
if (found)
{
return (itm.Count < itm.Item.Max);
}
var dbItem = FindItemInDb(itemKey);
return dbItem != null;
}
public bool AddItem(LootItem item)
{
//var item = new LootItem() { Item = type, Amount = amount };