示例#1
0
        /// <summary>Helper function for deserializing graphs</summary>
        void DeserializeGraphsPartAdditive(AstarSerializer sr)
        {
            if (graphs == null)
            {
                graphs = new NavGraph[0];
            }

            var gr = new List <NavGraph>(graphs);

            // Set an offset so that the deserializer will load
            // the graphs with the correct graph indexes
            sr.SetGraphIndexOffset(gr.Count);

            if (graphTypes == null)
            {
                FindGraphTypes();
            }
            gr.AddRange(sr.DeserializeGraphs(graphTypes));
            graphs = gr.ToArray();

            sr.DeserializeEditorSettingsCompatibility();
            sr.DeserializeExtraInfo();

            //Assign correct graph indices.
            for (int i = 0; i < graphs.Length; i++)
            {
                if (graphs[i] == null)
                {
                    continue;
                }
                graphs[i].GetNodes(node => node.GraphIndex = (uint)i);
            }

            for (int i = 0; i < graphs.Length; i++)
            {
                for (int j = i + 1; j < graphs.Length; j++)
                {
                    if (graphs[i] != null && graphs[j] != null && graphs[i].guid == graphs[j].guid)
                    {
                        Debug.LogWarning("Guid Conflict when importing graphs additively. Imported graph will get a new Guid.\nThis message is (relatively) harmless.");
                        graphs[i].guid = Pathfinding.Util.Guid.NewGuid();
                        break;
                    }
                }
            }

            sr.PostDeserialization();
            active.hierarchicalGraph.RecalculateIfNecessary();
        }
示例#2
0
        // Token: 0x060021EB RID: 8683 RVA: 0x00190A94 File Offset: 0x0018EC94
        private void DeserializeGraphsPartAdditive(AstarSerializer sr)
        {
            if (this.graphs == null)
            {
                this.graphs = new NavGraph[0];
            }
            List <NavGraph> list = new List <NavGraph>(this.graphs);

            sr.SetGraphIndexOffset(list.Count);
            list.AddRange(sr.DeserializeGraphs());
            this.graphs = list.ToArray();
            sr.DeserializeEditorSettingsCompatibility();
            sr.DeserializeExtraInfo();
            int i;
            int l;

            for (i = 0; i < this.graphs.Length; i = l + 1)
            {
                if (this.graphs[i] != null)
                {
                    this.graphs[i].GetNodes(delegate(GraphNode node)
                    {
                        node.GraphIndex = (uint)i;
                    });
                }
                l = i;
            }
            for (int j = 0; j < this.graphs.Length; j++)
            {
                for (int k = j + 1; k < this.graphs.Length; k++)
                {
                    if (this.graphs[j] != null && this.graphs[k] != null && this.graphs[j].guid == this.graphs[k].guid)
                    {
                        Debug.LogWarning("Guid Conflict when importing graphs additively. Imported graph will get a new Guid.\nThis message is (relatively) harmless.");
                        this.graphs[j].guid = Pathfinding.Util.Guid.NewGuid();
                        break;
                    }
                }
            }
            sr.PostDeserialization();
        }