diff --git a/Libraries/Core/Generators/BotInventoryGenerator.cs b/Libraries/Core/Generators/BotInventoryGenerator.cs index cf5be899..58ac4554 100644 --- a/Libraries/Core/Generators/BotInventoryGenerator.cs +++ b/Libraries/Core/Generators/BotInventoryGenerator.cs @@ -482,6 +482,7 @@ public class BotInventoryGenerator( // Does item have slots for sub-mods to be inserted into if (pickedItemDb.Properties?.Slots?.Count > 0 + && settings?.GenerateModsBlacklist is not null && settings.GenerateModsBlacklist.Contains(pickedItemDb.Id)) { var childItemsToAdd = _botEquipmentModGenerator.GenerateModsForEquipment( diff --git a/Libraries/Core/Helpers/BotGeneratorHelper.cs b/Libraries/Core/Helpers/BotGeneratorHelper.cs index 3d4adb69..6b6c6550 100644 --- a/Libraries/Core/Helpers/BotGeneratorHelper.cs +++ b/Libraries/Core/Helpers/BotGeneratorHelper.cs @@ -535,17 +535,30 @@ public class BotGeneratorHelper( // Get root items in container we can iterate over to find out what space is free var containerItemsToCheck = existingContainerItems.Where(x => x.SlotId == slotGrid.Name); + var itemsToRemove = new List(); + var itemsToAdd = new List(); foreach (var item in containerItemsToCheck) { - // Look for children on items, insert into array if found + // Check item in contain for children, store for later insertion into `containerItemsToCheck` // (used later when figuring out how much space weapon takes up) - var itemWithChildrens = _itemHelper.FindAndReturnChildrenAsItems(inventory.Items, item.Id); - if (itemWithChildrens.Count <= 1) continue; + var itemWithChildItems = _itemHelper.FindAndReturnChildrenAsItems(inventory.Items, item.Id); + if (itemWithChildItems.Count <= 1) continue; - existingContainerItems.Remove(item); - existingContainerItems.AddRange(itemWithChildrens); + + // Store replaced item + new Child items to add later as we can't modify a collecting while looking over it + itemsToRemove.Add(item); + itemsToAdd.AddRange(itemsToAdd); } + // Remove the base items flagged above + foreach (var item in itemsToRemove) + { + existingContainerItems.Remove(item); + } + + // Add item back with its child items + existingContainerItems.AddRange(itemsToAdd); + // Get rid of items free/used spots in current grid if (slotGrid.Props is not null) { @@ -594,7 +607,7 @@ public class BotGeneratorHelper( // No space in this grid, move to next container grid and try again } - // if we got to this point, the item couldnt be placed on the container + // if we got to this point, the item couldn't be placed on the container if (containersIdFull is null) continue; // if the item was a one by one, we know it must be full. Or if the maps cant find a slot for a one by one diff --git a/Libraries/Core/Helpers/ContainerHelper.cs b/Libraries/Core/Helpers/ContainerHelper.cs index 04050f83..af2c50b0 100644 --- a/Libraries/Core/Helpers/ContainerHelper.cs +++ b/Libraries/Core/Helpers/ContainerHelper.cs @@ -88,7 +88,39 @@ public class ContainerHelper int itemW, int itemH) { - throw new NotImplementedException(); + var foundSlot = true; + + for (var itemY = 0; itemY < itemH; itemY++) + { + if (foundSlot && y + itemH - 1 > containerY - 1) + { + foundSlot = false; + break; + } + + // Does item fit x-ways across + for (var itemX = 0; itemX < itemW; itemX++) + { + if (foundSlot && x + itemW - 1 > containerX - 1) + { + foundSlot = false; + break; + } + + if (container2D[y + itemY][x + itemX] != 0) + { + foundSlot = false; + break; + } + } + + if (!foundSlot) + { + break; + } + } + + return foundSlot; } /// diff --git a/Libraries/Core/Helpers/InventoryHelper.cs b/Libraries/Core/Helpers/InventoryHelper.cs index 1ce5272e..dc90af7d 100644 --- a/Libraries/Core/Helpers/InventoryHelper.cs +++ b/Libraries/Core/Helpers/InventoryHelper.cs @@ -413,7 +413,8 @@ public class InventoryHelper( protected bool IsVertical(ItemLocation itemLocation) { - throw new NotImplementedException(); + var castValue = itemLocation.R.ToString(); + return castValue == "1" || castValue == "Vertical" || itemLocation.Rotation?.ToString() == "Vertical"; } protected InventoryItemHash GetInventoryItemHash(List inventoryItems)