Conversion Node -> PathNode

This commit is contained in:
C9Glax 2023-02-05 20:45:12 +01:00
parent 89d57f5147
commit daa88e5d24

View File

@ -14,7 +14,7 @@ public class Pathfinder
try
{
startRegion = regionManager.GetRegion(start);
startNode = (PathNode)ClosestNodeToCoordinates(start, startRegion)!; //TODO null handling
startNode = PathNode.FromNode(ClosestNodeToCoordinates(start, startRegion)!); //TODO null handling
}
catch (FileNotFoundException e)
{
@ -23,7 +23,7 @@ public class Pathfinder
try
{
goalRegion = regionManager.GetRegion(goal);
goalNode = (PathNode)ClosestNodeToCoordinates(goal, goalRegion)!; //TODO null handling
goalNode = PathNode.FromNode(ClosestNodeToCoordinates(goal, goalRegion)!); //TODO null handling
}
catch (FileNotFoundException e)
{
@ -47,7 +47,7 @@ public class Pathfinder
foreach (Connection connection in closestNodeToGoal.GetConnections())
{
PathNode? neighbor = (PathNode?)regionManager.GetNode(connection.endNodeCoordinates);
PathNode? neighbor = (PathNode)regionManager.GetNode(connection.endNodeCoordinates);
if (neighbor != null && neighbor.currentPathWeight < closestNodeToGoal.currentPathWeight + Utils.DistanceBetween(closestNodeToGoal, neighbor))
{
neighbor.previousPathNode = closestNodeToGoal;