Exemple #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);
            }
            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);
        }
Exemple #2
0
        public override void ExposeData()
        {
            base.ExposeData();

            if (Scribe.mode == LoadSaveMode.LoadingVars)
            {
                walkGrid        = new float[map.cellIndices.NumGridCells];
                stoneGrid       = new float[map.cellIndices.NumGridCells];
                originalTerrain = new TerrainDef[map.cellIndices.NumGridCells];
            }

            MapExposeUtility.ExposeUshort(
                map, (cell) => (ushort)(walkGrid[map.cellIndices.CellToIndex(cell)] * 100),
                (cell, val) => walkGrid[map.cellIndices.CellToIndex(cell)] = val / 100f,
                "walkGrid");

            MapExposeUtility.ExposeUshort(
                map, (cell) => (ushort)(stoneGrid[map.cellIndices.CellToIndex(cell)] * 100),
                (cell, val) => stoneGrid[map.cellIndices.CellToIndex(cell)] = val / 100f,
                "stoneGrid");

            MapExposeUtility.ExposeUshort(
                map, (cell) => originalTerrain[map.cellIndices.CellToIndex(cell)]?.shortHash ?? 0,
                (cell, val) =>
            {
                if (val != 0 && terrainsByHash.TryGetValue(val, out TerrainDef terrain))
                {
                    originalTerrain[map.cellIndices.CellToIndex(cell)] = terrain;
                }
            }, "originalTerrain");
        }
        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 override void ExposeData()
        {
            base.ExposeData();

            MapExposeUtility.ExposeUshort(
                map,
                c => spotGrid[map.cellIndices.CellToIndex(c)],
                (c, id) => spotGrid[map.cellIndices.CellToIndex(c)] = id,
                "spotGrid");
            Scribe_Collections.Look(ref spotCells, "spotCells", LookMode.Value);
            Scribe_Values.Look(ref blockSizeX, "blockSizeX");
            Scribe_Values.Look(ref blockSizeZ, "blockSizeZ");
            Scribe_Values.Look(ref allSpotNum, "allSpotNum");
            Scribe_Values.Look(ref lastUpdateTick, "lastUpdateTick");

            if (!MizuDef.GlobalSettings.forDebug.enableResetHiddenWaterSpot)
            {
                return;
            }

            spotCells = new HashSet <IntVec3>();
            CreateWaterSpot(
                MizuDef.GlobalSettings.forDebug.resetHiddenWaterSpotBlockSizeX,
                MizuDef.GlobalSettings.forDebug.resetHiddenWaterSpotBlockSizeZ,
                MizuDef.GlobalSettings.forDebug.resetHiddenWaterSpotAllSpotNum);
        }
