(99fb00391) Don't allow deconstructing items that don't give anything when deconstructed. Closes #690
This commit is contained in:
@@ -71,8 +71,10 @@ namespace Barotrauma.Items.Components
|
|||||||
var targetItem = inputContainer.Inventory.Items.LastOrDefault(i => i != null);
|
var targetItem = inputContainer.Inventory.Items.LastOrDefault(i => i != null);
|
||||||
if (targetItem == null) { return; }
|
if (targetItem == null) { return; }
|
||||||
|
|
||||||
progressState = Math.Min(progressTimer / targetItem.Prefab.DeconstructTime, 1.0f);
|
float deconstructTime = targetItem.Prefab.DeconstructItems.Any() ? targetItem.Prefab.DeconstructTime : 1.0f;
|
||||||
if (progressTimer > targetItem.Prefab.DeconstructTime)
|
|
||||||
|
progressState = Math.Min(progressTimer / deconstructTime, 1.0f);
|
||||||
|
if (progressTimer > deconstructTime)
|
||||||
{
|
{
|
||||||
foreach (DeconstructItem deconstructProduct in targetItem.Prefab.DeconstructItems)
|
foreach (DeconstructItem deconstructProduct in targetItem.Prefab.DeconstructItems)
|
||||||
{
|
{
|
||||||
@@ -100,10 +102,13 @@ namespace Barotrauma.Items.Components
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inputContainer.Inventory.RemoveItem(targetItem);
|
if (targetItem.Prefab.DeconstructItems.Any())
|
||||||
Entity.Spawner.AddToRemoveQueue(targetItem);
|
{
|
||||||
MoveInputQueue();
|
inputContainer.Inventory.RemoveItem(targetItem);
|
||||||
PutItemsToLinkedContainer();
|
Entity.Spawner.AddToRemoveQueue(targetItem);
|
||||||
|
MoveInputQueue();
|
||||||
|
PutItemsToLinkedContainer();
|
||||||
|
}
|
||||||
|
|
||||||
if (inputContainer.Inventory.Items.Any(i => i != null))
|
if (inputContainer.Inventory.Items.Any(i => i != null))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -566,7 +566,7 @@ namespace Barotrauma
|
|||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
case "deconstruct":
|
case "deconstruct":
|
||||||
DeconstructTime = subElement.GetAttributeFloat("time", 10.0f);
|
DeconstructTime = subElement.GetAttributeFloat("time", 1.0f);
|
||||||
|
|
||||||
foreach (XElement deconstructItem in subElement.Elements())
|
foreach (XElement deconstructItem in subElement.Elements())
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user