示例#1
0
        public static void GetPathsOfType(PathNodeList pathNodeList, List <Node> nodes, PathType typeA, PathType typeB)
        {
            if (typeA == PathType.Unk01)
            {
                foreach (Node node in nodes)
                {
                    foreach (Node edge in node.Edges)
                    {
                        PathNodeItem pathNodeItem = new PathNodeItem(node, edge, typeA);

                        foreach (PortalInfoItem portalInfoItem in node.Portals)
                        {
                            if (portalInfoItem.destRoomIdx == edge.index)
                            {
                                PathNodeChildItem pathNodeChildItem = new PathNodeChildItem(new PathNodeItem(node, node, typeB), portalInfoItem);
                                pathNodeItem.Items.Add(pathNodeChildItem);
                            }
                        }

                        pathNodeList.Items.Add(pathNodeItem);
                    }
                }
            }
            else
            {
                List <Pair> pairs = Pair.GetPairs(nodes);

                foreach (Pair pair in pairs)
                {
                    GetRoutes(pathNodeList, pair.limboPair, pair.nodeA, pair.nodeB, typeA, typeB);
                    GetRoutes(pathNodeList, pair.limboPair, pair.nodeB, pair.nodeA, typeA, typeB);
                }
            }
        }
示例#2
0
        public static void GetRoutes(PathNodeList pathNodeList, bool limboPair, Node nodeA, Node nodeB, PathType typeA, PathType typeB)
        {
            IEnumerable <Node> edges = (limboPair) ? nodeA.Edges : nodeA.Edges.Where(i => i.name != "limbo");

            foreach (PathNodeItem pathNode in pathNodeList.Items.Where(i => i.pathType == typeB).ToList())
            {
                switch (typeA)
                {
                case PathType.Unk01:
                case PathType.Unk02:
                case PathType.Unk03:

                    if (pathNode.nodeA == nodeA && pathNode.nodeB == nodeB)
                    {
                        (bool found, PathNodeItem existingPath) = FindPathNodeInList(pathNodeList, nodeA, nodeB, typeA);

                        if (found)
                        {
                            PathNodeItem pathNodeItem = existingPath;

                            foreach (PortalInfoItem portalInfoItem in nodeA.Portals)
                            {
                                if (portalInfoItem.destRoomIdx == nodeB.index)
                                {
                                    PathNodeChildItem pathNodeChildItem = new PathNodeChildItem(new PathNodeItem(nodeA, nodeA, typeB), portalInfoItem);
                                    pathNodeItem.Items.Add(pathNodeChildItem);
                                }
                            }
                        }
                        else
                        {
                            PathNodeItem pathNodeItem = new PathNodeItem(nodeA, nodeB, typeA);

                            foreach (PortalInfoItem portalInfoItem in nodeA.Portals)
                            {
                                if (portalInfoItem.destRoomIdx == nodeB.index)
                                {
                                    PathNodeChildItem pathNodeChildItem = new PathNodeChildItem(new PathNodeItem(nodeA, nodeA, typeB), portalInfoItem);
                                    pathNodeItem.Items.Add(pathNodeChildItem);
                                }
                            }
                            pathNodeList.Items.Add(pathNodeItem);
                        }
                    }
                    else
                    {
                        foreach (Node edge in edges)
                        {
                            if (pathNode.nodeA == edge && pathNode.nodeB == nodeB)
                            {
                                (bool found, PathNodeItem existingPath) = FindPathNodeInList(pathNodeList, nodeA, nodeB, typeA);

                                if (found)
                                {
                                    PathNodeItem pathNodeItem = existingPath;

                                    foreach (PortalInfoItem portalInfoItem in nodeA.Portals)
                                    {
                                        if (portalInfoItem.destRoomIdx == edge.index)
                                        {
                                            PathNodeChildItem pathNodeChildItem = new PathNodeChildItem(new PathNodeItem(edge, nodeB, typeB), portalInfoItem);
                                            pathNodeItem.Items.Add(pathNodeChildItem);
                                        }
                                    }
                                }
                                else
                                {
                                    PathNodeItem pathNodeItem = new PathNodeItem(nodeA, nodeB, typeA);
                                    foreach (PortalInfoItem portalInfoItem in nodeA.Portals)
                                    {
                                        if (portalInfoItem.destRoomIdx == edge.index)
                                        {
                                            PathNodeChildItem pathNodeChildItem = new PathNodeChildItem(new PathNodeItem(edge, nodeB, typeB), portalInfoItem);
                                            pathNodeItem.Items.Add(pathNodeChildItem);
                                        }
                                    }
                                    pathNodeList.Items.Add(pathNodeItem);
                                }
                            }
                        }
                    }
                    break;

                case PathType.Unk04:
                case PathType.Unk05:
                    foreach (Node edge in edges)
                    {
                        if (pathNode.nodeA == edge && pathNode.nodeB == nodeB)
                        {
                            (bool found, PathNodeItem existingPath) = FindPathNodeInList(pathNodeList, nodeA, nodeB, typeA);
                            bool hasPathBeenFound = HasPathAlreadyBeenFound(pathNodeList, nodeA, nodeB);
                            if (hasPathBeenFound == false)
                            {
                                if (found)
                                {
                                    PathNodeItem pathNodeItem = existingPath;

                                    foreach (PortalInfoItem portalInfoItem in nodeA.Portals)
                                    {
                                        if (portalInfoItem.destRoomIdx == edge.index)
                                        {
                                            PathNodeChildItem pathNodeChildItem = new PathNodeChildItem(new PathNodeItem(edge, nodeB, typeB), portalInfoItem);
                                            pathNodeItem.Items.Add(pathNodeChildItem);
                                        }
                                    }
                                }
                                else
                                {
                                    PathNodeItem pathNodeItem = new PathNodeItem(nodeA, nodeB, typeA);
                                    foreach (PortalInfoItem portalInfoItem in nodeA.Portals)
                                    {
                                        if (portalInfoItem.destRoomIdx == edge.index)
                                        {
                                            PathNodeChildItem pathNodeChildItem = new PathNodeChildItem(new PathNodeItem(edge, nodeB, typeB), portalInfoItem);
                                            pathNodeItem.Items.Add(pathNodeChildItem);
                                        }
                                    }
                                    pathNodeList.Items.Add(pathNodeItem);
                                }
                            }
                        }
                    }
                    break;
                }
            }
        }