Exemple #5
0
 public override void ExposeData()
 {
     MapExposeUtility.ExposeUshort(this.map, (IntVec3 c) => MapComponent_GooGrid.GooFloatToShort(this.GetDepth(c)), delegate(IntVec3 c, ushort val)
     {
         this.depthGrid[this.map.cellIndices.CellToIndex(c)] = MapComponent_GooGrid.GoohortToFloat(val);
     }, "depthGrid");
     base.ExposeData();
 }
        public override void ExposeData()
        {
            MapExposeUtility.ExposeUshort(this.map, (IntVec3 c) => MapComponent_HiveGrid.HiveFloatToShort(this.GetDepth(c)), delegate(IntVec3 c, ushort val)
            {
                this.depthGrid[this.map.cellIndices.CellToIndex(c)] = MapComponent_HiveGrid.HiveShortToFloat(val);
            }, "depthGrid");


            if (Scribe.mode == LoadSaveMode.Saving)
            {
                this.HiveGuardlist.RemoveAll((Pawn x) => x.Destroyed);
                this.HiveWorkerlist.RemoveAll((Pawn x) => x.Destroyed);
                this.potentialHosts.RemoveAll((Pawn x) => x.Destroyed);
                this.nonpotentialHosts.RemoveAll((Pawn x) => x.Destroyed);
                this.Queenlist.RemoveAll((Pawn x) => x.Destroyed);
                this.Dronelist.RemoveAll((Pawn x) => x.Destroyed);
                this.Warriorlist.RemoveAll((Pawn x) => x.Destroyed);
                this.Runnerlist.RemoveAll((Pawn x) => x.Destroyed);
                this.Runnerlist.RemoveAll((Pawn x) => x.Destroyed);
                this.Thrumbomorphlist.RemoveAll((Pawn x) => x.Destroyed);
                this.Hivelist.RemoveAll((Thing x) => x.Destroyed);
                this.HiveChildlist.RemoveAll((Thing x) => x.Destroyed);
            }
            Scribe_Collections.Look <Pawn>(ref this.HiveGuardlist, "HiveGuardlist", LookMode.Reference, new object[0]);
            Scribe_Collections.Look <Pawn>(ref this.HiveWorkerlist, "HiveWorkerlist", LookMode.Reference, new object[0]);
            Scribe_Collections.Look <Pawn>(ref this.potentialHosts, "potentialHosts", LookMode.Reference, new object[0]);
            Scribe_Collections.Look <Pawn>(ref this.nonpotentialHosts, "nonpotentialHosts", LookMode.Reference, new object[0]);
            Scribe_Collections.Look <Pawn>(ref this.Queenlist, "Queenlist", LookMode.Reference, new object[0]);
            Scribe_Collections.Look <Pawn>(ref this.Dronelist, "Dronelist", LookMode.Reference, new object[0]);
            Scribe_Collections.Look <Pawn>(ref this.Warriorlist, "Warriorlist", LookMode.Reference, new object[0]);
            Scribe_Collections.Look <Pawn>(ref this.Runnerlist, "Runnerlist", LookMode.Reference, new object[0]);
            Scribe_Collections.Look <Pawn>(ref this.Predalienlist, "Predalienlist", LookMode.Reference, new object[0]);
            Scribe_Collections.Look <Pawn>(ref this.Thrumbomorphlist, "Thrumbomorphlist", LookMode.Reference, new object[0]);
            Scribe_Collections.Look <PotentialXenomorphHiveLocation>(ref this.PotentialHiveLoclist, "PotentialHiveLoclist", LookMode.Deep);
            Scribe_Collections.Look <Thing>(ref this.Hivelist, "Hivelist", LookMode.Reference, new object[0]);
            Scribe_Collections.Look <Thing>(ref this.HiveChildlist, "HiveChildlist", LookMode.Reference, new object[0]);
            if (Scribe.mode == LoadSaveMode.PostLoadInit)
            {
                this.HiveGuardlist.RemoveAll((Pawn x) => x == null);
                this.HiveWorkerlist.RemoveAll((Pawn x) => x == null);
                this.potentialHosts.RemoveAll((Pawn x) => x == null);
                this.nonpotentialHosts.RemoveAll((Pawn x) => x == null);
                this.Queenlist.RemoveAll((Pawn x) => x == null);
                this.Dronelist.RemoveAll((Pawn x) => x == null);
                this.Warriorlist.RemoveAll((Pawn x) => x == null);
                this.Runnerlist.RemoveAll((Pawn x) => x == null);
                this.Predalienlist.RemoveAll((Pawn x) => x == null);
                this.Thrumbomorphlist.RemoveAll((Pawn x) => x == null);
                this.Hivelist.RemoveAll((Thing x) => x == null);
                this.HiveChildlist.RemoveAll((Thing x) => x == null);
            }
            Scribe_Deep.Look <ThingOwner>(ref this.innerContainer, "innerContainer", new object[]
            {
                this
            });
            base.ExposeData();
        }
