IList <int> GetParentsBelowStackBased(int id)
        {
            Stack <int> stack = StackPool <int> .Get();

            stack.Push(id);

            var parentsBelow = new List <int>();

            while (stack.Count > 0)
            {
                int current = stack.Pop();
                if (HasChildren(current))
                {
                    parentsBelow.Add(current);
                    var children = GetChildren(current);
                    foreach (var val in children)
                    {
                        stack.Push(val.Id);
                    }
                    ListPool <T> .Release(children);
                }
            }
            StackPool <int> .Release(stack);

            return(parentsBelow);
        }
Example #2
0
        void Sort <T>(T rootItem, Comparison <TreeViewItem> func, Comparison <int> intfunc) where T : TreeViewItem
        {
            rootItem.children.Sort(func);
            Stack <TreeViewItem> itemstack = StackPool <TreeViewItem> .Get();

            foreach (var child in rootItem.children)
            {
                itemstack.Push(child);
            }

            while (itemstack.Count > 0)
            {
                var item = itemstack.Pop();
                if (_treeView.IsExpanded(item.id) && item.children.Count > 0 && item.children[0] != null)
                {
                    foreach (var child in item.children)
                    {
                        itemstack.Push(child);
                    }
                    item.children.Sort(func);
                }
            }

            StackPool <TreeViewItem> .Release(itemstack);

            _model.Sort(intfunc);
        }
Example #3
0
        public static void TreeListChildren(TreeViewItem rootItem, IList <TreeViewItem> row)
        {
            row.Clear();
            Stack <TreeViewItem> stack = StackPool <TreeViewItem> .Get();

            for (int i = rootItem.children.Count - 1; i >= 0; i--)
            {
                stack.Push(rootItem.children[i]);
            }

            while (stack.Count > 0)
            {
                var item = stack.Pop();
                row.Add(item);

                if (item.hasChildren && item.children[0] != null)
                {
                    for (int i = item.children.Count - 1; i >= 0; i--)
                    {
                        stack.Push(item.children[i]);
                    }
                }
            }

            StackPool <TreeViewItem> .Release(stack);
        }
Example #4
0
		/** Returns all nodes reachable from the seed node.
		 * This function performs a BFS (breadth-first-search) or flood fill of the graph and returns all nodes which can be reached from
		 * the seed node. In almost all cases this will be identical to returning all nodes which have the same area as the seed node.
		 * In the editor areas are displayed as different colors of the nodes.
		 * The only case where it will not be so is when there is a one way path from some part of the area to the seed node
		 * but no path from the seed node to that part of the graph.
		 * 
		 * The returned list is sorted by node distance from the seed node
		 * i.e distance is measured in the number of nodes the shortest path from \a seed to that node would pass through.
		 * Note that the distance measurement does not take heuristics, penalties or tag penalties.
		 * 
		 * Depending on the number of reachable nodes, this function can take quite some time to calculate
		 * so don't use it too often or it might affect the framerate of your game.
		 * 
		 * \param seed The node to start the search from
		 * \param tagMask Optional mask for tags. This is a bitmask.
		 * 
		 * \returns A List<Node> containing all nodes reachable from the seed node.
		 * For better memory management the returned list should be pooled, see Pathfinding.Util.ListPool
		 */
		public static List<GraphNode> GetReachableNodes (GraphNode seed, int tagMask = -1) {
			var stack = StackPool<GraphNode>.Claim ();
			var list = ListPool<GraphNode>.Claim ();
			
			/** \todo Pool */
			var map = new HashSet<GraphNode>();
			
			GraphNodeDelegate callback;
			if (tagMask == -1) {
				callback = delegate (GraphNode node) {
					if (node.Walkable && map.Add (node)) {
						list.Add (node);
						stack.Push (node);
					}
				};
			} else {
				callback = delegate (GraphNode node) {
					if (node.Walkable && ((tagMask >> (int)node.Tag) & 0x1) != 0 && map.Add (node)) {
						list.Add (node);
						stack.Push (node);
					}
				};
			}
			
			callback (seed);
			
			while (stack.Count > 0) {
				stack.Pop ().GetConnections (callback);
			}
			
			StackPool<GraphNode>.Release (stack);
			
			return list;
		}
