You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Babushka/scripts/CSharp/Common/Inventory/ItemRepository.cs

29 lines
789 B

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;
}
}