All remaining physics bodies are removed at the end of submarine unloading (freeing debug bodyShapeTextures, etc). -> LevelTrigger bodies don't have to be removed separately during unloading

This commit is contained in:
Joonas Rikkonen
2017-08-24 20:30:10 +03:00
parent 65094a02c1
commit 1a12f46708
3 changed files with 17 additions and 4 deletions
@@ -1153,8 +1153,8 @@ namespace Barotrauma
} }
Item.ItemList.Clear(); Item.ItemList.Clear();
} }
PhysicsBody.list.Clear(); PhysicsBody.RemoveAll();
Ragdoll.list.Clear(); Ragdoll.list.Clear();
@@ -65,7 +65,11 @@ namespace Barotrauma
Circle, Rectangle, Capsule Circle, Rectangle, Capsule
}; };
public static List<PhysicsBody> list = new List<PhysicsBody>(); private static List<PhysicsBody> list = new List<PhysicsBody>();
public static List<PhysicsBody> List
{
get { return list; }
}
//the farseer physics body of the item //the farseer physics body of the item
private Body body; private Body body;
@@ -534,6 +538,15 @@ namespace Barotrauma
DisposeProjSpecific(); DisposeProjSpecific();
} }
public static void RemoveAll()
{
for (int i = list.Count - 1; i >= 0; i--)
{
list[i].Remove();
}
System.Diagnostics.Debug.Assert(list.Count == 0);
}
partial void DisposeProjSpecific(); partial void DisposeProjSpecific();
} }
} }
@@ -113,7 +113,7 @@ namespace Barotrauma
sub.SetPrevTransform(sub.Position); sub.SetPrevTransform(sub.Position);
} }
foreach (PhysicsBody pb in PhysicsBody.list) foreach (PhysicsBody pb in PhysicsBody.List)
{ {
pb.SetPrevTransform(pb.SimPosition, pb.Rotation); pb.SetPrevTransform(pb.SimPosition, pb.Rotation);
} }