(99fb00391) Don't allow deconstructing items that don't give anything when deconstructed. Closes #690

This commit is contained in:
Joonas Rikkonen
2019-04-18 12:03:22 +03:00
parent fdacc4534b
commit c85cf63494
2 changed files with 12 additions and 7 deletions

View File

@@ -71,8 +71,10 @@ namespace Barotrauma.Items.Components
var targetItem = inputContainer.Inventory.Items.LastOrDefault(i => i != null);
if (targetItem == null) { return; }
progressState = Math.Min(progressTimer / targetItem.Prefab.DeconstructTime, 1.0f);
if (progressTimer > targetItem.Prefab.DeconstructTime)
float deconstructTime = targetItem.Prefab.DeconstructItems.Any() ? targetItem.Prefab.DeconstructTime : 1.0f;
progressState = Math.Min(progressTimer / deconstructTime, 1.0f);
if (progressTimer > deconstructTime)
{
foreach (DeconstructItem deconstructProduct in targetItem.Prefab.DeconstructItems)
{
@@ -100,10 +102,13 @@ namespace Barotrauma.Items.Components
}
}
inputContainer.Inventory.RemoveItem(targetItem);
Entity.Spawner.AddToRemoveQueue(targetItem);
MoveInputQueue();
PutItemsToLinkedContainer();
if (targetItem.Prefab.DeconstructItems.Any())
{
inputContainer.Inventory.RemoveItem(targetItem);
Entity.Spawner.AddToRemoveQueue(targetItem);
MoveInputQueue();
PutItemsToLinkedContainer();
}
if (inputContainer.Inventory.Items.Any(i => i != null))
{

View File

@@ -566,7 +566,7 @@ namespace Barotrauma
break;
#endif
case "deconstruct":
DeconstructTime = subElement.GetAttributeFloat("time", 10.0f);
DeconstructTime = subElement.GetAttributeFloat("time", 1.0f);
foreach (XElement deconstructItem in subElement.Elements())
{