Example #5
0
        private void Release()
        {
            tokenStream.Release();
            StackPool <StyleOperatorNode> .Release(operatorStack);

            StackPool <StyleASTNode> .Release(expressionStack);
        }
Example #6
0
        string GetPath(GameObject gameObject)
        {
            Transform         trans = gameObject.transform;
            Stack <Transform> stack = StackPool <Transform> .Get();

            stack.Push(trans);

            while (trans.parent != null)
            {
                trans = trans.parent;
                stack.Push(trans);
            }

            string path = "";

            while (stack.Count > 0)
            {
                var node = stack.Pop();
                path += node.name;

                if (stack.Count > 0)
                {
                    path += "/";
                }
            }

            StackPool <Transform> .Release(stack);

            return(path);
        }
Example #7
0
        public void Release()
        {
            StackPool <int> .Release(stack);

            StructList <ExpressionToken> .Release(ref tokens);

            stack = null;
        }
            public static void ApplyActionLeafFirst(GraphData graph, Action <AbstractMaterialNode> action)
            {
                var temporaryMarks = PooledHashSet <string> .Get();

                var permanentMarks = PooledHashSet <string> .Get();

                var slots = ListPool <MaterialSlot> .Get();

                // Make sure we process a node's children before the node itself.
                var stack = StackPool <AbstractMaterialNode> .Get();

                foreach (var node in graph.GetNodes <AbstractMaterialNode>())
                {
                    stack.Push(node);
                }
                while (stack.Count > 0)
                {
                    var node = stack.Pop();
                    if (permanentMarks.Contains(node.objectId))
                    {
                        continue;
                    }

                    if (temporaryMarks.Contains(node.objectId))
                    {
                        action.Invoke(node);
                        permanentMarks.Add(node.objectId);
                    }
                    else
                    {
                        temporaryMarks.Add(node.objectId);
                        stack.Push(node);
                        node.GetInputSlots(slots);
                        foreach (var inputSlot in slots)
                        {
                            var nodeEdges = graph.GetEdges(inputSlot.slotReference);
                            foreach (var edge in nodeEdges)
                            {
                                var fromSocketRef = edge.outputSlot;
                                var childNode     = fromSocketRef.node;
                                if (childNode != null)
                                {
                                    stack.Push(childNode);
                                }
                            }
                        }
                        slots.Clear();
                    }
                }

                StackPool <AbstractMaterialNode> .Release(stack);

                ListPool <MaterialSlot> .Release(slots);

                temporaryMarks.Dispose();
                permanentMarks.Dispose();
            }
Example #9
0
        public void Release()
        {
            StackPool <int> .Release(stack);

            ListPool <StyleToken> .Release(ref tokens);

            stack  = null;
            tokens = null;
        }
Example #10
0
        public void Release(bool releaseTokenStream = true)
        {
            if (releaseTokenStream)
            {
                tokenStream.Release();
            }

            StackPool <OperatorNode> .Release(operatorStack);

            StackPool <ASTNode> .Release(expressionStack);
        }
