private void ExposeTerrainGrid(TerrainDef[] grid, string label) { Dictionary <ushort, TerrainDef> terrainDefsByShortHash = new Dictionary <ushort, TerrainDef>(); foreach (TerrainDef allDef in DefDatabase <TerrainDef> .AllDefs) { terrainDefsByShortHash.Add(allDef.shortHash, allDef); } MapExposeUtility.ExposeUshort(this.map, (Func <IntVec3, ushort>)(c => { TerrainDef terrainDef = grid[this.map.cellIndices.CellToIndex(c)]; if (terrainDef != null) { return(terrainDef.shortHash); } return(0); }), (Action <IntVec3, ushort>)((c, val) => { TerrainDef terrainDef1 = terrainDefsByShortHash.TryGetValue <ushort, TerrainDef>(val, (TerrainDef)null); if (terrainDef1 == null && val != (ushort)0) { TerrainDef terrainDef2 = BackCompatibility.BackCompatibleTerrainWithShortHash(val); if (terrainDef2 == null) { Log.Error("Did not find terrain def with short hash " + (object)val + " for cell " + (object)c + ".", false); terrainDef2 = TerrainDefOf.Soil; } terrainDef1 = terrainDef2; terrainDefsByShortHash.Add(val, terrainDef2); } grid[this.map.cellIndices.CellToIndex(c)] = terrainDef1; }), label); }