Ejemplo n.º 1
0
 public void ExposeData()
 {
     MapExposeUtility.ExposeUshort(map, (IntVec3 c) => SnowFloatToShort(GetDepth(c)), delegate(IntVec3 c, ushort val)
     {
         depthGrid[map.cellIndices.CellToIndex(c)] = SnowShortToFloat(val);
     }, "depthGrid");
 }
Ejemplo n.º 2
0
 public void ExposeData()
 {
     MapExposeUtility.ExposeUshort(map, (IntVec3 c) => (ushort)((roofGrid[map.cellIndices.CellToIndex(c)] != null) ? roofGrid[map.cellIndices.CellToIndex(c)].shortHash : 0), delegate(IntVec3 c, ushort val)
     {
         SetRoof(c, DefDatabase <RoofDef> .GetByShortHash(val));
     }, "roofs");
 }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
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 = delegate(IntVec3 c)
            {
                TerrainDef terrainDef2 = grid[this.map.cellIndices.CellToIndex(c)];
                return((ushort)((terrainDef2 != null) ? terrainDef2.shortHash : 0));
            };
            Action <IntVec3, ushort> shortWriter = delegate(IntVec3 c, ushort val)
            {
                TerrainDef terrainDef = terrainDefsByShortHash.TryGetValue(val);
                if (terrainDef == null && val != 0)
                {
                    Log.Error("Did not find terrain def with short hash " + val + " for cell " + c + ".");
                    terrainDef = TerrainDefOf.Sand;
                    terrainDefsByShortHash.Add(val, terrainDef);
                }
                grid[this.map.cellIndices.CellToIndex(c)] = terrainDef;
            };

            MapExposeUtility.ExposeUshort(this.map, shortReader, shortWriter, label);
        }
Ejemplo n.º 5
0
        private void ExposeTerrainGrid(TerrainDef[] grid, string label)
        {
            Dictionary <ushort, TerrainDef> terrainDefsByShortHash = new Dictionary <ushort, TerrainDef>();

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

            MapExposeUtility.ExposeUshort(this.map, shortReader, shortWriter, label);
        }
Ejemplo n.º 6
0
 public void ExposeData()
 {
     MapExposeUtility.ExposeUshort(this.map, (IntVec3 c) => this.roofGrid[this.map.cellIndices.CellToIndex(c)], delegate(IntVec3 c, ushort val)
     {
         this.SetRoof(c, DefDatabase <RoofDef> .GetByShortHash(val));
     }, "roofs");
 }
 public void ExposeData()
 {
     MapExposeUtility.ExposeUshort(this.map, (IntVec3 c) => this.defGrid[this.map.cellIndices.CellToIndex(c)], delegate(IntVec3 c, ushort val)
     {
         this.defGrid[this.map.cellIndices.CellToIndex(c)] = val;
     }, "defGrid");
     MapExposeUtility.ExposeUshort(this.map, (IntVec3 c) => this.countGrid[this.map.cellIndices.CellToIndex(c)], delegate(IntVec3 c, ushort val)
     {
         this.countGrid[this.map.cellIndices.CellToIndex(c)] = val;
     }, "countGrid");
 }