Example #11
0
        /// <summary>
        /// Returns all nodes reachable from the seed node.
        /// This function performs a DFS (depth-first-search) or flood fill of the graph and returns all nodes which can be reached from
        /// the seed node. In almost all cases this will be identical to returning all nodes which have the same area as the seed node.
        /// In the editor areas are displayed as different colors of the nodes.
        /// The only case where it will not be so is when there is a one way path from some part of the area to the seed node
        /// but no path from the seed node to that part of the graph.
        ///
        /// The returned list is not sorted in any particular way.
        ///
        /// Depending on the number of reachable nodes, this function can take quite some time to calculate
        /// so don't use it too often or it might affect the framerate of your game.
        ///
        /// See: bitmasks (view in online documentation for working links).
        ///
        /// Returns: A List<Node> containing all nodes reachable from the seed node.
        /// For better memory management the returned list should be pooled, see Pathfinding.Util.ListPool.
        /// </summary>
        /// <param name="seed">The node to start the search from.</param>
        /// <param name="tagMask">Optional mask for tags. This is a bitmask.</param>
        /// <param name="filter">Optional filter for which nodes to search. You can combine this with tagMask = -1 to make the filter determine everything.
        ///      Only walkable nodes are searched regardless of the filter. If the filter function returns false the node will be treated as unwalkable.</param>
        public static List <GraphNode> GetReachableNodes(GraphNode seed, int tagMask          = -1,
                                                         System.Func <GraphNode, bool> filter = null)
        {
            var dfsStack = StackPool <GraphNode> .Claim();

            var reachable = ListPool <GraphNode> .Claim();

            /// <summary>TODO: Pool</summary>
            var map = new HashSet <GraphNode>();

            System.Action <GraphNode> callback;
            // Check if we can use the fast path
            if (tagMask == -1 && filter == null)
            {
                callback = (GraphNode node) =>
                {
                    if (node.Walkable && map.Add(node))
                    {
                        reachable.Add(node);
                        dfsStack.Push(node);
                    }
                }
            }
            ;
            else
            {
                callback = (GraphNode node) =>
                {
                    if (node.Walkable && ((tagMask >> (int)node.Tag) & 0x1) != 0 && map.Add(node))
                    {
                        if (filter != null && !filter(node))
                        {
                            return;
                        }

                        reachable.Add(node);
                        dfsStack.Push(node);
                    }
                }
            };

            callback(seed);

            while (dfsStack.Count > 0)
            {
                dfsStack.Pop().GetConnections(callback);
            }

            StackPool <GraphNode> .Release(dfsStack);

            return(reachable);
        }
        void TryAddChildren(AssetTreeItem <T> rootitem, List <TreeViewItem> list, AssetTreeModel <T> model, int depth)
        {
            if (model.HasChildren(rootitem.DataId))
            {
                List <T> children = model.GetChildren(rootitem.DataId);
                Stack <AssetTreeItem <T> > stack = StackPool <AssetTreeItem <T> > .Get();

                for (int i = children.Count - 1; i >= 0; i--)
                {
                    var child = children[i];

                    //create item
                    var childItem = CreateItem(ref child, depth + 1);
                    stack.Push(childItem);
                }

                ListPool <T> .Release(children);

                while (stack.Count > 0)
                {
                    var stackChild = stack.Pop();
                    list.Add(stackChild);
                    if (model.HasChildren(stackChild.DataId))
                    {
                        if (IsExpanded(stackChild.id))
                        {
                            children = model.GetChildren(stackChild.DataId);
                            //
                            //stackChild.children = new List<TreeViewItem>();
                            for (int i = children.Count - 1; i >= 0; i--)
                            {
                                var child = children[i];

                                //create item
                                var childItem = CreateItem(ref child, stackChild.depth + 1);
                                stack.Push(childItem);
                                //stackChild.children.Add(childItem);
                            }

                            ListPool <T> .Release(children);
                        }
                        else
                        {
                            stackChild.children = CreateChildListForCollapsedParent();
                        }
                    }
                }

                StackPool <AssetTreeItem <T> > .Release(stack);
            }
        }
