Added new fruit prefabs

This commit is contained in:
Pasha Bibko
2026-04-21 11:37:33 +01:00
parent 30a743cdbf
commit 34f2169607
60 changed files with 2824 additions and 23 deletions

View File

@@ -2,14 +2,15 @@
using System.Collections.Generic;
using UnityEngine;
using System;
using Unity.Plastic.Antlr3.Runtime.Tree;
namespace Fruitomation.Game.Items
{
public class ItemInfoRegistry : MonoBehaviour
{
[Header("References")]
[SerializeField] private SerializedItemInfoRegistry SerializedRegistry;
[Header("References")] [SerializeField]
private SerializedItemInfoRegistry SerializedRegistry;
private Dictionary<ItemType, ItemInfo> Dictionary;
private static ItemInfoRegistry Instance;
@@ -34,22 +35,31 @@ namespace Fruitomation.Game.Items
}
}
[InspectorCallable("Load Registry")] private void LoadFromRegistry()
[InspectorCallable("Load Registry")]
private void LoadFromRegistry()
{
Dictionary = new Dictionary<ItemType, ItemInfo>();
foreach (ItemInfo info in SerializedRegistry.Registry)
{
Dictionary.Add(info.Type, info);
}
#if UNITY_EDITOR
ItemType[] types = Enum.GetValues(typeof(ItemType)) as ItemType[];
Debug.Assert(types != null, nameof(types) + " != null");
foreach (ItemType type in types)
{
bool contained = Dictionary.ContainsKey(type);
if (!contained)
if (type == ItemType.None)
{
if (contained)
{
Debug.LogError("ItemType.None should not be included in ItemInfoRegistry");
}
}
else if (!contained)
{
Debug.LogWarning($"Type [{type}] is not contained in the registry");
}
@@ -57,6 +67,15 @@ namespace Fruitomation.Game.Items
#endif // UNITY_EDITOR
}
public static ItemInfo Get(ItemType type) => Instance.Dictionary[type];
public static ItemInfo Get(ItemType type)
{
if (type == ItemType.None)
{
Debug.LogError("ItemType.None is not a valid ItemType value for ItemInfoRegistry.Get");
return null;
}
return Instance.Dictionary[type];
}
}
}