Restructured for new direction.
This commit is contained in:
@@ -35,39 +35,38 @@ namespace BriarQueen.Framework.Registries
|
||||
{
|
||||
_entryLookup = new Dictionary<string, ItemDataSo>();
|
||||
|
||||
AddEntries(_puzzleSlots, "Puzzle Slots");
|
||||
AddEntries(_pickupItems, "Pickup Items");
|
||||
AddEntries(_environmentInteractables, "Environment Interactables");
|
||||
}
|
||||
RegistryLookupBuilder.AddEntries(
|
||||
_entryLookup,
|
||||
_puzzleSlots,
|
||||
this,
|
||||
nameof(ItemRegistry),
|
||||
"Puzzle Slots",
|
||||
"UniqueID",
|
||||
entry => entry.UniqueID,
|
||||
entry => entry,
|
||||
entry => RegistryLookupBuilder.HasNonEmptyKey(entry.UniqueID));
|
||||
|
||||
private void AddEntries(List<ItemDataSo> entries, string category)
|
||||
{
|
||||
if (entries == null)
|
||||
return;
|
||||
RegistryLookupBuilder.AddEntries(
|
||||
_entryLookup,
|
||||
_pickupItems,
|
||||
this,
|
||||
nameof(ItemRegistry),
|
||||
"Pickup Items",
|
||||
"UniqueID",
|
||||
entry => entry.UniqueID,
|
||||
entry => entry,
|
||||
entry => RegistryLookupBuilder.HasNonEmptyKey(entry.UniqueID));
|
||||
|
||||
foreach (var entry in entries)
|
||||
{
|
||||
if (entry == null)
|
||||
continue;
|
||||
|
||||
if (string.IsNullOrWhiteSpace(entry.UniqueID))
|
||||
{
|
||||
Debug.LogWarning(
|
||||
$"[ItemRegistry] Skipping {category} entry '{entry.name}' because UniqueID is empty.",
|
||||
this);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (_entryLookup.ContainsKey(entry.UniqueID))
|
||||
{
|
||||
Debug.LogError(
|
||||
$"[ItemRegistry] Duplicate UniqueID detected: '{entry.UniqueID}' from entry '{entry.name}'.",
|
||||
this);
|
||||
continue;
|
||||
}
|
||||
|
||||
_entryLookup.Add(entry.UniqueID, entry);
|
||||
}
|
||||
RegistryLookupBuilder.AddEntries(
|
||||
_entryLookup,
|
||||
_environmentInteractables,
|
||||
this,
|
||||
nameof(ItemRegistry),
|
||||
"Environment Interactables",
|
||||
"UniqueID",
|
||||
entry => entry.UniqueID,
|
||||
entry => entry,
|
||||
entry => RegistryLookupBuilder.HasNonEmptyKey(entry.UniqueID));
|
||||
}
|
||||
|
||||
public bool TryGetEntry(string itemID, out ItemDataSo entry)
|
||||
@@ -130,4 +129,4 @@ namespace BriarQueen.Framework.Registries
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user