Merge branch 'master' into new-netcode

Conflicts:
	Subsurface/Source/Items/Components/Machines/Deconstructor.cs
	Subsurface/Source/Items/Components/Machines/Fabricator.cs
This commit is contained in:
Regalis
2017-03-23 18:58:18 +02:00
9 changed files with 156 additions and 89 deletions
@@ -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;
}
@@ -51,10 +48,10 @@ namespace Barotrauma.Items.Components
if (progressTimer>targetItem.Prefab.DeconstructTime)
{
var containers = item.GetComponents<ItemContainer>();
if (containers.Count<2)
if (containers.Count < 2)
{
DebugConsole.ThrowError("Error in Deconstructor.Update: Deconstructors must have two ItemContainer components!");
return;
}
@@ -62,21 +59,32 @@ namespace Barotrauma.Items.Components
{
if (deconstructProduct.RequireFullCondition && targetItem.Condition < 100.0f) continue;
var itemPrefab = ItemPrefab.list.FirstOrDefault(ip => ip.Name.ToLowerInvariant() == deconstructProduct.ItemPrefabName.ToLowerInvariant()) as ItemPrefab;
if (itemPrefab==null)
var itemPrefab = MapEntityPrefab.list.FirstOrDefault(ip => ip.Name.ToLowerInvariant() == deconstructProduct.ItemPrefabName.ToLowerInvariant()) as ItemPrefab;
if (itemPrefab == null)
{
DebugConsole.ThrowError("Tried to deconstruct item \""+targetItem.Name+"\" but couldn't find item prefab \""+deconstructProduct+"\"!");
DebugConsole.ThrowError("Tried to deconstruct item \"" + targetItem.Name + "\" but couldn't find item prefab \"" + deconstructProduct + "\"!");
continue;
}
Item.Spawner.AddToSpawnQueue(itemPrefab, containers[1].Inventory);
//container full, drop the items outside the deconstructor
if (containers[1].Inventory.Items.All(i => i != null))
{
Entity.Spawner.AddToSpawnQueue(itemPrefab, item.Position, item.Submarine);
}
else
{
Entity.Spawner.AddToSpawnQueue(itemPrefab, containers[1].Inventory);
}
}
container.Inventory.RemoveItem(targetItem);
Item.Spawner.AddToRemoveQueue(targetItem);
Entity.Spawner.AddToRemoveQueue(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;
}
}
}
@@ -122,6 +130,8 @@ namespace Barotrauma.Items.Components
return;
}
if (container.Inventory.Items.All(i => i == null)) active = false;
IsActive = active;
if (!IsActive)
@@ -133,7 +143,6 @@ namespace Barotrauma.Items.Components
}
else
{
if (container.Inventory.Items.All(i => i == null)) return;
activateButton.Text = "Cancel";
}