From 66af3464a9e69fe77b79ba5f6660e927e446c228 Mon Sep 17 00:00:00 2001 From: Joonas Rikkonen Date: Wed, 27 Mar 2019 13:52:04 +0200 Subject: [PATCH] (4d472a71c) Removing an item after it's been combined doesn't trigger the OnBroken StatusEffects (e.g. combining two half-full flash powder jars doesn't cause them to explode), made all crafting materials disappear after they've been fully used. Closes #1303 --- .../Source/Items/Components/ItemComponent.cs | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/Barotrauma/BarotraumaShared/Source/Items/Components/ItemComponent.cs b/Barotrauma/BarotraumaShared/Source/Items/Components/ItemComponent.cs index 76a75d62e..28638ff15 100644 --- a/Barotrauma/BarotraumaShared/Source/Items/Components/ItemComponent.cs +++ b/Barotrauma/BarotraumaShared/Source/Items/Components/ItemComponent.cs @@ -392,13 +392,10 @@ namespace Barotrauma.Items.Components else transferAmount = -Math.Min(this.item.Condition, item.MaxCondition - item.Condition); - if (transferAmount == 0.0f) - return false; - this.Item.Condition += transferAmount; - item.Condition -= transferAmount; + if (transferAmount == 0.0f) { return false; } if (removeOnCombined) { - if (item.Condition <= 0.0f) + if (item.Condition - transferAmount <= 0.0f) { if (item.ParentInventory != null) { @@ -408,7 +405,11 @@ namespace Barotrauma.Items.Components } Entity.Spawner.AddToRemoveQueue(item); } - if (this.Item.Condition <= 0.0f) + else + { + item.Condition -= transferAmount; + } + if (this.Item.Condition + transferAmount <= 0.0f) { if (this.Item.ParentInventory != null) { @@ -418,6 +419,15 @@ namespace Barotrauma.Items.Components } Entity.Spawner.AddToRemoveQueue(this.Item); } + else + { + this.Item.Condition += transferAmount; + } + } + else + { + this.Item.Condition += transferAmount; + item.Condition -= transferAmount; } return true; }