Fixed fabricated items always appearing to be in full condition client-side (e.g. oxygen tanks which should be empty after being fabricated). Cherry-picked from 64896b0f. Closes #561

This commit is contained in:
Joonas Rikkonen
2018-06-29 17:39:10 +03:00
parent 7f58e4619b
commit 274a29bada
3 changed files with 12 additions and 15 deletions
@@ -22,13 +22,13 @@ namespace Barotrauma
public readonly Vector2 Position;
public readonly Inventory Inventory;
public readonly Submarine Submarine;
public readonly float Condition;
public readonly float Condition;
public ItemSpawnInfo(ItemPrefab prefab, Vector2 worldPosition, float? condition = null)
{
Prefab = prefab;
Position = worldPosition;
Condition = (float)(condition ?? prefab.Health);
Condition = condition ?? prefab.Health;
}
public ItemSpawnInfo(ItemPrefab prefab, Vector2 position, Submarine sub, float? condition = null)
@@ -36,14 +36,14 @@ namespace Barotrauma
Prefab = prefab;
Position = position;
Submarine = sub;
Condition = (float)(condition ?? prefab.Health);
Condition = condition ?? prefab.Health;
}
public ItemSpawnInfo(ItemPrefab prefab, Inventory inventory, float? condition = null)
{
Prefab = prefab;
Inventory = inventory;
Condition = (float)(condition ?? prefab.Health);
Condition = condition ?? prefab.Health;
}
public Entity Spawn()
@@ -52,13 +52,14 @@ namespace Barotrauma
if (Inventory != null)
{
spawnedItem = new Item(Prefab, Vector2.Zero, null, Condition);
spawnedItem = new Item(Prefab, Vector2.Zero, null);
Inventory.TryPutItem(spawnedItem, null, spawnedItem.AllowedSlots);
}
else
{
spawnedItem = new Item(Prefab, Position, Submarine, Condition);
spawnedItem = new Item(Prefab, Position, Submarine);
}
spawnedItem.Condition = Condition;
return spawnedItem;
}