Example #13
0
        /** Returns all nodes reachable from the seed node.
         * This function performs a BFS (breadth-first-search) or flood fill of the graph and returns all nodes which can be reached from
         * the seed node. In almost all cases this will be identical to returning all nodes which have the same area as the seed node.
         * In the editor areas are displayed as different colors of the nodes.
         * The only case where it will not be so is when there is a one way path from some part of the area to the seed node
         * but no path from the seed node to that part of the graph.
         *
         * The returned list is sorted by node distance from the seed node
         * i.e distance is measured in the number of nodes the shortest path from \a seed to that node would pass through.
         * Note that the distance measurement does not take heuristics, penalties or tag penalties.
         *
         * Depending on the number of reachable nodes, this function can take quite some time to calculate
         * so don't use it too often or it might affect the framerate of your game.
         *
         * \param seed The node to start the search from
         * \param tagMask Optional mask for tags. This is a bitmask.
         *
         * \returns A List<Node> containing all nodes reachable from the seed node.
         * For better memory management the returned list should be pooled, see Pathfinding.Util.ListPool
         */
        public static List <GraphNode> GetReachableNodes(GraphNode seed, int tagMask = -1)
        {
#if ASTAR_PROFILE
            System.Diagnostics.Stopwatch watch = new System.Diagnostics.Stopwatch();
            watch.Start();
#endif
            Stack <GraphNode> stack = StackPool <GraphNode> .Claim();

            List <GraphNode> list = ListPool <GraphNode> .Claim();

            /** \todo Pool */
            var map = new HashSet <GraphNode>();

            GraphNodeDelegate callback;
            if (tagMask == -1)
            {
                callback = delegate(GraphNode node) {
                    if (node.Walkable && map.Add(node))
                    {
                        list.Add(node);
                        stack.Push(node);
                    }
                };
            }
            else
            {
                callback = delegate(GraphNode node) {
                    if (node.Walkable && ((tagMask >> (int)node.Tag) & 0x1) != 0 && map.Add(node))
                    {
                        list.Add(node);
                        stack.Push(node);
                    }
                };
            }

            callback(seed);

            while (stack.Count > 0)
            {
                stack.Pop().GetConnections(callback);
            }

            StackPool <GraphNode> .Release(stack);

#if ASTAR_PROFILE
            watch.Stop();
            Debug.Log((1000 * watch.Elapsed.TotalSeconds).ToString("0.0 ms"));
#endif
            return(list);
        }
Example #14
0
        private void Abort(string info = null)
        {
            string expression = tokenStream.PrintTokens();

            tokenStream.Release();
            StackPool <OperatorNode> .Release(operatorStack);

            StackPool <ASTNode> .Release(expressionStack);

            if (info != null)
            {
                throw new ParseException($"Failed to parse expression: {expression}. {info}");
            }
            else
            {
                throw new ParseException($"Failed to parse expression: {expression}");
            }
        }
        // Token: 0x0600279F RID: 10143 RVA: 0x001B30BC File Offset: 0x001B12BC
        public static List <GraphNode> GetReachableNodes(GraphNode seed, int tagMask = -1, Func <GraphNode, bool> filter = null)
        {
            Stack <GraphNode> dfsStack = StackPool <GraphNode> .Claim();

            List <GraphNode> reachable = ListPool <GraphNode> .Claim();

            HashSet <GraphNode> map = new HashSet <GraphNode>();
            Action <GraphNode>  action;

            if (tagMask == -1 && filter == null)
            {
                action = delegate(GraphNode node)
                {
                    if (node.Walkable && map.Add(node))
                    {
                        reachable.Add(node);
                        dfsStack.Push(node);
                    }
                };
            }
            else
            {
                action = delegate(GraphNode node)
                {
                    if (node.Walkable && (tagMask >> (int)node.Tag & 1) != 0 && map.Add(node))
                    {
                        if (filter != null && !filter(node))
                        {
                            return;
                        }
                        reachable.Add(node);
                        dfsStack.Push(node);
                    }
                };
            }
            action(seed);
            while (dfsStack.Count > 0)
            {
                dfsStack.Pop().GetConnections(action);
            }
            StackPool <GraphNode> .Release(dfsStack);

            return(reachable);
        }
