From 4d19d0afc1c0fc0eff1f3a785cc0c2d400e23022 Mon Sep 17 00:00:00 2001 From: Regalis Date: Thu, 23 Mar 2017 18:55:39 +0200 Subject: [PATCH] Deconstructors & fabricators drop created items on the floor if there's no more room in the inventory, deconstructor doesn't reset the activation button after deconstructing an item if there are still more items to go --- .../Components/Machines/Deconstructor.cs | 30 ++++++++++++------- .../Items/Components/Machines/Fabricator.cs | 10 ++++++- 2 files changed, 29 insertions(+), 11 deletions(-) diff --git a/Subsurface/Source/Items/Components/Machines/Deconstructor.cs b/Subsurface/Source/Items/Components/Machines/Deconstructor.cs index 5f2b53114..ad0b7d421 100644 --- a/Subsurface/Source/Items/Components/Machines/Deconstructor.cs +++ b/Subsurface/Source/Items/Components/Machines/Deconstructor.cs @@ -30,12 +30,9 @@ namespace Barotrauma.Items.Components public override void Update(float deltaTime, Camera cam) { - if (container == null || !container.Inventory.Items.Any(i=>i!=null)) + if (container == null || container.Inventory.Items.All(i => i == null)) { - progressBar.BarSize = 0.0f; - //activateButton.Enabled = true; - if (container != null) container.Inventory.Locked = false; - IsActive = false; + SetActive(false); return; } @@ -68,15 +65,27 @@ namespace Barotrauma.Items.Components DebugConsole.ThrowError("Tried to deconstruct item \""+targetItem.Name+"\" but couldn't find item prefab \""+deconstructProduct+"\"!"); continue; } - Item.Spawner.QueueItem(itemPrefab, containers[1].Inventory); + + //container full, drop the items outside the deconstructor + if (containers[1].Inventory.Items.All(i => i != null)) + { + Item.Spawner.QueueItem(itemPrefab, item.Position, item.Submarine); + } + else + { + Item.Spawner.QueueItem(itemPrefab, containers[1].Inventory); + } + } container.Inventory.RemoveItem(targetItem); Item.Remover.QueueItem(targetItem); - activateButton.Text = "Deconstruct"; - progressBar.BarSize = 0.0f; - progressTimer = 0.0f; + if (container.Inventory.Items.Any(i => i != null)) + { + progressTimer = 0.0f; + progressBar.BarSize = 0.0f; + } } } @@ -115,6 +124,8 @@ namespace Barotrauma.Items.Components return; } + if (container.Inventory.Items.All(i => i == null)) active = false; + IsActive = active; if (!IsActive) @@ -126,7 +137,6 @@ namespace Barotrauma.Items.Components } else { - if (container.Inventory.Items.All(i => i == null)) return; activateButton.Text = "Cancel"; } diff --git a/Subsurface/Source/Items/Components/Machines/Fabricator.cs b/Subsurface/Source/Items/Components/Machines/Fabricator.cs index f594f22f6..813ce443c 100644 --- a/Subsurface/Source/Items/Components/Machines/Fabricator.cs +++ b/Subsurface/Source/Items/Components/Machines/Fabricator.cs @@ -375,7 +375,15 @@ namespace Barotrauma.Items.Components } } - Item.Spawner.QueueItem(fabricatedItem.TargetItem, containers[1].Inventory); + if (containers[1].Inventory.Items.All(i => i != null)) + { + Item.Spawner.QueueItem(fabricatedItem.TargetItem, item.Position, item.Submarine); + } + else + { + Item.Spawner.QueueItem(fabricatedItem.TargetItem, containers[1].Inventory); + } + CancelFabricating(); }