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:
@@ -50,7 +50,14 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
|
|
||||||
Items[slotIndex].ApplyStatusEffects(ActionType.OnUse, 1.0f, character);
|
Items[slotIndex].ApplyStatusEffects(ActionType.OnUse, 1.0f, character);
|
||||||
|
foreach (ItemComponent ic in Items[slotIndex].components)
|
||||||
|
{
|
||||||
|
if (ic.DeleteOnUse)
|
||||||
|
{
|
||||||
|
Entity.Spawner.AddToRemoveQueue(Items[slotIndex]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -288,6 +288,11 @@ namespace Barotrauma.Items.Components
|
|||||||
if (targetCharacter != null) //TODO: Allow OnUse to happen on structures too maybe??
|
if (targetCharacter != null) //TODO: Allow OnUse to happen on structures too maybe??
|
||||||
ApplyStatusEffects(ActionType.OnUse, 1.0f, targetCharacter != null ? targetCharacter : null);
|
ApplyStatusEffects(ActionType.OnUse, 1.0f, targetCharacter != null ? targetCharacter : null);
|
||||||
|
|
||||||
|
if (DeleteOnUse)
|
||||||
|
{
|
||||||
|
Entity.Spawner.AddToRemoveQueue(item);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1166,7 +1166,10 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (remove) Remove();
|
if (remove)
|
||||||
|
{
|
||||||
|
Spawner.AddToRemoveQueue(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SecondaryUse(float deltaTime, Character character = null)
|
public void SecondaryUse(float deltaTime, Character character = null)
|
||||||
@@ -1845,7 +1848,16 @@ namespace Barotrauma
|
|||||||
public override void Remove()
|
public override void Remove()
|
||||||
{
|
{
|
||||||
base.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)
|
if (parentInventory != null)
|
||||||
{
|
{
|
||||||
parentInventory.RemoveItem(this);
|
parentInventory.RemoveItem(this);
|
||||||
|
|||||||
Reference in New Issue
Block a user