Example #16
0
        /** Returns all nodes reachable from the seed node.
         * This function performs a BFS (breadth-first-search) or flood fill of the graph and returns all nodes which can be reached from
         * the seed node. In almost all cases this will be identical to returning all nodes which have the same area as the seed node.
         * In the editor areas are displayed as different colors of the nodes.
         * The only case where it will not be so is when there is a one way path from some part of the area to the seed node
         * but no path from the seed node to that part of the graph.
         *
         * The returned list is sorted by node distance from the seed node
         * i.e distance is measured in the number of nodes the shortest path from \a seed to that node would pass through.
         * Note that the distance measurement does not take heuristics, penalties or tag penalties.
         *
         * Depending on the number of reachable nodes, this function can take quite some time to calculate
         * so don't use it too often or it might affect the framerate of your game.
         *
         * \param seed The node to start the search from
         * \param tagMask Optional mask for tags. This is a bitmask.
         *
         * \returns A List<Node> containing all nodes reachable from the seed node.
         * For better memory management the returned list should be pooled, see Pathfinding.Util.ListPool
         */
        public static List <GraphNode> GetReachableNodes(GraphNode seed, int tagMask = -1)
        {
            Stack <GraphNode> dfsStack = StackPool <GraphNode> .Claim();

            List <GraphNode> reachable = ListPool <GraphNode> .Claim();

            /** \todo Pool */
            var map = new HashSet <GraphNode>();

            System.Action <GraphNode> callback;
            if (tagMask == -1)
            {
                callback = (GraphNode node) => {
                    if (node.Walkable && map.Add(node))
                    {
                        reachable.Add(node);
                        dfsStack.Push(node);
                    }
                };
            }
            else
            {
                callback = (GraphNode node) => {
                    if (node.Walkable && ((tagMask >> (int)node.Tag) & 0x1) != 0 && map.Add(node))
                    {
                        reachable.Add(node);
                        dfsStack.Push(node);
                    }
                };
            }

            callback(seed);

            while (dfsStack.Count > 0)
            {
                dfsStack.Pop().GetConnections(callback);
            }

            StackPool <GraphNode> .Release(dfsStack);

            return(reachable);
        }
Example #17
0
        public static List <GraphNode> GetReachableNodes(GraphNode seed, int tagMask = -1)
        {
            Stack <GraphNode> stack = StackPool <GraphNode> .Claim();

            List <GraphNode> list = ListPool <GraphNode> .Claim();

            HashSet <GraphNode> map = new HashSet <GraphNode>();
            Action <GraphNode>  action;

            if (tagMask == -1)
            {
                action = delegate(GraphNode node)
                {
                    if (node.Walkable && map.Add(node))
                    {
                        list.Add(node);
                        stack.Push(node);
                    }
                };
            }
            else
            {
                action = delegate(GraphNode node)
                {
                    if (node.Walkable && (tagMask >> (int)node.Tag & 1) != 0 && map.Add(node))
                    {
                        list.Add(node);
                        stack.Push(node);
                    }
                };
            }
            action(seed);
            while (stack.Count > 0)
            {
                stack.Pop().GetConnections(action);
            }
            StackPool <GraphNode> .Release(stack);

            return(list);
        }
        void SearchItem(List <TreeViewItem> list, AssetTreeModel <T> model, int itemid)
        {
            if (list != null && model != null && model.HasChildren(itemid))
            {
                List <T>  children = model.GetChildren(itemid);
                Stack <T> stack    = StackPool <T> .Get();

                for (int i = children.Count - 1; i >= 0; i--)
                {
                    stack.Push(children[i]);
                }

                ListPool <T> .Release(children);

                while (stack.Count > 0)
                {
                    T current = stack.Pop();

                    if (!string.IsNullOrEmpty(current.DisplayName) && current.DisplayName.IndexOf(searchString, StringComparison.OrdinalIgnoreCase) >= 0)
                    {
                        //Add result
                        var viewitem = CreateItem(ref current, 0);
                        list.Add(viewitem);
                    }

                    if (model.HasChildren(current.Id))
                    {
                        children = model.GetChildren(current.Id);
                        for (int i = children.Count - 1; i >= 0; i--)
                        {
                            stack.Push(children[i]);
                        }

                        ListPool <T> .Release(children);
                    }
                }

                StackPool <T> .Release(stack);
            }
        }
        // Token: 0x060022EE RID: 8942 RVA: 0x00196858 File Offset: 0x00194A58
        public void FloodFill(GraphNode seed, uint area)
        {
            if (area > 131071U)
            {
                Debug.LogError("Too high area index - The maximum area index is " + 131071U);
                return;
            }
            if (area < 0U)
            {
                Debug.LogError("Too low area index - The minimum area index is 0");
                return;
            }
            Stack <GraphNode> stack = StackPool <GraphNode> .Claim();

            stack.Push(seed);
            seed.Area = area;
            while (stack.Count > 0)
            {
                stack.Pop().FloodFill(stack, area);
            }
            StackPool <GraphNode> .Release(stack);
        }
