diff --git a/SabreTools.DatFiles/ItemDictionaryDB.cs b/SabreTools.DatFiles/ItemDictionaryDB.cs index 38cb87c5..96e23e33 100644 --- a/SabreTools.DatFiles/ItemDictionaryDB.cs +++ b/SabreTools.DatFiles/ItemDictionaryDB.cs @@ -135,7 +135,7 @@ namespace SabreTools.DatFiles /// /// Get an item based on the index /// - public DatItem? GetItemByIndex(long index) + public DatItem? GetItem(long index) { if (!_items.ContainsKey(index)) return null; @@ -146,7 +146,7 @@ namespace SabreTools.DatFiles /// /// Get a machine based on the index /// - public Machine? GetMachineByIndex(long index) + public Machine? GetMachine(long index) { if (!_machines.ContainsKey(index)) return null; @@ -157,7 +157,7 @@ namespace SabreTools.DatFiles /// /// Get the machine associated with an item index /// - public Machine? GetMachineForItemByIndex(long itemIndex) + public Machine? GetMachineForItem(long itemIndex) { if (!_itemToMachineMapping.ContainsKey(itemIndex)) return null; @@ -169,10 +169,30 @@ namespace SabreTools.DatFiles return _machines[machineIndex]; } + /// + /// Get the items associated with a bucket name + /// + public DatItem[]? GetDatItemsForBucket(string bucketName) + { + if (!_buckets.ContainsKey(bucketName)) + return null; + + var itemIds = _buckets[bucketName]; + + var datItems = new List(); + foreach (long itemId in itemIds) + { + if (_items.ContainsKey(itemId)) + datItems.Add(_items[itemId]); + } + + return [.. datItems]; + } + /// /// Get the items associated with a machine index /// - public DatItem[]? GetDatItemsForMachineByIndex(long machineIndex) + public DatItem[]? GetDatItemsForMachine(long machineIndex) { var itemIds = _itemToMachineMapping .Where(mapping => mapping.Value == machineIndex) @@ -185,7 +205,7 @@ namespace SabreTools.DatFiles datItems.Add(_items[itemId]); } - return datItems.ToArray(); + return [.. datItems]; } ///