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:
@@ -291,7 +291,6 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
}
|
||||
|
||||
//TODO: apply OutCondition
|
||||
if (containers[1].Inventory.Items.All(i => i != null))
|
||||
{
|
||||
Entity.Spawner.AddToSpawnQueue(fabricatedItem.TargetItem, item.Position, item.Submarine, fabricatedItem.TargetItem.Health * fabricatedItem.OutCondition);
|
||||
|
||||
@@ -344,18 +344,18 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
public Item(ItemPrefab itemPrefab, Vector2 position, Submarine submarine, float? spawnCondition = null)
|
||||
public Item(ItemPrefab itemPrefab, Vector2 position, Submarine submarine)
|
||||
: this(new Rectangle(
|
||||
(int)(position.X - itemPrefab.sprite.size.X / 2),
|
||||
(int)(position.Y + itemPrefab.sprite.size.Y / 2),
|
||||
(int)itemPrefab.sprite.size.X,
|
||||
(int)itemPrefab.sprite.size.Y),
|
||||
itemPrefab, submarine, spawnCondition)
|
||||
itemPrefab, submarine)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public Item(Rectangle newRect, ItemPrefab itemPrefab, Submarine submarine, float? spawnCondition = null)
|
||||
public Item(Rectangle newRect, ItemPrefab itemPrefab, Submarine submarine)
|
||||
: base(itemPrefab, submarine)
|
||||
{
|
||||
prefab = itemPrefab;
|
||||
@@ -370,7 +370,7 @@ namespace Barotrauma
|
||||
|
||||
rect = newRect;
|
||||
|
||||
condition = (float)(spawnCondition ?? prefab.Health);
|
||||
condition = prefab.Health;
|
||||
lastSentCondition = condition;
|
||||
|
||||
XElement element = prefab.ConfigElement;
|
||||
@@ -425,11 +425,8 @@ namespace Barotrauma
|
||||
//and add them to the corresponding statuseffect list
|
||||
foreach (List<StatusEffect> componentEffectList in ic.statusEffectLists.Values)
|
||||
{
|
||||
|
||||
ActionType actionType = componentEffectList.First().type;
|
||||
|
||||
List<StatusEffect> statusEffectList;
|
||||
if (!statusEffectLists.TryGetValue(actionType, out statusEffectList))
|
||||
if (!statusEffectLists.TryGetValue(actionType, out List<StatusEffect> statusEffectList))
|
||||
{
|
||||
statusEffectList = new List<StatusEffect>();
|
||||
statusEffectLists.Add(actionType, statusEffectList);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user