private void AddNeighbours(NodeMeta nodeMeta)
        {
            foreach (var pathfindingNode in nodeMeta.Node.GetNeighbours())
            {
                var neighbour = (T)pathfindingNode;

                NodeMeta neighNodeMeta = GetFillData(neighbour);
                if (!frontier.Contains(neighNodeMeta) && traverser.CanTraverse(neighNodeMeta.Node))
                {
                    neighNodeMeta.GCost = nodeMeta.GCost + traverser.GetTraverseCost(nodeMeta.Node, neighNodeMeta.Node);
                    frontier.Add(neighNodeMeta);
                }
            }
        }
Exemple #2
0
        private void AddToOpen(T node)
        {
            NodeMeta target = GetNodeMeta(node);

            if (traverser.CanTraverse(node) || node == endNode)
            {
                float gCost = current.GCost + traverser.GetTraverseCost(current.Node, node);
                if (!closedList.Contains(target) && !openList.Contains(target))
                {
                    target.Parent = current.Node;
                    target.HCost  = Vector3.Distance(node.Position, endNode.Position);
                    target.GCost  = gCost;
                    openList.Add(target);
                }
                else if (target.GCost > gCost)
                {
                    target.Parent = current.Node;
                    target.GCost  = gCost;
                }
            }
        }