Пример #1
0
        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);
            }
            Func <IntVec3, ushort>   shortReader = (IntVec3 c) => grid[map.cellIndices.CellToIndex(c)]?.shortHash ?? 0;
            Action <IntVec3, ushort> shortWriter = delegate(IntVec3 c, ushort val)
            {
                TerrainDef terrainDef = terrainDefsByShortHash.TryGetValue(val);
                if (terrainDef == null && val != 0)
                {
                    TerrainDef terrainDef2 = BackCompatibility.BackCompatibleTerrainWithShortHash(val);
                    if (terrainDef2 == null)
                    {
                        Log.Error("Did not find terrain def with short hash " + val + " for cell " + c + ".");
                        terrainDef2 = TerrainDefOf.Soil;
                    }
                    terrainDef = terrainDef2;
                    terrainDefsByShortHash.Add(val, terrainDef2);
                }
                grid[map.cellIndices.CellToIndex(c)] = terrainDef;
            };

            MapExposeUtility.ExposeUshort(map, shortReader, shortWriter, label);
        }
Пример #2
0
        private void ExposeTerrainGrid(TerrainDef[] grid, string label)
        {
            Dictionary <ushort, TerrainDef> terrainDefsByShortHash = new Dictionary <ushort, TerrainDef>();

            foreach (TerrainDef terrainDef in DefDatabase <TerrainDef> .AllDefs)
            {
                terrainDefsByShortHash.Add(terrainDef.shortHash, terrainDef);
            }
            Func <IntVec3, ushort> shortReader = delegate(IntVec3 c)
            {
                TerrainDef terrainDef2 = grid[this.map.cellIndices.CellToIndex(c)];
                return((terrainDef2 == null) ? 0 : terrainDef2.shortHash);
            };
            Action <IntVec3, ushort> shortWriter = delegate(IntVec3 c, ushort val)
            {
                TerrainDef terrainDef2 = terrainDefsByShortHash.TryGetValue(val, null);
                if (terrainDef2 == null && val != 0)
                {
                    TerrainDef terrainDef3 = BackCompatibility.BackCompatibleTerrainWithShortHash(val);
                    if (terrainDef3 == null)
                    {
                        Log.Error(string.Concat(new object[]
                        {
                            "Did not find terrain def with short hash ",
                            val,
                            " for cell ",
                            c,
                            "."
                        }), false);
                        terrainDef3 = TerrainDefOf.Soil;
                    }
                    terrainDef2 = terrainDef3;
                    terrainDefsByShortHash.Add(val, terrainDef3);
                }
                grid[this.map.cellIndices.CellToIndex(c)] = terrainDef2;
            };

            MapExposeUtility.ExposeUshort(this.map, shortReader, shortWriter, label);
        }
Пример #3
0
            internal void <> m__1(IntVec3 c, ushort val)
            {
                TerrainDef terrainDef = this.terrainDefsByShortHash.TryGetValue(val, null);

                if (terrainDef == null && val != 0)
                {
                    TerrainDef terrainDef2 = BackCompatibility.BackCompatibleTerrainWithShortHash(val);
                    if (terrainDef2 == null)
                    {
                        Log.Error(string.Concat(new object[]
                        {
                            "Did not find terrain def with short hash ",
                            val,
                            " for cell ",
                            c,
                            "."
                        }), false);
                        terrainDef2 = TerrainDefOf.Soil;
                    }
                    terrainDef = terrainDef2;
                    this.terrainDefsByShortHash.Add(val, terrainDef2);
                }
                this.grid[this.$this.map.cellIndices.CellToIndex(c)] = terrainDef;
            }