AI reachable improvements (#1595)

Deleted regions in some instances were being retained indefinitely.

Co-authored-by: Metal Gear Sloth <metalgearsloth@gmail.com>
This commit is contained in:
metalgearsloth
2020-08-06 00:19:00 +10:00
committed by GitHub
parent c5d3bff266
commit 140f8f7647
2 changed files with 38 additions and 10 deletions

View File

@@ -34,7 +34,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding.Accessible
public bool IsDoor { get; }
public HashSet<PathfindingNode> Nodes => _nodes;
private HashSet<PathfindingNode> _nodes;
private readonly HashSet<PathfindingNode> _nodes;
public bool Deleted { get; private set; }
@@ -55,6 +55,9 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding.Accessible
var neighbor = neighbors[i];
neighbor.Neighbors.Remove(this);
}
_nodes.Clear();
Neighbors.Clear();
Deleted = true;
}
@@ -127,7 +130,10 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding.Accessible
{
if (other == null) return false;
if (ReferenceEquals(this, other)) return true;
return GetHashCode() == other.GetHashCode();
if (_nodes.Count != other.Nodes.Count) return false;
if (Deleted != other.Deleted) return false;
if (OriginNode != other.OriginNode) return false;
return true;
}
public override int GetHashCode()