Example #20
0
        void AddPathRecursive(HashSet <string> hashset, string path)
        {
            if (path != Application.dataPath)
            {
                path = path.Replace('\\', '/');
                string         subpath = path;
                Stack <string> stack   = StackPool <string> .Get();

                while (true)
                {
                    int index = subpath.LastIndexOf('/');
                    if (index >= 0)
                    {
                        subpath = path.Substring(0, index);
                        stack.Push(subpath);
                    }
                    else
                    {
                        subpath = null;
                    }

                    if (string.IsNullOrEmpty(subpath) || subpath == Application.dataPath)
                    {
                        break;
                    }
                }


                while (stack.Count > 0)
                {
                    string result = stack.Pop();

                    hashset.Add(result);
                }

                StackPool <string> .Release(stack);
            }
        }
Example #21
0
        public void ValidateGraph()
        {
            var propertyNodes = GetNodes <PropertyNode>().Where(n => !m_Properties.Any(p => p.guid == n.propertyGuid)).ToArray();

            foreach (var pNode in propertyNodes)
            {
                ReplacePropertyNodeWithConcreteNodeNoValidate(pNode);
            }

            messageManager?.ClearAllFromProvider(this);
            //First validate edges, remove any
            //orphans. This can happen if a user
            //manually modifies serialized data
            //of if they delete a node in the inspector
            //debug view.
            foreach (var edge in edges.ToArray())
            {
                var outputNode = GetNodeFromGuid(edge.outputSlot.nodeGuid);
                var inputNode  = GetNodeFromGuid(edge.inputSlot.nodeGuid);

                MaterialSlot outputSlot = null;
                MaterialSlot inputSlot  = null;
                if (outputNode != null && inputNode != null)
                {
                    outputSlot = outputNode.FindOutputSlot <MaterialSlot>(edge.outputSlot.slotId);
                    inputSlot  = inputNode.FindInputSlot <MaterialSlot>(edge.inputSlot.slotId);
                }

                if (outputNode == null ||
                    inputNode == null ||
                    outputSlot == null ||
                    inputSlot == null ||
                    !outputSlot.IsCompatibleWith(inputSlot))
                {
                    //orphaned edge
                    RemoveEdgeNoValidate(edge);
                }
            }

            var temporaryMarks = IndexSetPool.Get();
            var permanentMarks = IndexSetPool.Get();
            var slots          = ListPool <MaterialSlot> .Get();

            // Make sure we process a node's children before the node itself.
            var stack = StackPool <AbstractMaterialNode> .Get();

            foreach (var node in GetNodes <AbstractMaterialNode>())
            {
                stack.Push(node);
            }
            while (stack.Count > 0)
            {
                var node = stack.Pop();
                if (permanentMarks.Contains(node.tempId.index))
                {
                    continue;
                }

                if (temporaryMarks.Contains(node.tempId.index))
                {
                    node.ValidateNode();
                    permanentMarks.Add(node.tempId.index);
                }
                else
                {
                    temporaryMarks.Add(node.tempId.index);
                    stack.Push(node);
                    node.GetInputSlots(slots);
                    foreach (var inputSlot in slots)
                    {
                        var nodeEdges = GetEdges(inputSlot.slotReference);
                        foreach (var edge in nodeEdges)
                        {
                            var fromSocketRef = edge.outputSlot;
                            var childNode     = GetNodeFromGuid(fromSocketRef.nodeGuid);
                            if (childNode != null)
                            {
                                stack.Push(childNode);
                            }
                        }
                    }
                    slots.Clear();
                }
            }

            StackPool <AbstractMaterialNode> .Release(stack);

            ListPool <MaterialSlot> .Release(slots);

            IndexSetPool.Release(temporaryMarks);
            IndexSetPool.Release(permanentMarks);

            foreach (var edge in m_AddedEdges.ToList())
            {
                if (!ContainsNodeGuid(edge.outputSlot.nodeGuid) || !ContainsNodeGuid(edge.inputSlot.nodeGuid))
                {
                    Debug.LogWarningFormat("Added edge is invalid: {0} -> {1}\n{2}", edge.outputSlot.nodeGuid, edge.inputSlot.nodeGuid, Environment.StackTrace);
                    m_AddedEdges.Remove(edge);
                }
            }

            foreach (var groupChange in m_NodeGroupChanges.ToList())
            {
                if (!ContainsNodeGuid(groupChange.nodeGuid))
                {
                    m_NodeGroupChanges.Remove(groupChange);
                }
            }
        }
        // Token: 0x060022EF RID: 8943 RVA: 0x001968C8 File Offset: 0x00194AC8
        public void FloodFill()
        {
            NavGraph[] graphs = this.astar.graphs;
            if (graphs == null)
            {
                return;
            }
            foreach (NavGraph navGraph in graphs)
            {
                if (navGraph != null)
                {
                    navGraph.GetNodes(delegate(GraphNode node)
                    {
                        node.Area = 0U;
                    });
                }
            }
            this.lastUniqueAreaIndex = 0U;
            uint area               = 0U;
            int  forcedSmallAreas   = 0;
            Stack <GraphNode> stack = StackPool <GraphNode> .Claim();

            Action <GraphNode> < > 9__1;
            foreach (NavGraph navGraph2 in graphs)
            {
                if (navGraph2 != null)
                {
                    NavGraph           navGraph3 = navGraph2;
                    Action <GraphNode> action;
                    if ((action = < > 9__1) == null)
                    {
                        action = (< > 9__1 = delegate(GraphNode node)
                        {
                            if (node.Walkable && node.Area == 0U)
                            {
                                uint area = area;
                                area += 1U;
                                uint area2 = area;
                                if (area > 131071U)
                                {
                                    area = area;
                                    area -= 1U;
                                    area2 = area;
                                    int forcedSmallAreas;
                                    if (forcedSmallAreas == 0)
                                    {
                                        forcedSmallAreas = 1;
                                    }
                                    forcedSmallAreas = forcedSmallAreas;
                                    forcedSmallAreas++;
                                }
                                stack.Clear();
                                stack.Push(node);
                                int num = 1;
                                node.Area = area2;
                                while (stack.Count > 0)
                                {
                                    num++;
                                    stack.Pop().FloodFill(stack, area2);
                                }
                            }
                        });
                    }
                    navGraph3.GetNodes(action);
                }
            }
            this.lastUniqueAreaIndex = area;
            if (forcedSmallAreas > 0)
            {
                Debug.LogError(string.Concat(new object[]
                {
                    forcedSmallAreas,
                    " areas had to share IDs. This usually doesn't affect pathfinding in any significant way (you might get 'Searched whole area but could not find target' as a reason for path failure) however some path requests may take longer to calculate (specifically those that fail with the 'Searched whole area' error).The maximum number of areas is ",
                    131071U,
                    "."
                }));
            }
            StackPool <GraphNode> .Release(stack);
        }
