Items removed due to the "DeleteOnUse" property are removed using EntitySpawner, removing an item removes it from the selected items of all characters. Closes #306

This commit is contained in:
Joonas Rikkonen
2018-03-05 12:13:52 +02:00
parent f72b4c697f
commit 4e048b7895
3 changed files with 27 additions and 3 deletions
@@ -1166,7 +1166,10 @@ namespace Barotrauma
}
}
if (remove) Remove();
if (remove)
{
Spawner.AddToRemoveQueue(this);
}
}
public void SecondaryUse(float deltaTime, Character character = null)
@@ -1845,7 +1848,16 @@ namespace Barotrauma
public override void Remove()
{
base.Remove();
foreach (Character character in Character.CharacterList)
{
if (character.SelectedConstruction == this) character.SelectedConstruction = null;
for (int i = 0; i < character.SelectedItems.Length; i++)
{
if (character.SelectedItems[i] == this) character.SelectedItems[i] = null;
}
}
if (parentInventory != null)
{
parentInventory.RemoveItem(this);