public void Read(Stream input, Endian endian = Endian.Little) { RoadGraphRoadToJunctionEdgeMappingCount = input.ReadValueU16(endian); RoadGraphEdgeCount = input.ReadValueU16(endian); for (int i = 0; i < RoadGraphEdgeCount; i++) { RoadGraphEdges.Add(new Tuple <ushort, ushort>(input.ReadValueU16(endian), input.ReadValueU16(endian))); } ushort roadCount = input.ReadValueU16(endian); for (int i = 0; i < roadCount; i++) { var road = new RoadDefinitionDe(); road.Read(input, endian); Roads.Add(road); } for (int i = 0; i < RoadGraphEdgeCount; i++) { var costMapping = new CostMapEntryDe(); costMapping.Read(input, endian); CostMap.Add(costMapping); } byte magic0 = input.ReadValueU8(); byte magic1 = input.ReadValueU8(); byte magic2 = input.ReadValueU8(); byte magic3 = input.ReadValueU8(); if (magic0 != 0x11 && magic1 != 0x11 && magic2 != 0x11 && magic3 != 0) { throw new IOException($"Unexpected magic values ({magic0}, {magic1}, {magic2}, {magic3})"); } ushort splineCount = input.ReadValueU16(endian); for (int i = 0; i < splineCount; i++) { var spline = new RoadSplineDe(); spline.Read(input, endian); Splines.Add(spline); } for (int i = 0; i < roadCount * 2; i++) { RoadToCrossroadMapping.Add(input.ReadValueU16(endian)); } ushort crossroadCount = input.ReadValueU16(endian); for (int i = 0; i < crossroadCount; i++) { var crossroad = new CrossroadDe(); crossroad.Read(input, endian); Crossroads.Add(crossroad); } }
public void AddRoadEdge(ushort roadIndex) { RoadGraphEdges.Add((ushort)(roadIndex * 2 + 1)); EnsureMappingInitialized(); RoadGraphRoadToJunctionEdgeMapping[roadIndex * 2] = (ushort)(CostMap.Count - 1); RoadGraphRoadToJunctionEdgeMapping[roadIndex * 2 + 1] = (ushort)(CostMap.Count); RoadGraphRoadToJunctionEdgeMapping[RoadGraphRoadToJunctionEdgeMapping.Count - 1] = (ushort)(CostMap.Count + 1); }
public void AddCrossroadJunctionEdge(ushort targetRoadIndex) { RoadGraphEdges.Add(new Tuple <ushort, ushort>(GetLastRoadEdgeIndex(), (ushort)(targetRoadIndex * 2))); }
public void AddRoadEdge(ushort roadIndex) { RoadGraphEdges.Add(new Tuple <ushort, ushort>((ushort)(roadIndex * 2), (ushort)(roadIndex * 2 + 1))); RoadGraphRoadToJunctionEdgeMappingCount = (ushort)(GetLastRoadEdgeIndex() + 1); RoadGraphEdgeCount = (ushort)(RoadGraphEdges.Count + 1); }
public void AddCrossroadJunctionEdge(ushort targetRoadIndex) { RoadGraphEdges.Add((ushort)(targetRoadIndex * 2)); }