WIP reworking the item repository

This commit is contained in:
2025-09-09 23:57:55 +02:00
parent 9f50e1d293
commit d1a8ff0cbf
9 changed files with 97 additions and 75 deletions
@@ -0,0 +1,28 @@
using Godot;
using Godot.Collections;
namespace Babushka.scripts.CSharp.Common.Inventory;
/// <summary>
/// A dictionary wrapper resource that holds references to ItemResources and maps them to their respective prefabs.
/// </summary>
[GlobalClass]
public partial class ItemRepository : Resource
{
[Export] public Dictionary<ItemResource, string> itemInventoryRepository;
/// <summary>
/// Returns the path to the itemPrefab for the inventory item.
/// </summary>
/// <param name="resource"></param>
/// <returns></returns>
public string TryGetPrefabPath(ItemResource resource)
{
if (itemInventoryRepository.Keys.Contains(resource))
{
return itemInventoryRepository[resource];
}
return null;
}
}