WIP reworking the item repository
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user