Hulls, gaps, structures & waypoints implement ShallowRemove (= a method that's used to remove entities without severing links between them when copypasting).

Copied waypoints used to stay in the waypoint list, causing an exception to be thrown in PathFinder.GenerateNodes due to duplicate IDs.
This commit is contained in:
Regalis
2017-05-29 19:49:58 +03:00
parent 9281795866
commit 7910b13120
5 changed files with 87 additions and 7 deletions
+28 -1
View File
@@ -452,7 +452,34 @@ namespace Barotrauma
}
}
}
public override void ShallowRemove()
{
base.ShallowRemove();
if (WallList.Contains(this)) WallList.Remove(this);
if (bodies != null)
{
foreach (Body b in bodies)
GameMain.World.RemoveBody(b);
}
if (sections != null)
{
foreach (WallSection s in sections)
{
if (s.gap != null)
{
s.gap.Remove();
s.gap = null;
}
}
}
if (convexHulls != null) convexHulls.ForEach(x => x.Remove());
}
public override void Remove()
{
base.Remove();