From 9bfd0517254d84365b8d8cb076c7d898b721a509 Mon Sep 17 00:00:00 2001 From: CWX Date: Sat, 3 May 2025 13:06:46 +0100 Subject: [PATCH] dont calculate size twice --- .../Generators/LocationLootGenerator.cs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/Libraries/SPTarkov.Server.Core/Generators/LocationLootGenerator.cs b/Libraries/SPTarkov.Server.Core/Generators/LocationLootGenerator.cs index 5c158679..8c81e167 100644 --- a/Libraries/SPTarkov.Server.Core/Generators/LocationLootGenerator.cs +++ b/Libraries/SPTarkov.Server.Core/Generators/LocationLootGenerator.cs @@ -463,16 +463,18 @@ public class LocationLootGenerator( continue; } + if (tplToAdd == "5bf3e0490db83400196199af") + { + Console.WriteLine("yo"); + } + // Check if item should have children removed var items = _locationConfig.TplsToStripChildItemsFrom.Contains(tplToAdd) ? [chosenItemWithChildren.Items[0]] // Strip children from parent : chosenItemWithChildren.Items; - var itemSize = _itemHelper.GetItemSize(items, items[0].Id); - var itemWidth = itemSize.Width; - var itemHeight = itemSize.Height; // look for open slot to put chosen item into - var result = _containerHelper.FindSlotForItem(containerMap, itemWidth, itemHeight); + var result = _containerHelper.FindSlotForItem(containerMap, chosenItemWithChildren.Width, chosenItemWithChildren.Height); if (!result.Success.GetValueOrDefault(false)) { if (failedToFitAttemptCount > _locationConfig.FitLootIntoContainerAttempts) @@ -492,8 +494,8 @@ public class LocationLootGenerator( containerMap, result.X.Value, result.Y.Value, - itemWidth, - itemHeight, + chosenItemWithChildren.Width, + chosenItemWithChildren.Height, result.Rotation.GetValueOrDefault(false) ); @@ -1316,14 +1318,14 @@ public class ContainerItem } [JsonPropertyName("width")] - public double? Width + public int? Width { get; set; } [JsonPropertyName("height")] - public double? Height + public int? Height { get; set;