Skip to content

Commit

Permalink
Populate allitemdict, check new items are unique
Browse files Browse the repository at this point in the history
Co-Authored-By: bdlm-dev <[email protected]>
  • Loading branch information
MegaPiggy and bdlm-dev committed Jun 25, 2024
1 parent 897e934 commit 64e49b5
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion Winch/Util/ItemUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ internal static class ItemUtil
};

public static Dictionary<string, ItemData> HarvestableItemDataDict = new();
public static Dictionary<string, ItemData> AllItemDataDict = new();

public static void PopulateItemData()
{
Expand All @@ -34,8 +35,10 @@ public static void PopulateItemData()
if (item is FishItemData or RelicItemData or HarvestableItemData)
{
HarvestableItemDataDict.Add(item.id, item);
WinchCore.Log.Debug($"Added item {item.id} to HarvestableItemDataDict");
}
WinchCore.Log.Debug($"Added item {item.id} to HarvestableItemDataDict");
AllItemDataDict.Add(item.id, item);
WinchCore.Log.Debug($"Added item {item.id} to AllItemDataDict");
}
}

Expand All @@ -47,8 +50,15 @@ internal static void AddItemFromMeta<T>(string metaPath) where T : ItemData
WinchCore.Log.Error($"Meta file {metaPath} is empty");
return;
}
if (AllItemDataDict.ContainsKey((string)meta["id"]))
{
WinchCore.Log.Error($"Duplicate item {(string)meta["id"]} at {metaPath} failed to load");
return;
}
var item = UtilHelpers.GetScriptableObjectFromMeta<T>(meta, metaPath);
if (UtilHelpers.PopulateObjectFromMeta<T>(item, meta, Converters))
{
GameManager.Instance.ItemManager.allItems.Add(item);
}
}
}

0 comments on commit 64e49b5

Please sign in to comment.