Exemple #7
0
 public void ExposeData()
 {
     MapExposeUtility.ExposeUshort(this.map,
                                   (IntVec3 c) => strengthGrid[this.map.cellIndices.CellToIndex(c)],
                                   delegate(IntVec3 c, ushort val)
     {
         strengthGrid[this.map.cellIndices.CellToIndex(c)] = val;
     }
                                   , "strengthGrid");
 }
        public override void ExposeData()
        {
            base.ExposeData();

            Scribe_Values.Look(ref this.elapsedTicks, "elapsedTicks");
            Scribe_Values.Look(ref this.randomIndex, "randomIndex");
            MapExposeUtility.ExposeUshort(this.map, (c) => this.wateringGrid[this.map.cellIndices.CellToIndex(c)], (c, val) =>
            {
                this.wateringGrid[this.map.cellIndices.CellToIndex(c)] = val;
            }, "wateringGrid");
        }
        public override void ExposeData()
        {
            base.ExposeData();

            MapExposeUtility.ExposeUshort(
                map,
                c => poolIDGrid[map.cellIndices.CellToIndex(c)],
                (c, id) => poolIDGrid[map.cellIndices.CellToIndex(c)] = id,
                "poolIDGrid");

            Scribe_Collections.Look(ref pools, "pools", LookMode.Deep, this);
        }
        public override void ExposeData()
        {
            base.ExposeData();

            MapExposeUtility.ExposeUshort(this.map, (c) => this.poolIDGrid[this.map.cellIndices.CellToIndex(c)], (c, id) =>
            {
                this.poolIDGrid[this.map.cellIndices.CellToIndex(c)] = id;
            }, "poolIDGrid");

            Scribe_Collections.Look <UndergroundWaterPool>(ref this.pools, "pools", LookMode.Deep, new object[]
            {
                this
            });
        }
 public override void ExposeData()
 {
     MapExposeUtility.ExposeUshort(this.map, (IntVec3 c) => MapComponent_HiveGrid.HiveFloatToShort(this.GetDepth(c)), delegate(IntVec3 c, ushort val)
     {
         this.depthGrid[this.map.cellIndices.CellToIndex(c)] = MapComponent_HiveGrid.HiveShortToFloat(val);
     }, "depthGrid");
     Scribe_Collections.Look <Pawn>(ref this.HiveGuardlist, "HiveGuardlist", LookMode.Reference, new object[0]);
     Scribe_Collections.Look <Pawn>(ref this.HiveWorkerlist, "HiveWorkerlist", LookMode.Reference, new object[0]);
     Scribe_Collections.Look <Pawn>(ref this.potentialHosts, "potentialHosts", LookMode.Reference, new object[0]);
     Scribe_Collections.Look <Pawn>(ref this.nonpotentialHosts, "nonpotentialHosts", LookMode.Reference, new object[0]);
     Scribe_Collections.Look <Pawn>(ref this.Queenlist, "Queenlist", LookMode.Reference, new object[0]);
     Scribe_Collections.Look <Pawn>(ref this.Dronelist, "Dronelist", LookMode.Reference, new object[0]);
     Scribe_Collections.Look <Pawn>(ref this.Warriorlist, "Warriorlist", LookMode.Reference, new object[0]);
     Scribe_Collections.Look <Pawn>(ref this.Runnerlist, "Runnerlist", LookMode.Reference, new object[0]);
     Scribe_Collections.Look <Pawn>(ref this.Predalienlist, "Predalienlist", LookMode.Reference, new object[0]);
     Scribe_Collections.Look <Pawn>(ref this.Thrumbomorphlist, "Thrumbomorphlist", LookMode.Reference, new object[0]);
     Scribe_Collections.Look <Thing>(ref this.Hivelist, "Hivelist", LookMode.Reference, new object[0]);
     Scribe_Collections.Look <Thing>(ref this.HiveChildlist, "HiveChildlist", LookMode.Reference, new object[0]);
     base.ExposeData();
 }