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