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

This commit is contained in:
ursinewalrus
2018-07-23 21:32:01 -05:00
parent 4e3d375ae5
commit c28fd336c9
@@ -110,6 +110,7 @@ namespace Barotrauma
} }
Dictionary<ItemContainer, int> availableContainers = new Dictionary<ItemContainer, int>(); Dictionary<ItemContainer, int> availableContainers = new Dictionary<ItemContainer, int>();
ItemPrefab containerPrefab = null;
foreach (PurchasedItem Pi in itemsToSpawn) foreach (PurchasedItem Pi in itemsToSpawn)
{ {
Vector2 position = new Vector2( Vector2 position = new Vector2(
@@ -125,7 +126,7 @@ namespace Barotrauma
if (itemContainer == null) if (itemContainer == null)
{ {
var containerPrefab = MapEntityPrefab.List.Find(ep => containerPrefab = MapEntityPrefab.List.Find(ep =>
ep.NameMatches(Pi.itemPrefab.CargoContainerName) || ep.NameMatches(Pi.itemPrefab.CargoContainerName) ||
(ep.Tags != null && ep.Tags.Contains(Pi.itemPrefab.CargoContainerName.ToLowerInvariant()))) as ItemPrefab; (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++) for (int i = 0; i < Pi.quantity; i++)
{ {
if (!availableContainers.ContainsKey(itemContainer))
{
Item containerItemOverFlow = new Item(containerPrefab, position, wp.Submarine);
itemContainer = containerItemOverFlow.GetComponent<ItemContainer>();
availableContainers.Add(itemContainer, itemContainer.Capacity);
}
if (itemContainer == null) if (itemContainer == null)
{ {
//no container, place at the waypoint //no container, place at the waypoint
@@ -177,7 +185,8 @@ namespace Barotrauma
} }
//reduce the number of available slots in the container //reduce the number of available slots in the container
if (availableContainers.Count() > 0) //if there is a container
if (availableContainers.ContainsKey(itemContainer))
{ {
availableContainers[itemContainer]--; availableContainers[itemContainer]--;
} }