Items are removed from their parent inventory and their bodies are removed when Item.Remove is called

This commit is contained in:
Regalis
2016-10-12 21:07:19 +03:00
parent 060a1db431
commit 1cdb218fe0
2 changed files with 18 additions and 4 deletions

View File

@@ -378,7 +378,12 @@ namespace Barotrauma.Items.Components
{
base.RemoveComponentSpecific();
GameMain.World.RemoveBody(body.FarseerBody);
if (body != null)
{
body.Remove();
body = null;
}
if (linkedGap!=null) linkedGap.Remove();

View File

@@ -1894,8 +1894,11 @@ namespace Barotrauma
Removed = true;
//sprite.Remove();
//if (body != null) body.Remove();
if (parentInventory != null)
{
parentInventory.RemoveItem(this);
parentInventory = null;
}
foreach (ItemComponent ic in components)
{
@@ -1903,13 +1906,19 @@ namespace Barotrauma
}
ItemList.Remove(this);
if (body != null)
{
body.Remove();
body = null;
}
foreach (Item it in ItemList)
{
if (it.linkedTo.Contains(this))
{
it.linkedTo.Remove(this);
}
}
}
}
}