private void DeserializeNodeLinks(GraphNode[] int2Node) { ZipEntry entry = this.GetEntry("node_link2.binary"); if (entry == null) { return; } NodeLink2.DeserializeReferences(new GraphSerializationContext(AstarSerializer.GetBinaryReader(entry), int2Node, 0u, this.meta)); }
private void DeserializeNodeLinks(GraphNode[] int2Node) { ZipEntry zipEntry = this.zip["node_link2.binary"]; if (zipEntry == null) { return; } BinaryReader binaryReader = AstarSerializer.GetBinaryReader(zipEntry); GraphSerializationContext ctx = new GraphSerializationContext(binaryReader, int2Node, 0u, this.meta); NodeLink2.DeserializeReferences(ctx); }
private GraphMeta DeserializeBinaryMeta(ZipEntry entry) { GraphMeta graphMeta = new GraphMeta(); BinaryReader binaryReader = AstarSerializer.GetBinaryReader(entry); if (binaryReader.ReadString() != "A*") { throw new Exception("Invalid magic number in saved data"); } int num = binaryReader.ReadInt32(); int num2 = binaryReader.ReadInt32(); int num3 = binaryReader.ReadInt32(); int num4 = binaryReader.ReadInt32(); if (num < 0) { graphMeta.version = new Version(0, 0); } else if (num2 < 0) { graphMeta.version = new Version(num, 0); } else if (num3 < 0) { graphMeta.version = new Version(num, num2); } else if (num4 < 0) { graphMeta.version = new Version(num, num2, num3); } else { graphMeta.version = new Version(num, num2, num3, num4); } graphMeta.graphs = binaryReader.ReadInt32(); graphMeta.guids = new List <string>(); int num5 = binaryReader.ReadInt32(); for (int i = 0; i < num5; i++) { graphMeta.guids.Add(binaryReader.ReadString()); } graphMeta.typeNames = new List <string>(); num5 = binaryReader.ReadInt32(); for (int j = 0; j < num5; j++) { graphMeta.typeNames.Add(binaryReader.ReadString()); } return(graphMeta); }
private bool DeserializeExtraInfo(NavGraph graph) { int num = this.graphIndexInZip[graph]; ZipEntry entry = this.GetEntry("graph" + num + "_extra.binary"); if (entry == null) { return(false); } GraphSerializationContext ctx = new GraphSerializationContext(AstarSerializer.GetBinaryReader(entry), null, graph.graphIndex, this.meta); graph.DeserializeExtraInfo(ctx); return(true); }
private bool DeserializeExtraInfo(NavGraph graph) { int num = this.graphIndexInZip[graph]; ZipEntry zipEntry = this.zip["graph" + num + "_extra.binary"]; if (zipEntry == null) { return(false); } BinaryReader binaryReader = AstarSerializer.GetBinaryReader(zipEntry); GraphSerializationContext ctx = new GraphSerializationContext(binaryReader, null, graph.graphIndex); graph.DeserializeExtraInfo(ctx); return(true); }
private GraphNode[] DeserializeNodeReferenceMap() { ZipEntry entry = this.GetEntry("graph_references.binary"); if (entry == null) { throw new Exception("Node references not found in the data. Was this loaded from an older version of the A* Pathfinding Project?"); } BinaryReader reader = AstarSerializer.GetBinaryReader(entry); int num = reader.ReadInt32(); GraphNode[] int2Node = new GraphNode[num + 1]; try { Action <GraphNode> < > 9__0; for (int i = 0; i < this.graphs.Length; i++) { NavGraph navGraph = this.graphs[i]; Action <GraphNode> action; if ((action = < > 9__0) == null) { action = (< > 9__0 = delegate(GraphNode node) { int num2 = reader.ReadInt32(); int2Node[num2] = node; }); } navGraph.GetNodes(action); } } catch (Exception innerException) { throw new Exception("Some graph(s) has thrown an exception during GetNodes, or some graph(s) have deserialized more or fewer nodes than were serialized", innerException); } if (reader.BaseStream.Position != reader.BaseStream.Length) { throw new Exception(string.Concat(new object[] { reader.BaseStream.Length / 4L, " nodes were serialized, but only data for ", reader.BaseStream.Position / 4L, " nodes was found. The data looks corrupt." })); } reader.Close(); return(int2Node); }
private NavGraph DeserializeGraph(int zipIndex, int graphIndex) { Type graphType = this.meta.GetGraphType(zipIndex); if (object.Equals(graphType, null)) { return(null); } NavGraph navGraph = this.data.CreateGraph(graphType); navGraph.graphIndex = (uint)graphIndex; string name = "graph" + zipIndex + ".json"; string name2 = "graph" + zipIndex + ".binary"; if (this.ContainsEntry(name)) { TinyJsonDeserializer.Deserialize(AstarSerializer.GetString(this.GetEntry(name)), graphType, navGraph); } else { if (!this.ContainsEntry(name2)) { throw new FileNotFoundException(string.Concat(new object[] { "Could not find data for graph ", zipIndex, " in zip. Entry 'graph", zipIndex, ".json' does not exist" })); } BinaryReader binaryReader = AstarSerializer.GetBinaryReader(this.GetEntry(name2)); GraphSerializationContext ctx = new GraphSerializationContext(binaryReader, null, navGraph.graphIndex, this.meta); navGraph.DeserializeSettingsCompatibility(ctx); } if (navGraph.guid.ToString() != this.meta.guids[zipIndex]) { throw new Exception(string.Concat(new object[] { "Guid in graph file not equal to guid defined in meta file. Have you edited the data manually?\n", navGraph.guid, " != ", this.meta.guids[zipIndex] })); } return(navGraph); }
private void DeserializeNodeReferences(NavGraph graph, GraphNode[] int2Node) { int num = this.graphIndexInZip[graph]; ZipEntry entry = this.GetEntry("graph" + num + "_references.binary"); if (entry == null) { throw new Exception("Node references for graph " + num + " not found in the data. Was this loaded from an older version of the A* Pathfinding Project?"); } BinaryReader binaryReader = AstarSerializer.GetBinaryReader(entry); GraphSerializationContext ctx = new GraphSerializationContext(binaryReader, int2Node, graph.graphIndex, this.meta); graph.GetNodes(delegate(GraphNode node) { node.DeserializeReferences(ctx); }); }