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
+6 -1
View File
@@ -378,7 +378,12 @@ namespace Barotrauma.Items.Components
{ {
base.RemoveComponentSpecific(); base.RemoveComponentSpecific();
GameMain.World.RemoveBody(body.FarseerBody); if (body != null)
{
body.Remove();
body = null;
}
if (linkedGap!=null) linkedGap.Remove(); if (linkedGap!=null) linkedGap.Remove();
+12 -3
View File
@@ -1894,8 +1894,11 @@ namespace Barotrauma
Removed = true; Removed = true;
//sprite.Remove(); if (parentInventory != null)
//if (body != null) body.Remove(); {
parentInventory.RemoveItem(this);
parentInventory = null;
}
foreach (ItemComponent ic in components) foreach (ItemComponent ic in components)
{ {
@@ -1903,13 +1906,19 @@ namespace Barotrauma
} }
ItemList.Remove(this); ItemList.Remove(this);
if (body != null)
{
body.Remove();
body = null;
}
foreach (Item it in ItemList) foreach (Item it in ItemList)
{ {
if (it.linkedTo.Contains(this)) if (it.linkedTo.Contains(this))
{ {
it.linkedTo.Remove(this); it.linkedTo.Remove(this);
} }
} }
} }
} }