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 TilesToRawData() { this.tileBiome = DataSerializeUtility.SerializeUshort(this.TilesCount, (int i) => this.tiles[i].biome.shortHash); this.tileElevation = DataSerializeUtility.SerializeUshort(this.TilesCount, (int i) => (ushort)Mathf.Clamp(Mathf.RoundToInt(((!this.tiles[i].WaterCovered) ? Mathf.Max(this.tiles[i].elevation, 1f) : this.tiles[i].elevation) + 8192f), 0, 65535)); this.tileHilliness = DataSerializeUtility.SerializeByte(this.TilesCount, (int i) => (byte)this.tiles[i].hilliness); this.tileTemperature = DataSerializeUtility.SerializeUshort(this.TilesCount, (int i) => (ushort)Mathf.Clamp(Mathf.RoundToInt((this.tiles[i].temperature + 300f) * 10f), 0, 65535)); this.tileRainfall = DataSerializeUtility.SerializeUshort(this.TilesCount, (int i) => (ushort)Mathf.Clamp(Mathf.RoundToInt(this.tiles[i].rainfall), 0, 65535)); this.tileSwampiness = DataSerializeUtility.SerializeByte(this.TilesCount, (int i) => (byte)Mathf.Clamp(Mathf.RoundToInt(this.tiles[i].swampiness * 255f), 0, 255)); this.tileFeature = DataSerializeUtility.SerializeUshort(this.TilesCount, (int i) => (this.tiles[i].feature != null) ? ((ushort)this.tiles[i].feature.uniqueID) : ushort.MaxValue); List <int> list = new List <int>(); List <byte> list2 = new List <byte>(); List <ushort> list3 = new List <ushort>(); for (int m = 0; m < this.TilesCount; m++) { List <Tile.RoadLink> potentialRoads = this.tiles[m].potentialRoads; if (potentialRoads != null) { for (int j = 0; j < potentialRoads.Count; j++) { Tile.RoadLink roadLink = potentialRoads[j]; if (roadLink.neighbor >= m) { byte b = (byte)this.GetNeighborId(m, roadLink.neighbor); if (b < 0) { Log.ErrorOnce("Couldn't find valid neighbor for road piece", 81637014, false); } else { list.Add(m); list2.Add(b); list3.Add(roadLink.road.shortHash); } } } } } this.tileRoadOrigins = DataSerializeUtility.SerializeInt(list.ToArray()); this.tileRoadAdjacency = DataSerializeUtility.SerializeByte(list2.ToArray()); this.tileRoadDef = DataSerializeUtility.SerializeUshort(list3.ToArray()); List <int> list4 = new List <int>(); List <byte> list5 = new List <byte>(); List <ushort> list6 = new List <ushort>(); for (int k = 0; k < this.TilesCount; k++) { List <Tile.RiverLink> potentialRivers = this.tiles[k].potentialRivers; if (potentialRivers != null) { for (int l = 0; l < potentialRivers.Count; l++) { Tile.RiverLink riverLink = potentialRivers[l]; if (riverLink.neighbor >= k) { byte b2 = (byte)this.GetNeighborId(k, riverLink.neighbor); if (b2 < 0) { Log.ErrorOnce("Couldn't find valid neighbor for river piece", 81637014, false); } else { list4.Add(k); list5.Add(b2); list6.Add(riverLink.river.shortHash); } } } } } this.tileRiverOrigins = DataSerializeUtility.SerializeInt(list4.ToArray()); this.tileRiverAdjacency = DataSerializeUtility.SerializeByte(list5.ToArray()); this.tileRiverDef = DataSerializeUtility.SerializeUshort(list6.ToArray()); }