public void ExposeData() { Scribe_Values.Look <int>(ref mapId, "mapid", -1); if (map != null) { numCells = map.cellIndices.NumGridCells; } Scribe_Values.Look <int>(ref numCells, "numCells", 0); if (Scribe.mode == LoadSaveMode.Saving) { MapExposeUtility.ExposeUshort(map, (IntVec3 c) => priorityGrid[map.cellIndices.CellToIndex(c)], delegate(IntVec3 c, ushort val) { priorityGrid[map.cellIndices.CellToIndex(c)] = val; }, "priorityGrid"); } else if (Scribe.mode == LoadSaveMode.LoadingVars) { priorityGrid = new ushort[numCells]; DataExposeUtility.ByteArray(ref griddata, "priorityGrid"); DataSerializeUtility.LoadUshort(griddata, numCells, delegate(int c, ushort val) { priorityGrid[c] = val; }); griddata = null; } }
public void ExposeData() { Scribe_Collections.Look <WorldFeature>(ref this.features, "features", LookMode.Deep, new object[0]); if (Scribe.mode == LoadSaveMode.PostLoadInit) { WorldGrid grid = Find.WorldGrid; if (grid.tileFeature != null && grid.tileFeature.Length != 0) { DataSerializeUtility.LoadUshort(grid.tileFeature, grid.TilesCount, delegate(int i, ushort data) { grid[i].feature = ((data != ushort.MaxValue) ? this.GetFeatureWithID((int)data) : null); }); } this.textsCreated = false; } }
public void ExposeData() { Scribe_Collections.Look(ref features, "features", LookMode.Deep); if (Scribe.mode == LoadSaveMode.PostLoadInit) { WorldGrid grid = Find.WorldGrid; if (grid.tileFeature != null && grid.tileFeature.Length != 0) { DataSerializeUtility.LoadUshort(grid.tileFeature, grid.TilesCount, delegate(int i, ushort data) { grid[i].feature = ((data != 65535) ? GetFeatureWithID(data) : null); }); } textsCreated = false; } }
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 }); } } }