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
+34 -2
View File
@@ -332,6 +332,39 @@ namespace Barotrauma
Pressure = surface;
}
public override void ShallowRemove()
{
base.Remove();
hullList.Remove(this);
if (Submarine == null || (!Submarine.Loading && !Submarine.Unloading))
{
Item.UpdateHulls();
Gap.UpdateHulls();
}
List<FireSource> fireSourcesToRemove = new List<FireSource>(fireSources);
foreach (FireSource fireSource in fireSourcesToRemove)
{
fireSource.Remove();
}
fireSources.Clear();
if (soundIndex > -1)
{
Sounds.SoundManager.Stop(soundIndex);
soundIndex = -1;
}
if (entityGrids != null)
{
foreach (EntityGrid entityGrid in entityGrids)
{
entityGrid.RemoveEntity(this);
}
}
}
public override void Remove()
{
base.Remove();
@@ -355,8 +388,7 @@ namespace Barotrauma
Sounds.SoundManager.Stop(soundIndex);
soundIndex = -1;
}
//renderer.Dispose();
if (entityGrids != null)
{
foreach (EntityGrid entityGrid in entityGrids)