public override void ExposeData() { byte[] arr = null; if (Scribe.mode == LoadSaveMode.Saving) { if (priorityGrid == null || priorityGrid.Length != map.cellIndices.NumGridCells) { Log.Error("PriorityMapGrid : Invalid priorityGrid. fixing.."); InitGrid(); } arr = DataSerializeUtility.SerializeInt(priorityGrid); } DataExposeUtility.ByteArray(ref arr, "priorityGrid"); if (Scribe.mode == LoadSaveMode.LoadingVars) { priorityGrid = DataSerializeUtility.DeserializeInt(arr); } }
private void RawDataToTiles() { if (this.tiles.Count != this.TilesCount) { this.tiles.Clear(); for (int m = 0; m < this.TilesCount; m++) { this.tiles.Add(new Tile()); } } else { for (int j = 0; j < this.TilesCount; j++) { this.tiles[j].potentialRoads = null; this.tiles[j].potentialRivers = null; } } DataSerializeUtility.LoadUshort(this.tileBiome, this.TilesCount, delegate(int i, ushort data) { this.tiles[i].biome = (DefDatabase <BiomeDef> .GetByShortHash(data) ?? BiomeDefOf.TemperateForest); }); DataSerializeUtility.LoadUshort(this.tileElevation, this.TilesCount, delegate(int i, ushort data) { this.tiles[i].elevation = (float)(data - 8192); }); DataSerializeUtility.LoadByte(this.tileHilliness, this.TilesCount, delegate(int i, byte data) { this.tiles[i].hilliness = (Hilliness)data; }); DataSerializeUtility.LoadUshort(this.tileTemperature, this.TilesCount, delegate(int i, ushort data) { this.tiles[i].temperature = (float)data / 10f - 300f; }); DataSerializeUtility.LoadUshort(this.tileRainfall, this.TilesCount, delegate(int i, ushort data) { this.tiles[i].rainfall = (float)data; }); DataSerializeUtility.LoadByte(this.tileSwampiness, this.TilesCount, delegate(int i, byte data) { this.tiles[i].swampiness = (float)data / 255f; }); int[] array = DataSerializeUtility.DeserializeInt(this.tileRoadOrigins); byte[] array2 = DataSerializeUtility.DeserializeByte(this.tileRoadAdjacency); ushort[] array3 = DataSerializeUtility.DeserializeUshort(this.tileRoadDef); for (int k = 0; k < array.Length; k++) { int num = array[k]; int tileNeighbor = this.GetTileNeighbor(num, (int)array2[k]); RoadDef byShortHash = DefDatabase <RoadDef> .GetByShortHash(array3[k]); if (byShortHash != null) { if (this.tiles[num].potentialRoads == null) { this.tiles[num].potentialRoads = new List <Tile.RoadLink>(); } if (this.tiles[tileNeighbor].potentialRoads == null) { this.tiles[tileNeighbor].potentialRoads = new List <Tile.RoadLink>(); } this.tiles[num].potentialRoads.Add(new Tile.RoadLink { neighbor = tileNeighbor, road = byShortHash }); this.tiles[tileNeighbor].potentialRoads.Add(new Tile.RoadLink { neighbor = num, road = byShortHash }); } } int[] array4 = DataSerializeUtility.DeserializeInt(this.tileRiverOrigins); byte[] array5 = DataSerializeUtility.DeserializeByte(this.tileRiverAdjacency); ushort[] array6 = DataSerializeUtility.DeserializeUshort(this.tileRiverDef); for (int l = 0; l < array4.Length; l++) { int num2 = array4[l]; int tileNeighbor2 = this.GetTileNeighbor(num2, (int)array5[l]); RiverDef byShortHash2 = DefDatabase <RiverDef> .GetByShortHash(array6[l]); if (byShortHash2 != null) { if (this.tiles[num2].potentialRivers == null) { this.tiles[num2].potentialRivers = new List <Tile.RiverLink>(); } if (this.tiles[tileNeighbor2].potentialRivers == null) { this.tiles[tileNeighbor2].potentialRivers = new List <Tile.RiverLink>(); } this.tiles[num2].potentialRivers.Add(new Tile.RiverLink { neighbor = tileNeighbor2, river = byShortHash2 }); this.tiles[tileNeighbor2].potentialRivers.Add(new Tile.RiverLink { neighbor = num2, river = byShortHash2 }); } } }