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:
@@ -45,6 +45,12 @@ namespace Barotrauma
|
||||
var nodes = new Dictionary<int, PathNode>();
|
||||
foreach (WayPoint wayPoint in wayPoints)
|
||||
{
|
||||
if (wayPoint == null) continue;
|
||||
if (nodes.ContainsKey(wayPoint.ID))
|
||||
{
|
||||
DebugConsole.ThrowError("Error in PathFinder.GenerateNodes (duplicate ID \"" + wayPoint.ID + "\")");
|
||||
continue;
|
||||
}
|
||||
nodes.Add(wayPoint.ID, new PathNode(wayPoint));
|
||||
}
|
||||
|
||||
|
||||
@@ -670,19 +670,27 @@ namespace Barotrauma
|
||||
return null;
|
||||
}
|
||||
|
||||
public override void Remove()
|
||||
public override void ShallowRemove()
|
||||
{
|
||||
base.Remove();
|
||||
|
||||
base.ShallowRemove();
|
||||
GapList.Remove(this);
|
||||
|
||||
foreach (Hull hull in Hull.hullList)
|
||||
{
|
||||
hull.ConnectedGaps.Remove(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public override void Remove()
|
||||
{
|
||||
base.Remove();
|
||||
GapList.Remove(this);
|
||||
|
||||
foreach (Hull hull in Hull.hullList)
|
||||
{
|
||||
hull.ConnectedGaps.Remove(this);
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnMapLoaded()
|
||||
{
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -820,6 +820,13 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
public override void ShallowRemove()
|
||||
{
|
||||
base.ShallowRemove();
|
||||
|
||||
WayPointList.Remove(this);
|
||||
}
|
||||
|
||||
public override void Remove()
|
||||
{
|
||||
base.Remove();
|
||||
|
||||
Reference in New Issue
Block a user