コード例 #1
0
        private static byte[] SerializeNodeIndices(NavGraph[] graphs)
        {
            MemoryStream memoryStream            = new MemoryStream();
            BinaryWriter writer                  = new BinaryWriter(memoryStream);
            int          maxNodeIndexInAllGraphs = AstarSerializer.GetMaxNodeIndexInAllGraphs(graphs);

            writer.Write(maxNodeIndexInAllGraphs);
            int maxNodeIndex2 = 0;

            Action <GraphNode> < > 9__0;
            for (int i = 0; i < graphs.Length; i++)
            {
                if (graphs[i] != null)
                {
                    NavGraph           navGraph = graphs[i];
                    Action <GraphNode> action;
                    if ((action = < > 9__0) == null)
                    {
                        action = (< > 9__0 = delegate(GraphNode node)
                        {
                            maxNodeIndex2 = Math.Max(node.NodeIndex, maxNodeIndex2);
                            writer.Write(node.NodeIndex);
                        });
                    }
                    navGraph.GetNodes(action);
                }
            }
            if (maxNodeIndex2 != maxNodeIndexInAllGraphs)
            {
                throw new Exception("Some graphs are not consistent in their GetNodes calls, sequential calls give different results.");
            }
            byte[] result = memoryStream.ToArray();
            writer.Close();
            return(result);
        }