Пример #1
0
        public override void Apply(Path p)
        {
            if (p.path == null || p.path.Count == 0 || p.vectorPath == null || p.vectorPath.Count == 0)
            {
                return;
            }
            List <Vector3> list = ListPool <Vector3> .Claim();

            List <Funnel.PathPart> list2 = Funnel.SplitIntoParts(p);

            for (int i = 0; i < list2.Count; i++)
            {
                Funnel.PathPart pathPart = list2[i];
                if (!pathPart.isLink)
                {
                    List <Vector3> list3 = Funnel.Calculate(Funnel.ConstructFunnelPortals(p.path, pathPart), this.unwrap, this.splitAtEveryPortal);
                    list.AddRange(list3);
                    ListPool <Vector3> .Release(list3);
                }
            }
            ListPool <Funnel.PathPart> .Release(list2);

            ListPool <Vector3> .Release(p.vectorPath);

            p.vectorPath = list;
        }
        // Token: 0x06002648 RID: 9800 RVA: 0x001A5D98 File Offset: 0x001A3F98
        public override void Apply(Path p)
        {
            if (p.path == null || p.path.Count == 0 || p.vectorPath == null || p.vectorPath.Count == 0)
            {
                return;
            }
            List <Vector3> list = ListPool <Vector3> .Claim();

            List <Funnel.PathPart> list2 = Funnel.SplitIntoParts(p);

            if (list2.Count == 0)
            {
                return;
            }
            for (int i = 0; i < list2.Count; i++)
            {
                Funnel.PathPart pathPart = list2[i];
                if (!pathPart.isLink)
                {
                    Funnel.FunnelPortals funnel     = Funnel.ConstructFunnelPortals(p.path, pathPart);
                    List <Vector3>       collection = Funnel.Calculate(funnel, this.unwrap, this.splitAtEveryPortal);
                    list.AddRange(collection);
                    ListPool <Vector3> .Release(ref funnel.left);

                    ListPool <Vector3> .Release(ref funnel.right);

                    ListPool <Vector3> .Release(ref collection);
                }
                else
                {
                    if (i == 0 || list2[i - 1].isLink)
                    {
                        list.Add(pathPart.startPoint);
                    }
                    if (i == list2.Count - 1 || list2[i + 1].isLink)
                    {
                        list.Add(pathPart.endPoint);
                    }
                }
            }
            ListPool <Funnel.PathPart> .Release(ref list2);

            ListPool <Vector3> .Release(ref p.vectorPath);

            p.vectorPath = list;
        }
Пример #3
0
        public static List <Funnel.PathPart> SplitIntoParts(Path path)
        {
            List <GraphNode>       path2 = path.path;
            List <Funnel.PathPart> list  = ListPool <Funnel.PathPart> .Claim();

            if (path2 == null || path2.Count == 0)
            {
                return(list);
            }
            for (int i = 0; i < path2.Count; i++)
            {
                if (path2[i] is TriangleMeshNode || path2[i] is GridNodeBase)
                {
                    Funnel.PathPart pathPart = default(Funnel.PathPart);
                    pathPart.startIndex = i;
                    uint graphIndex = path2[i].GraphIndex;
                    while (i < path2.Count && (path2[i].GraphIndex == graphIndex || path2[i] is NodeLink3Node))
                    {
                        i++;
                    }
                    i--;
                    pathPart.endIndex = i;
                    if (pathPart.startIndex == 0)
                    {
                        pathPart.startPoint = path.vectorPath[0];
                    }
                    else
                    {
                        pathPart.startPoint = (Vector3)path2[pathPart.startIndex - 1].position;
                    }
                    if (pathPart.endIndex == path2.Count - 1)
                    {
                        pathPart.endPoint = path.vectorPath[path.vectorPath.Count - 1];
                    }
                    else
                    {
                        pathPart.endPoint = (Vector3)path2[pathPart.endIndex + 1].position;
                    }
                    list.Add(pathPart);
                }
                else
                {
                    if (!(NodeLink2.GetNodeLink(path2[i]) != null))
                    {
                        throw new Exception("Unsupported node type or null node");
                    }
                    Funnel.PathPart pathPart2 = default(Funnel.PathPart);
                    pathPart2.startIndex = i;
                    uint graphIndex2 = path2[i].GraphIndex;
                    i++;
                    while (i < path2.Count && path2[i].GraphIndex == graphIndex2)
                    {
                        i++;
                    }
                    i--;
                    if (i - pathPart2.startIndex != 0)
                    {
                        if (i - pathPart2.startIndex != 1)
                        {
                            throw new Exception("NodeLink2 link length greater than two (2) nodes. " + (i - pathPart2.startIndex + 1));
                        }
                        pathPart2.endIndex   = i;
                        pathPart2.isLink     = true;
                        pathPart2.startPoint = (Vector3)path2[pathPart2.startIndex].position;
                        pathPart2.endPoint   = (Vector3)path2[pathPart2.endIndex].position;
                        list.Add(pathPart2);
                    }
                }
            }
            return(list);
        }
Пример #4
0
        public static Funnel.FunnelPortals ConstructFunnelPortals(List <GraphNode> nodes, Funnel.PathPart part)
        {
            List <Vector3> list = ListPool <Vector3> .Claim(nodes.Count + 1);

            List <Vector3> list2 = ListPool <Vector3> .Claim(nodes.Count + 1);

            if (nodes == null || nodes.Count == 0)
            {
                return(new Funnel.FunnelPortals
                {
                    left = list,
                    right = list2
                });
            }
            if (part.endIndex < part.startIndex || part.startIndex < 0 || part.endIndex > nodes.Count)
            {
                throw new ArgumentOutOfRangeException();
            }
            list.Add(part.startPoint);
            list2.Add(part.startPoint);
            for (int i = part.startIndex; i < part.endIndex - 1; i++)
            {
                if (!nodes[i].GetPortal(nodes[i + 1], list, list2, false))
                {
                    list.Add((Vector3)nodes[i].position);
                    list2.Add((Vector3)nodes[i].position);
                    list.Add((Vector3)nodes[i + 1].position);
                    list2.Add((Vector3)nodes[i + 1].position);
                }
            }
            list.Add(part.endPoint);
            list2.Add(part.endPoint);
            return(new Funnel.FunnelPortals
            {
                left = list,
                right = list2
            });
        }