Example #23
0
        IEnumerator ParseAssetBundle(AssetTreeModel <AssetTreeData> dataModel, Dictionary <string, string[]> assetbundleDictionary, int total)
        {
            //create root
            AssetTreeData rootData = new AssetTreeData();

            rootData.Id    = AssetTreeManager.mIns.GetUniqueId();
            dataModel.Root = rootData;
            dataModel.Add(ref rootData);

            //Editor Ui
            int progress = 0;

            float totalprogress = total + 2;

            yield return(DisplayProgressBar("Asset-Parse AssetBundle", "Start Parseing", 0f));

            foreach (var assetbundleinfo in assetbundleDictionary)
            {
                var assetbundlename = assetbundleinfo.Key;
                var assetpaths      = assetbundleinfo.Value;

                if (assetpaths.Length > 0)
                {
                    AssetTreeData folderData = CreateBaseAssetBundle(assetpaths, assetbundlename, dataModel);
                    folderData.IsAssetBundleViewData = true;

                    foreach (var assetpath in assetpaths)
                    {
                        CreateSubAssetBundle(dataModel, folderData.Id, assetpath, assetbundlename);
                        //Editor Ui
                        progress++;
                        if (progress % AssetWindowConfig.ParseStep == 0)
                        {
                            yield return(DisplayProgressBar("Asset-Parse AssetBundle", "Parseing " + assetpath, progress / totalprogress));
                        }
                    }
                }
            }

            yield return(DisplayProgressBar("Asset-Parse AssetBundle", "Set Dependency", (progress + 1) / totalprogress));

            List <AssetTreeData>  nonamelist = new List <AssetTreeData>();
            Stack <AssetTreeData> itemStack  = StackPool <AssetTreeData> .Get();

            var allTreeDatas = dataModel.GetAllItems();

            //set dependency references
            for (int i = 0; i < allTreeDatas.Count; i++)
            {
                var info = allTreeDatas[i];
                itemStack.Push(info);
                //SetAssetDependRef(ref info,dataModel,nonamelist);
            }

            ListPool <AssetTreeData> .Release(allTreeDatas);

            yield return(SetAssetDependRef(itemStack, dataModel, nonamelist));

            StackPool <AssetTreeData> .Release(itemStack);

            yield return(DisplayProgressBar("Asset-Parse AssetBundle", "Assigning NoAssetName", 1f));

            for (int i = 0; i < nonamelist.Count; i++)
            {
                var nonameitem = nonamelist[i];

                var deplist = dataModel.GetDependParents(nonameitem.FilePath);
                for (int j = 0; j < deplist.Count; j++)
                {
                    var dep = deplist[j];
                    if (j == 0)
                    {
                        dataModel.AddChild(dep.Id, nonameitem.Id);
                    }
                    else
                    {
                        nonameitem.Id = AssetTreeManager.mIns.GetUniqueId();
                        dataModel.Add(ref nonameitem);
                        //dataModel.AddViewData(ref nonameitem);
                        dataModel.AddChild(dep.Id, nonameitem.Id);
                    }
                }
            }

            yield return(null);

            EditorUtility.ClearProgressBar();
        }
        protected override void SelectionChanged(IList <int> selectedIds)
        {
            if (selectedIds.Count > 0)
            {
                FrameItem(selectedIds[0]);

                var render = AssetTreeManager.mIns.GetGuiRender(EditorContexts.mIns.Mode);
                if (render != null)
                {
                    List <TreeViewItem> itemList = ListPool <TreeViewItem> .Get();

                    var rows = GetRows();
                    for (int i = 0; i < rows.Count; i++)
                    {
                        var rowdata = rows[i] as AssetTreeItem <T>;
                        if (rowdata != null && selectedIds.Contains(rowdata.id))
                        {
                            itemList.Add(rowdata);
                        }
                    }

                    foreach (var subrender in render)
                    {
                        if (subrender.TypeMode == _viewMode)
                        {
                            IGuiTree treeRender = subrender as IGuiTree;
                            if (treeRender != null)
                            {
                                treeRender.SelectionChanged(itemList);
                            }
                        }
                    }

                    //is searching
                    if (!string.IsNullOrEmpty(searchString))
                    {
                        IList <int> expandlist = GetExpanded();
                        if (expandlist != null)
                        {
                            List <int> list = new List <int>();
                            list.AddRange(expandlist);

                            Stack <int> stack = StackPool <int> .Get();

                            foreach (var item in itemList)
                            {
                                stack.Push(item.id);
                            }

                            while (stack.Count > 0)
                            {
                                var itemid = stack.Pop();
                                if (!list.Contains(itemid))
                                {
                                    list.Add(itemid);
                                    if (_model.HasParent(itemid))
                                    {
                                        var parents = _model.GetParent(itemid);
                                        foreach (var parent in parents)
                                        {
                                            if (!list.Contains(parent.Id) && parent.Id != _model.Root.Id)
                                            {
                                                stack.Push(parent.Id);
                                            }
                                        }

                                        ListPool <T> .Release(parents);
                                    }
                                }
                            }
                            StackPool <int> .Release(stack);

                            SetExpanded(list);
                        }
                    }

                    ListPool <TreeViewItem> .Release(itemList);
                }
                else
                {
                    base.SelectionChanged(selectedIds);
                }
            }
        }