From c28fd336c9bdbe3790c1e529f385a8a5afcffe33 Mon Sep 17 00:00:00 2001 From: ursinewalrus Date: Mon, 23 Jul 2018 21:32:01 -0500 Subject: [PATCH] If you buy more than a full box worth of stuff at the store instead of not letting you start the mission it will put the extra stuff in extra boxes for you --- .../Source/GameSession/CargoManager.cs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/Barotrauma/BarotraumaShared/Source/GameSession/CargoManager.cs b/Barotrauma/BarotraumaShared/Source/GameSession/CargoManager.cs index 941d21b7a..31aa45682 100644 --- a/Barotrauma/BarotraumaShared/Source/GameSession/CargoManager.cs +++ b/Barotrauma/BarotraumaShared/Source/GameSession/CargoManager.cs @@ -110,6 +110,7 @@ namespace Barotrauma } Dictionary availableContainers = new Dictionary(); + ItemPrefab containerPrefab = null; foreach (PurchasedItem Pi in itemsToSpawn) { Vector2 position = new Vector2( @@ -125,7 +126,7 @@ namespace Barotrauma if (itemContainer == null) { - var containerPrefab = MapEntityPrefab.List.Find(ep => + containerPrefab = MapEntityPrefab.List.Find(ep => ep.NameMatches(Pi.itemPrefab.CargoContainerName) || (ep.Tags != null && ep.Tags.Contains(Pi.itemPrefab.CargoContainerName.ToLowerInvariant()))) as ItemPrefab; @@ -151,6 +152,13 @@ namespace Barotrauma } for (int i = 0; i < Pi.quantity; i++) { + if (!availableContainers.ContainsKey(itemContainer)) + { + Item containerItemOverFlow = new Item(containerPrefab, position, wp.Submarine); + itemContainer = containerItemOverFlow.GetComponent(); + availableContainers.Add(itemContainer, itemContainer.Capacity); + } + if (itemContainer == null) { //no container, place at the waypoint @@ -177,7 +185,8 @@ namespace Barotrauma } //reduce the number of available slots in the container - if (availableContainers.Count() > 0) + //if there is a container + if (availableContainers.ContainsKey(itemContainer)) { availableContainers[itemContainer]--; }