Example #1
0
        public static float GetBiomeFishSpawnRateFactor(Map map)
        {
            float biomeFactor = 1f;

            if (map.Biome == BiomeDefOf.BorealForest)
            {
                biomeFactor = 1.2f;
            }
            else if ((map.Biome == BiomeDefOf.Tundra) ||
                     (map.Biome == BiomeDefOf.AridShrubland))
            {
                biomeFactor = 1.4f;
            }
            else if ((map.Biome == BiomeDefOf.IceSheet) ||
                     (map.Biome == BiomeDefOf.Desert))
            {
                biomeFactor = 1.6f;
            }
            else if ((map.Biome == BiomeDefOf.SeaIce) ||
                     (map.Biome == BiomeDef.Named("ExtremeDesert")))
            {
                biomeFactor = 1.8f;
            }
            return(biomeFactor);
        }
Example #2
0
 public void ApplyInjuriesOrIllnessToTeam(Map map, List <Pawn> teamPawns)
 {
     if ((map.Biome == BiomeDefOf.TropicalRainforest) ||
         (map.Biome == BiomeDef.Named("TropicalSwamp")))
     {
         // Apply malaria/sleeping sickness to all team pawns in tropical or swamp biomes.
         HediffDef illness = null;
         if (Rand.Value < 0.5f)
         {
             illness = HediffDef.Named("SleepingSickness");
         }
         else
         {
             illness = HediffDefOf.Malaria;
         }
         foreach (Pawn pawn in teamPawns)
         {
             pawn.health.AddHediff(illness);
         }
     }
     else
     {
         // Randomly damage some pawns.
         int injuredPawnsNumber = Mathf.RoundToInt(Rand.Range(0.25f, 0.5f) * teamPawns.Count);
         injuredPawnsNumber = Mathf.Clamp(injuredPawnsNumber, 1, teamPawns.Count - 1);
         for (int pawnIndex = 0; pawnIndex < injuredPawnsNumber; pawnIndex++)
         {
             Expedition.RandomlyDamagePawn(teamPawns[pawnIndex], Rand.Range(1, 2), Rand.Range(12, 20));
         }
     }
 }
Example #3
0
        public static float GetBiomeMaxFishStockFactor(BiomeDef biome)
        {
            float biomeFactor = 1f;

            if (biome == BiomeDefOf.BorealForest)
            {
                biomeFactor = 0.8f;
            }
            else if ((biome == BiomeDefOf.Tundra) ||
                     (biome == BiomeDefOf.AridShrubland))
            {
                biomeFactor = 0.6f;
            }
            else if ((biome == BiomeDefOf.SeaIce) ||
                     (biome == BiomeDefOf.Desert))
            {
                biomeFactor = 0.4f;
            }
            else if ((biome == BiomeDefOf.IceSheet) ||
                     (biome == BiomeDef.Named("ExtremeDesert")))
            {
                biomeFactor = 0.2f;
            }
            return(biomeFactor);
        }
 public static int RandomSettlementTileFor_WoodElves(Faction faction, bool mustBeAutoChoosable = false)
 {
     for (int i = 0; i < 500; i++)
     {
         int num;
         if ((from _ in Enumerable.Range(0, 100)
              select Rand.Range(0, Find.WorldGrid.TilesCount)).TryRandomElementByWeight(delegate(int x)
         {
             Tile tile = Find.WorldGrid[x];
             if (!tile.biome.canBuildBase || tile.hilliness == Hilliness.Impassable)
             {
                 return(0f);
             }
             if (tile.biome == BiomeDef.Named("LotRE_MallornForest"))
             {
                 return(1000f);
             }
             return(0f);     //tile.biome.settlementSelectionWeight;
         }, out num))
         {
             if (TileFinder.IsValidTileForNewSettlement(num, null))
             {
                 return(num);
             }
         }
     }
     Log.Error("Failed to find faction base tile for " + faction);
     return(0);
 }
        public void SpreadPurityFromPoint(int start)
        {
            HashSet <int> toConvert = new HashSet <int>();
            HashSet <int> neighbors = new HashSet <int>();

            toConvert.Add(start);

            List <int> tmpTiles = new List <int>();

            for (int i = 0; i <= 12; i++)
            {
                foreach (int t in toConvert)
                {
                    Find.WorldGrid.GetTileNeighbors(t, tmpTiles);
                    //neighbors.UnionWith(tmpTiles);
                    //neighbors.Add(tmpTiles.RandomElement());

                    neighbors.AddRange(tmpTiles.TakeRandom(2));
                }

                toConvert.UnionWith(neighbors);
            }

            foreach (int t in toConvert)
            {
                Tile tile = Find.WorldGrid[t];
                tile.biome = BiomeDef.Named(cache[t].originalBiome);
                PurifyTile(t);
            }
        }
Example #6
0
        public static ZoneType GetRandomZoneTypeExteriorZone(OG_OutpostData outpostData)
        {
            List <ZoneTypeWithWeight> exteriorZonesList = new List <ZoneTypeWithWeight>();

            if (outpostData.isMilitary)
            {
                exteriorZonesList.Add(new ZoneTypeWithWeight(ZoneType.WaterPool, 5f));
                exteriorZonesList.Add(new ZoneTypeWithWeight(ZoneType.Cemetery, 4f));
                exteriorZonesList.Add(new ZoneTypeWithWeight(ZoneType.ExteriorRecRoom, 2f));
                exteriorZonesList.Add(new ZoneTypeWithWeight(ZoneType.ShootingRange, 7f));
                exteriorZonesList.Add(new ZoneTypeWithWeight(ZoneType.MortarBay, 5f));
                exteriorZonesList.Add(new ZoneTypeWithWeight(ZoneType.Empty, 2f));
            }
            else
            {
                exteriorZonesList.Add(new ZoneTypeWithWeight(ZoneType.WaterPool, 4f));
                if ((Find.Map.Biome != BiomeDef.Named("ExtremeDesert")) &&
                    (Find.Map.Biome != BiomeDef.Named("IceSheet")))
                {
                    exteriorZonesList.Add(new ZoneTypeWithWeight(ZoneType.Farm, 5f));
                }
                exteriorZonesList.Add(new ZoneTypeWithWeight(ZoneType.Cemetery, 3f));
                exteriorZonesList.Add(new ZoneTypeWithWeight(ZoneType.ExteriorRecRoom, 5f));
                exteriorZonesList.Add(new ZoneTypeWithWeight(ZoneType.ShootingRange, 1f));
                exteriorZonesList.Add(new ZoneTypeWithWeight(ZoneType.MortarBay, 1f));
                exteriorZonesList.Add(new ZoneTypeWithWeight(ZoneType.Empty, 1f));
            }

            ZoneType exteriorZoneType = GetRandomZoneTypeByWeight(exteriorZonesList);

            return(exteriorZoneType);
        }
Example #7
0
 private static void EditAnimalDefs()
 {
     foreach (PawnKindDef current in DefDatabase <PawnKindDef> .AllDefs)
     {
         if (current.RaceProps.wildBiomes != null && current.defName != "Cobra")
         {
             for (int j = 0; j < current.RaceProps.wildBiomes.Count; j++)
             {
                 if (current.RaceProps.wildBiomes[j].biome.defName == "Tundra")
                 {
                     AnimalBiomeRecord newRecord = new AnimalBiomeRecord();
                     newRecord.biome       = BiomeDef.Named("RRP_Permafrost");
                     newRecord.commonality = current.RaceProps.wildBiomes[j].commonality / 2;
                     current.RaceProps.wildBiomes.Add(newRecord);
                 }
                 if (current.RaceProps.wildBiomes[j].biome.defName == "TemperateForest")
                 {
                     AnimalBiomeRecord newRecord = new AnimalBiomeRecord();
                     newRecord.biome       = BiomeDef.Named("RRP_Grassland");
                     newRecord.commonality = current.RaceProps.wildBiomes[j].commonality / 2;
                     current.RaceProps.wildBiomes.Add(newRecord);
                 }
                 if (current.RaceProps.wildBiomes[j].biome.defName == "BorealForest")
                 {
                     AnimalBiomeRecord newRecord = new AnimalBiomeRecord();
                     newRecord.biome       = BiomeDef.Named("RRP_Steppes");
                     newRecord.commonality = current.RaceProps.wildBiomes[j].commonality / 2;
                     current.RaceProps.wildBiomes.Add(newRecord);
                 }
                 if (current.RaceProps.wildBiomes[j].biome.defName == "AridShrubland")
                 {
                     AnimalBiomeRecord newRecord = new AnimalBiomeRecord();
                     newRecord.biome       = BiomeDef.Named("RRP_Savanna");
                     newRecord.commonality = current.RaceProps.wildBiomes[j].commonality / 2;
                     current.RaceProps.wildBiomes.Add(newRecord);
                 }
                 if (current.RaceProps.wildBiomes[j].biome.defName == "Desert")
                 {
                     AnimalBiomeRecord newRecord = new AnimalBiomeRecord();
                     newRecord.biome       = BiomeDef.Named("RRP_TemperateDesert");
                     newRecord.commonality = current.RaceProps.wildBiomes[j].commonality / 2;
                     current.RaceProps.wildBiomes.Add(newRecord);
                     AnimalBiomeRecord newRecord2 = new AnimalBiomeRecord();
                     newRecord2.biome       = BiomeDef.Named("RRP_Oasis");
                     newRecord2.commonality = current.RaceProps.wildBiomes[j].commonality;
                     current.RaceProps.wildBiomes.Add(newRecord2);
                 }
             }
         }
     }
 }
        public static int RandomSettlementTileFor_Townsfolk(Faction faction, bool mustBeAutoChoosable = false)
        {
            for (var i = 0; i < 500; i++)
            {
                if (!(from _ in Enumerable.Range(0, 100)
                      select Rand.Range(0, Find.WorldGrid.TilesCount)).TryRandomElementByWeight(delegate(int x)
                {
                    var tile = Find.WorldGrid[x];
                    if (!tile.biome.canBuildBase || tile.hilliness == Hilliness.Impassable)
                    {
                        return(0f);
                    }

                    var neighbors = new List <int>();
                    Find.WorldGrid.GetTileNeighbors(x, neighbors);
                    //Log.Message("Neighbors " + neighbors.Count.ToString());
                    if (neighbors.Count <= 0)
                    {
                        return(tile.biome.settlementSelectionWeight);
                    }

                    foreach (var y in neighbors)
                    {
                        var tile2 = Find.WorldGrid[y];
                        if (tile2.biome == BiomeDefOf.IceSheet || tile2.biome == BiomeDef.Named("SeaIce"))
                        {
                            return(0f);
                        }

                        if (tile2.WaterCovered)
                        {
                            return(1000f);
                        }
                    }

                    return(tile.biome.settlementSelectionWeight);
                }, out var num))
                {
                    continue;
                }

                if (TileFinder.IsValidTileForNewSettlement(num))
                {
                    return(num);
                }
            }

            Log.Error("Failed to find faction base tile for " + faction);
            return(0);
        }
        /// <summary>
        /// Update the max fishing stock according to terrain and biome (to avoid exploits due to terrain changes).
        /// </summary>
        public void UpdateMaxFishStock()
        {
            int maxFishStockTerrain = maxFishStockDefault;

            // Compute max fish stock according to surrounding aquatic cells.
            float aquaticCellsNumber = 0;

            foreach (IntVec3 cell in GenRadial.RadialCellsAround(this.Position, this.def.specialDisplayRadius, true))
            {
                if (cell.InBounds(this.Map) == false)
                {
                    continue;
                }
                if (Util_FishIndustry.IsAquaticTerrain(this.Map, cell))
                {
                    aquaticCellsNumber++;
                }
            }
            float aquaticCellsNumberThreshold = (float)(GenRadial.NumCellsInRadius(this.def.specialDisplayRadius)) / 2f;

            if (aquaticCellsNumber < aquaticCellsNumberThreshold)
            {
                maxFishStockTerrain = Mathf.CeilToInt((float)maxFishStockDefault * (aquaticCellsNumber / aquaticCellsNumberThreshold));
            }

            // Compute max fish stock according to biome.
            int maxFishStockBiome = maxFishStockDefault;

            if ((this.Map.Biome == BiomeDef.Named("AridShrubland")) ||
                (this.Map.Biome == BiomeDef.Named("Tundra")))
            {
                maxFishStockBiome = 3;
            }
            else if ((this.Map.Biome == BiomeDef.Named("IceSheet")) ||
                     (this.Map.Biome == BiomeDef.Named("Desert")))
            {
                maxFishStockBiome = 2;
            }
            else if ((this.Map.Biome == BiomeDef.Named("SeaIce")) ||
                     (this.Map.Biome == BiomeDef.Named("ExtremeDesert")))
            {
                maxFishStockBiome = 1;
            }
            this.maxFishStock = Math.Min(maxFishStockTerrain, maxFishStockBiome);
            if (this.maxFishStock < 1)
            {
                this.maxFishStock = 1;
            }
        }
Example #10
0
 public static void ClearAlienBiomesOuterTheSources()
 {
     for (int i = PurpleIvyData.TotalPollutedBiomes.Count - 1; i >= 0; i--)
     {
         int tile = PurpleIvyData.TotalPollutedBiomes[i];
         if (PurpleIvyUtils.TileInRadiusOfInfectedSites(tile) != true)
         {
             Log.Message("Return old biome: " + tile.ToString());
             BiomeDef origBiome = Find.WorldGrid[tile].biome;
             BiomeDef newBiome  = BiomeDef.Named(origBiome.defName.ReplaceFirst("PI_", string.Empty));
             Find.WorldGrid[tile].biome = newBiome;
             PurpleIvyData.TotalPollutedBiomes.Remove(tile);
             PurpleIvyData.BiomesToRenderNow.Add(tile);
         }
     }
 }
Example #11
0
            private static void Postfix()
            {
                var settlements = Find.WorldObjects.SettlementBases;

                foreach (var settlement in settlements)
                {
                    Log.Message(settlement.Faction.def.defName + " owns tile " + settlement.Tile + " with biome " +
                                Find.WorldGrid[settlement.Tile].biome.defName);
                    if (settlement.Faction.def.defName != "Horrors")
                    {
                        continue;
                    }

                    var settlementTile = Find.WorldGrid[settlement.Tile];
                    settlementTile.biome = BiomeDef.Named("HorrorWastes");
                }
            }
Example #12
0
        public override void Generate(Map map)
        {
            Terrain.baseGenstep.Generate(map);
            if (!Find.World.grid[map.Tile].biome.Equals(BiomeDef.Named("Caves")))
            {
                return;
            }
            TerrainGrid terrainGrid = map.terrainGrid;
            IntVec3     arg_4A_0    = map.Size;
            IntVec3     arg_55_0    = map.Size;

            foreach (IntVec3 current in map.AllCells)
            {
                if (RocksFromGrid.RiverMap[current.x, current.z] == 1)
                {
                    terrainGrid.SetTerrain(current, TerrainDefOf.WaterDeep);
                }
            }
            generateBridge = false;
            foreach (IntVec3 current in map.AllCells)
            {
                if (RocksFromGrid.RiverMap[current.x, current.z] == 1 && Rand.Value > 0.8)
                {
                    generateBridge = true;
                    GenerateBridge(new IntVec3[] { current }, map);
                }
            }
            ModuleBase moduleBase = new Perlin(0.021999999716877937, 2.0, 0.5, 6, Rand.Range(0, 2147483647), QualityMode.High);

            int[,] ravineGrid = MapGen.GenRiver(map.Size.x, map.Size.z, moduleBase);
            foreach (IntVec3 current in map.AllCells)
            {
                if (ravineGrid[current.x, current.z] == 1)
                {
                    map.thingGrid.ThingsAt(current).ToList().ForEach((Thing t) => t.Destroy());
                    map.roofGrid.SetRoof(current, null);
                }
            }
            GenerateOpening(MapGenerator.PlayerStartSpot, map);
        }
Example #13
0
        /// <summary>
        /// Compute the max fishing stock and fish respawn rate according to terrain and biome (to avoid exploits due to terrain changes).
        /// </summary>
        public void ComputeMaxFishStockAndRespawnPeriod()
        {
            // Compute max fish stock according to biome.
            this.maxFishStock = maxFishStockDefault;
            if (this.Map.Biome == BiomeDefOf.BorealForest)
            {
                this.maxFishStock = 4;
            }
            else if ((this.Map.Biome == BiomeDefOf.Tundra) ||
                     (this.Map.Biome == BiomeDefOf.AridShrubland))
            {
                this.maxFishStock = 3;
            }
            else if ((this.Map.Biome == BiomeDefOf.IceSheet) ||
                     (this.Map.Biome == BiomeDefOf.Desert))
            {
                this.maxFishStock = 2;
            }
            else if ((this.Map.Biome == BiomeDefOf.SeaIce) ||
                     (this.Map.Biome == BiomeDef.Named("ExtremeDesert")))
            {
                this.maxFishStock = 1;
            }

            // Compute fish stock respawn period factor according  to surrounding aquatic cells.
            float aquaticCellsProportion = Util_FishIndustry.GetAquaticCellsProportionInRadius(this.Position, this.Map, Building_FishingPier.optimalAquaticAreaRadius);
            float fishRespawnFactor      = 1f;

            if (aquaticCellsProportion < optimalAquaticCellsProportion)
            {
                fishRespawnFactor = (aquaticCellsProportion / optimalAquaticCellsProportion);
            }
            if (fishRespawnFactor <= 0)
            {
                // Avoid division by 0.
                fishRespawnFactor = 0.05f;
            }

            this.fishStockRespawnInterval = Mathf.CeilToInt((2f * GenDate.TicksPerDay) / ((float)this.maxFishStock * fishRespawnFactor));
        }
Example #14
0
 public static void Postfix(int tileID, ref Tile __result)
 {
     if (__result.biome.defName.Contains("Archipelago"))
     {
         if (Rand.Value > 0.03f)
         {
             __result.biome = BiomeDef.Named("Ocean");
         }
         else
         {
             __result.elevation += 100;
             if (Rand.Value < 0.33f)
             {
                 __result.hilliness = Hilliness.SmallHills;
                 if (Rand.Value < 0.25f)
                 {
                     __result.hilliness = Hilliness.LargeHills;
                 }
             }
         }
     }
 }
Example #15
0
 static RPF_Initializer()
 {
     foreach (ThingDef current in DefDatabase <ThingDef> .AllDefsListForReading)
     {
         if (current.plant != null)
         {
             if (current.plant.wildBiomes != null)
             {
                 for (int j = 0; j < current.plant.wildBiomes.Count; j++)
                 {
                     if (current.plant.wildBiomes[j].biome.defName == "Tundra")
                     {
                         PlantBiomeRecord newRecord = new PlantBiomeRecord();
                         newRecord.biome       = BiomeDef.Named("Permafrost");
                         newRecord.commonality = current.plant.wildBiomes[j].commonality / 2;
                         current.plant.wildBiomes.Add(newRecord);
                     }
                 }
             }
         }
     }
     foreach (PawnKindDef current in DefDatabase <PawnKindDef> .AllDefs)
     {
         if (current.RaceProps.wildBiomes != null)
         {
             for (int j = 0; j < current.RaceProps.wildBiomes.Count; j++)
             {
                 if (current.RaceProps.wildBiomes[j].biome.defName == "Tundra")
                 {
                     AnimalBiomeRecord newRecord = new AnimalBiomeRecord();
                     newRecord.biome       = BiomeDef.Named("Permafrost");
                     newRecord.commonality = current.RaceProps.wildBiomes[j].commonality / 2;
                     current.RaceProps.wildBiomes.Add(newRecord);
                 }
             }
         }
     }
 }
Example #16
0
        public override void Generate(Map map)
        {
            Log.Message("hey2");
            if (!Find.World.grid[map.Tile].biome.Equals(BiomeDef.Named("Caves")))
            {
                RocksFromGrid.baseGenstep.Generate(map);
                return;
            }
            MapGenFloatGrid elevation = MapGenerator.Elevation;
            int             x         = map.Size.x;
            int             z         = map.Size.z;

            int[,] array           = MapGen.GenMap(x, z, 5, 0.5);
            RocksFromGrid.RiverMap = MapGen.GenRiver(x, z, null);
            foreach (IntVec3 current in map.AllCells)
            {
                if (array[current.x, current.z] == 1 && RocksFromGrid.RiverMap[current.x, current.z] == 0)
                {
                    GenSpawn.Spawn(GenStep_RocksFromGrid.RockDefAt(current), current, map);
                }
                map.roofGrid.SetRoof(current, RoofDefOf.RoofRockThick);
            }
        }
        public void fillRadius(bool forced = false)
        {
            int newRadius = this.GetRadius();

            if (this.radius != newRadius || forced == true)
            {
                //PurpleIvyData.BiomesToRenderNow = new List<int>();
                this.radius = newRadius;
                List <int> tiles = new List <int>();
                PurpleIvyData.BiomesDirty = true;
                if (this.radius < newRadius)
                {
                    PurpleIvyData.BiomesToClear = true;
                }
                Find.WorldFloodFiller.FloodFill(this.infectedTile, (int tile) => true, delegate(int tile, int dist)
                {
                    if (dist > this.radius)
                    {
                        return(true);
                    }
                    tiles.Add(tile);
                    return(false);
                }, int.MaxValue, null);
                foreach (int tile in tiles)
                {
                    BiomeDef origBiome = Find.WorldGrid[tile].biome;
                    if (!origBiome.defName.StartsWith("PI_"))
                    {
                        Log.Message("Change biome: " + tile.ToString());
                        BiomeDef infectedBiome = BiomeDef.Named("PI_" + origBiome.defName);
                        Find.WorldGrid[tile].biome = infectedBiome;
                        PurpleIvyData.TotalPollutedBiomes.Add(tile);
                        PurpleIvyData.BiomesToRenderNow.Add(tile);
                    }
                }
            }
        }
        // adapted from RF-Archipelagos
        private static void AddPlantsWildBiomes()
        {
            foreach (ThingDef current in DefDatabase <ThingDef> .AllDefsListForReading)
            {
                if (current.plant?.wildBiomes != null)
                {
                    // to check if it's in any of these biomes already
                    if (!current.plant.wildBiomes.Any(w => w.biome.defName.Contains("ZBiome")))
                    {
                        //Sandbar
                        if (current.plant.wildBiomes.Any(b => b.biome.defName == "ExtremeDesert"))
                        {
                            PlantBiomeRecord newRecord1 = new PlantBiomeRecord();
                            newRecord1.biome       = BiomeDef.Named("ZBiome_Sandbar_NoBeach");
                            newRecord1.commonality = current.plant.wildBiomes.Where(bi => bi.biome.defName == "ExtremeDesert").FirstOrDefault().commonality;
                            current.plant.wildBiomes.Add(newRecord1);
                        }
                        else if (current.plant.wildBiomes.Any(b => b.biome.defName == "Desert"))
                        {
                            PlantBiomeRecord newRecord1 = new PlantBiomeRecord();
                            newRecord1.biome       = BiomeDef.Named("ZBiome_Sandbar_NoBeach");
                            newRecord1.commonality = current.plant.wildBiomes.Where(bi => bi.biome.defName == "Desert").FirstOrDefault().commonality;
                            current.plant.wildBiomes.Add(newRecord1);
                        }

                        else if (current.plant.wildBiomes.Any(b => b.biome.defName == "Tundra"))
                        {
                            PlantBiomeRecord newRecord1 = new PlantBiomeRecord();
                            newRecord1.biome       = BiomeDef.Named("ZBiome_GlacialShield");
                            newRecord1.commonality = current.plant.wildBiomes.Where(bi => bi.biome.defName == "Tundra").FirstOrDefault().commonality;
                            if (current.plant.IsTree)
                            {
                                newRecord1.commonality *= 1.7f;
                            }
                            if (current.plant.purpose == PlantPurpose.Beauty || current.plant.purpose == PlantPurpose.Food)
                            {
                                newRecord1.commonality *= 1.2f;
                            }


                            current.plant.wildBiomes.Add(newRecord1);
                        }


                        for (int j = 0; j < current.plant.wildBiomes.Count; j++)
                        {
                            // icebergs
                            if (current.plant.wildBiomes[j].biome.defName == "SeaIce")
                            {
                                PlantBiomeRecord newRecord1 = new PlantBiomeRecord();
                                newRecord1.biome       = BiomeDef.Named("ZBiome_Iceberg_NoBeach");
                                newRecord1.commonality = current.plant.wildBiomes[j].commonality;
                                current.plant.wildBiomes.Add(newRecord1);
                            }

                            //Meadow
                            if (current.plant.wildBiomes[j].biome.defName == "BorealForest")
                            {
                                PlantBiomeRecord newRecord1 = new PlantBiomeRecord();
                                newRecord1.biome       = BiomeDef.Named("ZBiome_AlpineMeadow");
                                newRecord1.commonality = current.plant.wildBiomes[j].commonality;
                                if (current.plant.IsTree)
                                {
                                    newRecord1.commonality *= 0.4f;
                                }
                                else if (current.plant.purpose == PlantPurpose.Beauty)
                                {
                                    newRecord1.commonality *= 2f;
                                }
                                current.plant.wildBiomes.Add(newRecord1);
                            }

                            // Grasslands
                            if (current.plant.wildBiomes[j].biome.defName == "AridShrubland")
                            {
                                PlantBiomeRecord newRecord1 = new PlantBiomeRecord();
                                newRecord1.biome       = BiomeDef.Named("ZBiome_Grasslands");
                                newRecord1.commonality = current.plant.wildBiomes[j].commonality;
                                if (current.plant.IsTree)
                                {
                                    newRecord1.commonality *= 0.4f;
                                }
                                current.plant.wildBiomes.Add(newRecord1);
                            }

                            // Dunes and Oasis
                            if (current.plant.wildBiomes[j].biome.defName == "AridShrubland")
                            {
                                if (current.plant.purpose == PlantPurpose.Food)
                                {
                                    PlantBiomeRecord newRecord1 = new PlantBiomeRecord();
                                    newRecord1.biome       = BiomeDef.Named("ZBiome_CoastalDunes");
                                    newRecord1.commonality = current.plant.wildBiomes[j].commonality;
                                    current.plant.wildBiomes.Add(newRecord1);

                                    PlantBiomeRecord newRecord2 = new PlantBiomeRecord();
                                    newRecord2.biome       = BiomeDef.Named("ZBiome_DesertOasis");
                                    newRecord2.commonality = current.plant.wildBiomes[j].commonality;
                                    current.plant.wildBiomes.Add(newRecord2);
                                }
                            }

                            if (current.plant.wildBiomes[j].biome.defName == "TropicalRainforest")
                            {
                                if (current.plant.purpose != PlantPurpose.Food)
                                {
                                    PlantBiomeRecord newRecord1 = new PlantBiomeRecord();
                                    newRecord1.biome       = BiomeDef.Named("ZBiome_CoastalDunes");
                                    newRecord1.commonality = current.plant.wildBiomes[j].commonality;
                                    current.plant.wildBiomes.Add(newRecord1);

                                    PlantBiomeRecord newRecord2 = new PlantBiomeRecord();
                                    newRecord2.biome       = BiomeDef.Named("ZBiome_DesertOasis");
                                    newRecord2.commonality = current.plant.wildBiomes[j].commonality;
                                    current.plant.wildBiomes.Add(newRecord2);
                                }

                                if (!current.plant.IsTree)
                                {
                                    PlantBiomeRecord newRecord1 = new PlantBiomeRecord();
                                    newRecord1.biome       = BiomeDef.Named("ZBiome_CloudForest");
                                    newRecord1.commonality = current.plant.wildBiomes[j].commonality;
                                    current.plant.wildBiomes.Add(newRecord1);
                                }
                            }

                            if (current.plant.wildBiomes[j].biome.defName == "TemperateForest")
                            {
                                if (current.plant.IsTree)
                                {
                                    PlantBiomeRecord newRecord1 = new PlantBiomeRecord();
                                    newRecord1.biome       = BiomeDef.Named("ZBiome_CloudForest");
                                    newRecord1.commonality = current.plant.wildBiomes[j].commonality;
                                    current.plant.wildBiomes.Add(newRecord1);
                                }

                                // Badlands
                                if (!current.plant.wildBiomes.Any(b => b.biome.defName == "TemperateSwamp"))
                                {
                                    PlantBiomeRecord newRecord1 = new PlantBiomeRecord();
                                    newRecord1.biome       = BiomeDef.Named("ZBiome_Badlands");
                                    newRecord1.commonality = current.plant.wildBiomes[j].commonality;
                                    current.plant.wildBiomes.Add(newRecord1);
                                }
                            }


                            //Marsh
                            if (current.plant.wildBiomes[j].biome.defName == "ColdBog")
                            {
                                PlantBiomeRecord newRecord1 = new PlantBiomeRecord();
                                newRecord1.biome       = BiomeDef.Named("ZBiome_Marsh");
                                newRecord1.commonality = current.plant.wildBiomes[j].commonality;
                                if (current.plant.IsTree)
                                {
                                    newRecord1.commonality *= 0.3f;
                                }
                                current.plant.wildBiomes.Add(newRecord1);
                            }
                        }
                    }
                }
            }
        }
        // adapted from RF-Archipelagos
        private static void AddAnimalsWildBiomes()
        {
            foreach (PawnKindDef current in DefDatabase <PawnKindDef> .AllDefs)
            {
                if (current.RaceProps?.wildBiomes != null)
                {
                    // to check if it's in any of these biomes already
                    if (!current.RaceProps.wildBiomes.Any(w => w.biome.defName.Contains("ZBiome")))
                    {
                        //Dunes, Oasis
                        if (current.RaceProps.wildBiomes.Any(b => b.biome.defName == "Desert"))
                        {
                            AnimalBiomeRecord newRecord1 = new AnimalBiomeRecord();
                            newRecord1.biome       = BiomeDef.Named("ZBiome_CoastalDunes");
                            newRecord1.commonality = current.RaceProps.wildBiomes.Where(bi => bi.biome.defName == "Desert").FirstOrDefault().commonality;
                            current.RaceProps.wildBiomes.Add(newRecord1);

                            AnimalBiomeRecord newRecord2 = new AnimalBiomeRecord();
                            newRecord2.biome       = BiomeDef.Named("ZBiome_DesertOasis");
                            newRecord2.commonality = current.RaceProps.wildBiomes.Where(bi => bi.biome.defName == "Desert").FirstOrDefault().commonality;
                            current.RaceProps.wildBiomes.Add(newRecord2);
                        }
                        else if (current.RaceProps.wildBiomes.Any(b => b.biome.defName == "ExtremeDesert"))
                        {
                            AnimalBiomeRecord newRecord1 = new AnimalBiomeRecord();
                            newRecord1.biome       = BiomeDef.Named("ZBiome_CoastalDunes");
                            newRecord1.commonality = current.RaceProps.wildBiomes.Where(bi => bi.biome.defName == "ExtremeDesert").FirstOrDefault().commonality;
                            current.RaceProps.wildBiomes.Add(newRecord1);

                            AnimalBiomeRecord newRecord2 = new AnimalBiomeRecord();
                            newRecord2.biome       = BiomeDef.Named("ZBiome_DesertOasis");
                            newRecord2.commonality = current.RaceProps.wildBiomes.Where(bi => bi.biome.defName == "ExtremeDesert").FirstOrDefault().commonality;
                            current.RaceProps.wildBiomes.Add(newRecord2);
                        }

                        //Cloud Forest
                        if (current.RaceProps.wildBiomes.Any(b => b.biome.defName == "TropicalRainforest"))
                        {
                            AnimalBiomeRecord newRecord1 = new AnimalBiomeRecord();
                            newRecord1.biome       = BiomeDef.Named("ZBiome_CloudForest");
                            newRecord1.commonality = current.RaceProps.wildBiomes.Where(bi => bi.biome.defName == "TropicalRainforest").FirstOrDefault().commonality;
                            current.RaceProps.wildBiomes.Add(newRecord1);
                        }
                        else if (current.RaceProps.baseBodySize <= 0.5f && current.RaceProps.wildBiomes.Any(b => b.biome.defName == "TemperateForest"))
                        {
                            AnimalBiomeRecord newRecord1 = new AnimalBiomeRecord();
                            newRecord1.biome       = BiomeDef.Named("ZBiome_CloudForest");
                            newRecord1.commonality = current.RaceProps.wildBiomes.Where(bi => bi.biome.defName == "TemperateForest").FirstOrDefault().commonality;
                            current.RaceProps.wildBiomes.Add(newRecord1);
                        }

                        //Badlands
                        if (current.RaceProps.wildBiomes.Any(b => b.biome.defName == "TemperateForest"))
                        {
                            if (!current.RaceProps.wildBiomes.Any(b => b.biome.defName == "TemperateSwamp"))
                            {
                                AnimalBiomeRecord newRecord1 = new AnimalBiomeRecord();
                                newRecord1.biome       = BiomeDef.Named("ZBiome_Badlands");
                                newRecord1.commonality = current.RaceProps.wildBiomes.Where(bi => bi.biome.defName == "TemperateForest").FirstOrDefault().commonality;
                                if (!current.RaceProps.predator && current.RaceProps.baseBodySize > 1.0)    // less large herbivores
                                {
                                    newRecord1.commonality *= 0.5f;
                                }
                                current.RaceProps.wildBiomes.Add(newRecord1);
                            }
                            else if (current.RaceProps.wildBiomes.Any(b => b.biome.defName == "AridShrubland"))
                            {
                                AnimalBiomeRecord newRecord1 = new AnimalBiomeRecord();
                                newRecord1.biome        = BiomeDef.Named("ZBiome_Badlands");
                                newRecord1.commonality  = current.RaceProps.wildBiomes.Where(bi => bi.biome.defName == "TemperateForest").FirstOrDefault().commonality;
                                newRecord1.commonality *= 0.5f;
                                if (!current.RaceProps.predator && current.RaceProps.baseBodySize > 1.0)    // less large herbivores
                                {
                                    newRecord1.commonality *= 0.5f;
                                }
                                current.RaceProps.wildBiomes.Add(newRecord1);
                            }
                        }

                        // Glacial Shield
                        if (current.RaceProps.wildBiomes.Any(b => b.biome.defName == "Tundra"))
                        {
                            AnimalBiomeRecord newRecord1 = new AnimalBiomeRecord();
                            newRecord1.biome       = BiomeDef.Named("ZBiome_GlacialShield");
                            newRecord1.commonality = current.RaceProps.wildBiomes.Where(bi => bi.biome.defName == "Tundra").FirstOrDefault().commonality;
                            current.RaceProps.wildBiomes.Add(newRecord1);
                        }
                        else if (current.RaceProps.wildBiomes.Any(b => b.biome.defName == "IceSheet"))
                        {
                            AnimalBiomeRecord newRecord1 = new AnimalBiomeRecord();
                            newRecord1.biome       = BiomeDef.Named("ZBiome_GlacialShield");
                            newRecord1.commonality = current.RaceProps.wildBiomes.Where(bi => bi.biome.defName == "IceSheet").FirstOrDefault().commonality;
                            current.RaceProps.wildBiomes.Add(newRecord1);
                        }
                        else if (current.RaceProps.wildBiomes.Any(b => b.biome.defName == "BorealForest"))
                        {
                            if (!current.RaceProps.wildBiomes.Any(b => b.biome.defName == "TemperateForest"))
                            {
                                AnimalBiomeRecord newRecord1 = new AnimalBiomeRecord();
                                newRecord1.biome        = BiomeDef.Named("ZBiome_GlacialShield");
                                newRecord1.commonality  = current.RaceProps.wildBiomes.Where(bi => bi.biome.defName == "BorealForest").FirstOrDefault().commonality;
                                newRecord1.commonality *= 0.5f;
                                current.RaceProps.wildBiomes.Add(newRecord1);
                            }
                        }


                        for (int j = 0; j < current.RaceProps.wildBiomes.Count; j++)
                        {
                            //Iceberg
                            if (current.RaceProps.wildBiomes[j].biome.defName == "SeaIce")
                            {
                                AnimalBiomeRecord newRecord1 = new AnimalBiomeRecord();
                                newRecord1.biome       = BiomeDef.Named("ZBiome_Iceberg_NoBeach");
                                newRecord1.commonality = current.RaceProps.wildBiomes[j].commonality;
                                current.RaceProps.wildBiomes.Add(newRecord1);
                            }

                            //Meadow
                            if (current.RaceProps.wildBiomes[j].biome.defName == "BorealForest")
                            {
                                AnimalBiomeRecord newRecord1 = new AnimalBiomeRecord();
                                newRecord1.biome       = BiomeDef.Named("ZBiome_AlpineMeadow");
                                newRecord1.commonality = current.RaceProps.wildBiomes[j].commonality;
                                if (current.RaceProps.predator && current.RaceProps.maxPreyBodySize >= 0.9f)
                                {
                                    newRecord1.commonality *= 0.5f;
                                }
                                current.RaceProps.wildBiomes.Add(newRecord1);
                            }

                            //Grasslands
                            if (current.RaceProps.wildBiomes[j].biome.defName == "AridShrubland")
                            {
                                AnimalBiomeRecord newRecord1 = new AnimalBiomeRecord();
                                newRecord1.biome       = BiomeDef.Named("ZBiome_Grasslands");
                                newRecord1.commonality = current.RaceProps.wildBiomes[j].commonality;
                                if (current.RaceProps.herdAnimal)
                                {
                                    newRecord1.commonality *= 1.5f;
                                }
                                else
                                {
                                    newRecord1.commonality *= 0.5f;
                                }
                                current.RaceProps.wildBiomes.Add(newRecord1);
                            }


                            //Sandbar
                            if (current.RaceProps.wildBiomes[j].biome.defName == "ExtremeDesert")
                            {
                                AnimalBiomeRecord newRecord3 = new AnimalBiomeRecord();
                                newRecord3.biome       = BiomeDef.Named("ZBiome_Sandbar_NoBeach");
                                newRecord3.commonality = current.RaceProps.wildBiomes[j].commonality;
                                current.RaceProps.wildBiomes.Add(newRecord3);
                            }

                            //Marsh
                            if (current.RaceProps.wildBiomes[j].biome.defName == "ColdBog")
                            {
                                AnimalBiomeRecord newRecord1 = new AnimalBiomeRecord();
                                newRecord1.biome       = BiomeDef.Named("ZBiome_Marsh");
                                newRecord1.commonality = current.RaceProps.wildBiomes[j].commonality;
                                current.RaceProps.wildBiomes.Add(newRecord1);
                            }
                        }
                    }
                }
            }
        }
        private static bool Prefix()
        {
            WorldGrid worldGrid = Find.WorldGrid;

            bool[]     flagArray = new bool[worldGrid.TilesCount];
            List <int> nums      = new List <int>();

            for (int i = 0; i < worldGrid.TilesCount; i++)
            {
                if (!flagArray[i])
                {
                    if (worldGrid[i].biome == BiomeDefOf.Ocean || (worldGrid[i].biome.defName != null && worldGrid[i].biome.defName.Contains("Archipelago")))
                    {
                        Find.WorldFloodFiller.FloodFill(i, (int tid) => (worldGrid[tid].biome == BiomeDefOf.Ocean || (worldGrid[tid].biome.defName != null && worldGrid[tid].biome.defName.Contains("Archipelago"))), (int tid) => {
                            nums.Add(tid);
                            flagArray[tid] = true;
                        }, 2147483647);
                        if (nums.Count <= 180)
                        {
                            for (int j = 0; j < nums.Count; j++)
                            {
                                if (worldGrid[nums[j]].biome.defName != null && worldGrid[nums[j]].biome.defName == "BorealArchipelago")
                                {
                                    worldGrid[nums[j]].biome = BiomeDef.Named("BorealArchipelago_Fresh");
                                }
                                else if (worldGrid[nums[j]].biome.defName != null && worldGrid[nums[j]].biome.defName == "ColdBogArchipelago")
                                {
                                    worldGrid[nums[j]].biome = BiomeDef.Named("ColdBogArchipelago_Fresh");
                                }
                                else if (worldGrid[nums[j]].biome.defName != null && worldGrid[nums[j]].biome.defName == "DesertArchipelago")
                                {
                                    worldGrid[nums[j]].biome = BiomeDef.Named("DesertArchipelago_Fresh");
                                }
                                else if (worldGrid[nums[j]].biome.defName != null && worldGrid[nums[j]].biome.defName == "TemperateArchipelago")
                                {
                                    worldGrid[nums[j]].biome = BiomeDef.Named("TemperateArchipelago_Fresh");
                                }
                                else if (worldGrid[nums[j]].biome.defName != null && worldGrid[nums[j]].biome.defName == "TemperateSwampArchipelago")
                                {
                                    worldGrid[nums[j]].biome = BiomeDef.Named("TemperateSwampArchipelago_Fresh");
                                }
                                else if (worldGrid[nums[j]].biome.defName != null && worldGrid[nums[j]].biome.defName == "TropicalArchipelago")
                                {
                                    worldGrid[nums[j]].biome = BiomeDef.Named("TropicalArchipelago_Fresh");
                                }
                                else if (worldGrid[nums[j]].biome.defName != null && worldGrid[nums[j]].biome.defName == "TropicalSwampArchipelago")
                                {
                                    worldGrid[nums[j]].biome = BiomeDef.Named("TropicalSwampArchipelago_Fresh");
                                }
                                else if (worldGrid[nums[j]].biome.defName != null && worldGrid[nums[j]].biome.defName == "TundraArchipelago")
                                {
                                    worldGrid[nums[j]].biome = BiomeDef.Named("TundraArchipelago_Fresh");
                                }
                                else
                                {
                                    worldGrid[nums[j]].biome = BiomeDefOf.Lake;
                                }
                            }
                        }
                        nums.Clear();
                    }
                }
            }
            return(false);
        }
        public override void WorldComponentTick()
        {
            if (cache == null)
            {
                PopulateCache();
            }

            //if (Find.TickManager.TicksGame % 500 == 84)         // 5 days to cover standard world at this speed
            if (Find.TickManager.TicksGame % 2000 == 84)
            {
                //Log.Message("Growing tiles");
                if (!Find.WorldGrid.tiles.Any(t => t.biome.defName == "ZTB_Corruption") || Find.TickManager.TicksGame % 200000 == 84)
                {
                    Log.Message("Spawning corruption");
                    Tile tile = Find.WorldGrid.tiles.Where(t => !t.WaterCovered && t.biome != ZTB_DefOf.ZTB_Corruption).RandomElement();
                    if (tile != null)
                    {
                        tile.biome = BiomeDef.Named("ZTB_Corruption");
                        CorruptTile(Find.WorldGrid.tiles.FindIndex(x => x == tile));
                    }
                }

                else
                {
                    //Log.Message("Expanding corruption.....");
                    List <TileConversionData> corruptTiles = cache.Where(x => x.convStatus == ConvStatus.Corrupt).ToList();
                    List <int> tmpTiles = new List <int>();

                    foreach (TileConversionData tile in corruptTiles)
                    {
                        Find.WorldGrid.GetTileNeighbors(tile.tile, tmpTiles);
                        int  tileID    = tmpTiles.RandomElement();
                        Tile toConvert = Find.WorldGrid[tileID];

                        if (toConvert.biome.defName != "ZTB_Corruption" && !toConvert.WaterCovered)
                        {
                            if (cache[tileID].lastConvertedTick + 500000 < Find.TickManager.TicksGame)       // don't instantly reconvert tiles
                            {
                                toConvert.biome = BiomeDef.Named("ZTB_Corruption");
                                CorruptTile(tileID);
                            }
                        }
                    }
                }


                if (Find.TickManager.TicksGame % 60000 == 84)
                {
                    // randomly clear corruption from faction bases
                    Settlement settlement = Find.World.worldObjects.Settlements.RandomElement();

                    foreach (Settlement sett in Find.World.worldObjects.Settlements)
                    {
                        if (Rand.Chance(0.005f))
                        {
                            if (!sett.Faction.IsPlayer && cache[sett.Tile].convStatus != ConvStatus.Pure)
                            {
                                SpreadPurityFromPoint(settlement.Tile);
                            }
                        }
                    }

                    // regenerate world map
                    Find.World.renderer.SetDirty <WorldLayer_Terrain>();
                }
            }
        }
 static Planets_Initializer()
 {
     if (ModsConfig.ActiveModsInLoadOrder.Any(mod => mod.Name.Contains("My Little Planet")))
     {
         Controller.Settings.usingMLP = true;
     }
     if (ModsConfig.ActiveModsInLoadOrder.Any(mod => mod.Name.Contains("Faction Control")))
     {
         Controller.Settings.usingFactionControl = true;
     }
     if (ModsConfig.ActiveModsInLoadOrder.Any(mod => mod.Name.Contains("Nature's Pretty Sweet")))
     {
         Controller.Settings.otherGrassland = true;
         Controller.Settings.otherSavanna   = true;
     }
     if (ModsConfig.ActiveModsInLoadOrder.Any(mod => mod.Name.Contains("Terra Project (Core)")))
     {
         Controller.Settings.otherSavanna = true;
     }
     if (ModsConfig.ActiveModsInLoadOrder.Any(mod => mod.Name.Contains("Advanced Biomes")))
     {
         Controller.Settings.otherSavanna = true;
     }
     foreach (ThingDef current in DefDatabase <ThingDef> .AllDefsListForReading)
     {
         if (current.plant != null)
         {
             if (current.plant.wildBiomes != null)
             {
                 for (int j = 0; j < current.plant.wildBiomes.Count; j++)
                 {
                     if (current.plant.wildBiomes[j].biome.defName == "Tundra")
                     {
                         PlantBiomeRecord newRecord = new PlantBiomeRecord();
                         newRecord.biome       = BiomeDef.Named("RRP_Permafrost");
                         newRecord.commonality = current.plant.wildBiomes[j].commonality / 2;
                         current.plant.wildBiomes.Add(newRecord);
                     }
                     if (current.plant.wildBiomes[j].biome.defName == "TemperateForest")
                     {
                         if (!current.defName.Contains("Tree"))
                         {
                             PlantBiomeRecord newRecord = new PlantBiomeRecord();
                             newRecord.biome       = BiomeDef.Named("RRP_Grassland");
                             newRecord.commonality = current.plant.wildBiomes[j].commonality / 2;
                             current.plant.wildBiomes.Add(newRecord);
                         }
                     }
                     if (current.plant.wildBiomes[j].biome.defName == "BorealForest")
                     {
                         if (!current.defName.Contains("Tree"))
                         {
                             PlantBiomeRecord newRecord = new PlantBiomeRecord();
                             newRecord.biome       = BiomeDef.Named("RRP_Steppes");
                             newRecord.commonality = current.plant.wildBiomes[j].commonality / 2;
                             current.plant.wildBiomes.Add(newRecord);
                         }
                     }
                     if (current.plant.wildBiomes[j].biome.defName == "AridShrubland")
                     {
                         if (!current.defName.Contains("Acacia"))
                         {
                             PlantBiomeRecord newRecord = new PlantBiomeRecord();
                             newRecord.biome       = BiomeDef.Named("RRP_Savanna");
                             newRecord.commonality = current.plant.wildBiomes[j].commonality / 2;
                             current.plant.wildBiomes.Add(newRecord);
                         }
                     }
                     if (current.plant.wildBiomes[j].biome.defName == "Desert")
                     {
                         if (!current.defName.Contains("Acacia"))
                         {
                             PlantBiomeRecord newRecord = new PlantBiomeRecord();
                             newRecord.biome       = BiomeDef.Named("RRP_TemperateDesert");
                             newRecord.commonality = current.plant.wildBiomes[j].commonality / 2;
                             current.plant.wildBiomes.Add(newRecord);
                             PlantBiomeRecord newRecord2 = new PlantBiomeRecord();
                             newRecord2.biome       = BiomeDef.Named("RRP_Oasis");
                             newRecord2.commonality = current.plant.wildBiomes[j].commonality;
                             current.plant.wildBiomes.Add(newRecord2);
                         }
                     }
                 }
             }
         }
     }
     foreach (PawnKindDef current in DefDatabase <PawnKindDef> .AllDefs)
     {
         if (current.RaceProps.wildBiomes != null && current.defName != "Cobra")
         {
             for (int j = 0; j < current.RaceProps.wildBiomes.Count; j++)
             {
                 if (current.RaceProps.wildBiomes[j].biome.defName == "Tundra")
                 {
                     AnimalBiomeRecord newRecord = new AnimalBiomeRecord();
                     newRecord.biome       = BiomeDef.Named("RRP_Permafrost");
                     newRecord.commonality = current.RaceProps.wildBiomes[j].commonality / 2;
                     current.RaceProps.wildBiomes.Add(newRecord);
                 }
                 if (current.RaceProps.wildBiomes[j].biome.defName == "TemperateForest")
                 {
                     AnimalBiomeRecord newRecord = new AnimalBiomeRecord();
                     newRecord.biome       = BiomeDef.Named("RRP_Grassland");
                     newRecord.commonality = current.RaceProps.wildBiomes[j].commonality / 2;
                     current.RaceProps.wildBiomes.Add(newRecord);
                 }
                 if (current.RaceProps.wildBiomes[j].biome.defName == "BorealForest")
                 {
                     AnimalBiomeRecord newRecord = new AnimalBiomeRecord();
                     newRecord.biome       = BiomeDef.Named("RRP_Steppes");
                     newRecord.commonality = current.RaceProps.wildBiomes[j].commonality / 2;
                     current.RaceProps.wildBiomes.Add(newRecord);
                 }
                 if (current.RaceProps.wildBiomes[j].biome.defName == "AridShrubland")
                 {
                     AnimalBiomeRecord newRecord = new AnimalBiomeRecord();
                     newRecord.biome       = BiomeDef.Named("RRP_Savanna");
                     newRecord.commonality = current.RaceProps.wildBiomes[j].commonality / 2;
                     current.RaceProps.wildBiomes.Add(newRecord);
                 }
                 if (current.RaceProps.wildBiomes[j].biome.defName == "Desert")
                 {
                     AnimalBiomeRecord newRecord = new AnimalBiomeRecord();
                     newRecord.biome       = BiomeDef.Named("RRP_TemperateDesert");
                     newRecord.commonality = current.RaceProps.wildBiomes[j].commonality / 2;
                     current.RaceProps.wildBiomes.Add(newRecord);
                     AnimalBiomeRecord newRecord2 = new AnimalBiomeRecord();
                     newRecord2.biome       = BiomeDef.Named("RRP_Oasis");
                     newRecord2.commonality = current.RaceProps.wildBiomes[j].commonality;
                     current.RaceProps.wildBiomes.Add(newRecord2);
                 }
             }
         }
     }
 }
 static Archi_Initializer()
 {
     foreach (ThingDef current in DefDatabase <ThingDef> .AllDefsListForReading)
     {
         if (current.plant != null)
         {
             if (current.plant.wildBiomes != null)
             {
                 for (int j = 0; j < current.plant.wildBiomes.Count; j++)
                 {
                     if (current.plant.wildBiomes[j].biome.defName == "AridShrubland")
                     {
                         PlantBiomeRecord newRecord1 = new PlantBiomeRecord();
                         PlantBiomeRecord newRecord2 = new PlantBiomeRecord();
                         newRecord1.biome       = BiomeDef.Named("DesertArchipelago");
                         newRecord2.biome       = BiomeDef.Named("DesertArchipelago_Fresh");
                         newRecord1.commonality = current.plant.wildBiomes[j].commonality;
                         newRecord2.commonality = current.plant.wildBiomes[j].commonality;
                         current.plant.wildBiomes.Add(newRecord1);
                         current.plant.wildBiomes.Add(newRecord2);
                     }
                     if (current.plant.wildBiomes[j].biome.defName == "BorealForest")
                     {
                         PlantBiomeRecord newRecord1 = new PlantBiomeRecord();
                         PlantBiomeRecord newRecord2 = new PlantBiomeRecord();
                         newRecord1.biome       = BiomeDef.Named("BorealArchipelago");
                         newRecord2.biome       = BiomeDef.Named("BorealArchipelago_Fresh");
                         newRecord1.commonality = current.plant.wildBiomes[j].commonality;
                         newRecord2.commonality = current.plant.wildBiomes[j].commonality;
                         current.plant.wildBiomes.Add(newRecord1);
                         current.plant.wildBiomes.Add(newRecord2);
                     }
                     if (current.plant.wildBiomes[j].biome.defName == "ColdBog")
                     {
                         PlantBiomeRecord newRecord1 = new PlantBiomeRecord();
                         PlantBiomeRecord newRecord2 = new PlantBiomeRecord();
                         newRecord1.biome       = BiomeDef.Named("ColdBogArchipelago");
                         newRecord2.biome       = BiomeDef.Named("ColdBogArchipelago_Fresh");
                         newRecord1.commonality = current.plant.wildBiomes[j].commonality;
                         newRecord2.commonality = current.plant.wildBiomes[j].commonality;
                         current.plant.wildBiomes.Add(newRecord1);
                         current.plant.wildBiomes.Add(newRecord2);
                     }
                     if (current.plant.wildBiomes[j].biome.defName == "TemperateForest")
                     {
                         PlantBiomeRecord newRecord1 = new PlantBiomeRecord();
                         PlantBiomeRecord newRecord2 = new PlantBiomeRecord();
                         newRecord1.biome       = BiomeDef.Named("TemperateArchipelago");
                         newRecord2.biome       = BiomeDef.Named("TemperateArchipelago_Fresh");
                         newRecord1.commonality = current.plant.wildBiomes[j].commonality;
                         newRecord2.commonality = current.plant.wildBiomes[j].commonality;
                         current.plant.wildBiomes.Add(newRecord1);
                         current.plant.wildBiomes.Add(newRecord2);
                     }
                     if (current.plant.wildBiomes[j].biome.defName == "TemperateSwamp")
                     {
                         PlantBiomeRecord newRecord1 = new PlantBiomeRecord();
                         PlantBiomeRecord newRecord2 = new PlantBiomeRecord();
                         newRecord1.biome       = BiomeDef.Named("TemperateSwampArchipelago");
                         newRecord2.biome       = BiomeDef.Named("TemperateSwampArchipelago_Fresh");
                         newRecord1.commonality = current.plant.wildBiomes[j].commonality;
                         newRecord2.commonality = current.plant.wildBiomes[j].commonality;
                         current.plant.wildBiomes.Add(newRecord1);
                         current.plant.wildBiomes.Add(newRecord2);
                     }
                     if (current.plant.wildBiomes[j].biome.defName == "TropicalRainforest")
                     {
                         PlantBiomeRecord newRecord1 = new PlantBiomeRecord();
                         PlantBiomeRecord newRecord2 = new PlantBiomeRecord();
                         newRecord1.biome       = BiomeDef.Named("TropicalArchipelago");
                         newRecord2.biome       = BiomeDef.Named("TropicalArchipelago_Fresh");
                         newRecord1.commonality = current.plant.wildBiomes[j].commonality;
                         newRecord2.commonality = current.plant.wildBiomes[j].commonality;
                         current.plant.wildBiomes.Add(newRecord1);
                         current.plant.wildBiomes.Add(newRecord2);
                     }
                     if (current.plant.wildBiomes[j].biome.defName == "TropicalSwamp")
                     {
                         PlantBiomeRecord newRecord1 = new PlantBiomeRecord();
                         PlantBiomeRecord newRecord2 = new PlantBiomeRecord();
                         newRecord1.biome       = BiomeDef.Named("TropicalSwampArchipelago");
                         newRecord2.biome       = BiomeDef.Named("TropicalSwampArchipelago_Fresh");
                         newRecord1.commonality = current.plant.wildBiomes[j].commonality;
                         newRecord2.commonality = current.plant.wildBiomes[j].commonality;
                         current.plant.wildBiomes.Add(newRecord1);
                         current.plant.wildBiomes.Add(newRecord2);
                     }
                     if (current.plant.wildBiomes[j].biome.defName == "Tundra")
                     {
                         PlantBiomeRecord newRecord1 = new PlantBiomeRecord();
                         PlantBiomeRecord newRecord2 = new PlantBiomeRecord();
                         newRecord1.biome       = BiomeDef.Named("TundraArchipelago");
                         newRecord2.biome       = BiomeDef.Named("TundraArchipelago_Fresh");
                         newRecord1.commonality = current.plant.wildBiomes[j].commonality;
                         newRecord2.commonality = current.plant.wildBiomes[j].commonality;
                         current.plant.wildBiomes.Add(newRecord1);
                         current.plant.wildBiomes.Add(newRecord2);
                     }
                 }
             }
         }
     }
     foreach (PawnKindDef current in DefDatabase <PawnKindDef> .AllDefs)
     {
         if (current.RaceProps.wildBiomes != null && current.defName != "Cobra")
         {
             for (int j = 0; j < current.RaceProps.wildBiomes.Count; j++)
             {
                 if (current.RaceProps.wildBiomes[j].biome.defName == "AridShrubland")
                 {
                     AnimalBiomeRecord newRecord1 = new AnimalBiomeRecord();
                     AnimalBiomeRecord newRecord2 = new AnimalBiomeRecord();
                     newRecord1.biome       = BiomeDef.Named("DesertArchipelago");
                     newRecord2.biome       = BiomeDef.Named("DesertArchipelago_Fresh");
                     newRecord1.commonality = current.RaceProps.wildBiomes[j].commonality;
                     newRecord2.commonality = current.RaceProps.wildBiomes[j].commonality;
                     current.RaceProps.wildBiomes.Add(newRecord1);
                     current.RaceProps.wildBiomes.Add(newRecord2);
                 }
                 if (current.RaceProps.wildBiomes[j].biome.defName == "BorealForest")
                 {
                     AnimalBiomeRecord newRecord1 = new AnimalBiomeRecord();
                     AnimalBiomeRecord newRecord2 = new AnimalBiomeRecord();
                     newRecord1.biome       = BiomeDef.Named("BorealArchipelago");
                     newRecord2.biome       = BiomeDef.Named("BorealArchipelago_Fresh");
                     newRecord1.commonality = current.RaceProps.wildBiomes[j].commonality;
                     newRecord2.commonality = current.RaceProps.wildBiomes[j].commonality;
                     current.RaceProps.wildBiomes.Add(newRecord1);
                     current.RaceProps.wildBiomes.Add(newRecord2);
                 }
                 if (current.RaceProps.wildBiomes[j].biome.defName == "ColdBog")
                 {
                     AnimalBiomeRecord newRecord1 = new AnimalBiomeRecord();
                     AnimalBiomeRecord newRecord2 = new AnimalBiomeRecord();
                     newRecord1.biome       = BiomeDef.Named("ColdBogArchipelago");
                     newRecord2.biome       = BiomeDef.Named("ColdBogArchipelago_Fresh");
                     newRecord1.commonality = current.RaceProps.wildBiomes[j].commonality;
                     newRecord2.commonality = current.RaceProps.wildBiomes[j].commonality;
                     current.RaceProps.wildBiomes.Add(newRecord1);
                     current.RaceProps.wildBiomes.Add(newRecord2);
                 }
                 if (current.RaceProps.wildBiomes[j].biome.defName == "TemperateForest")
                 {
                     AnimalBiomeRecord newRecord1 = new AnimalBiomeRecord();
                     AnimalBiomeRecord newRecord2 = new AnimalBiomeRecord();
                     newRecord1.biome       = BiomeDef.Named("TemperateArchipelago");
                     newRecord2.biome       = BiomeDef.Named("TemperateArchipelago_Fresh");
                     newRecord1.commonality = current.RaceProps.wildBiomes[j].commonality;
                     newRecord2.commonality = current.RaceProps.wildBiomes[j].commonality;
                     current.RaceProps.wildBiomes.Add(newRecord1);
                     current.RaceProps.wildBiomes.Add(newRecord2);
                 }
                 if (current.RaceProps.wildBiomes[j].biome.defName == "TemperateSwamp")
                 {
                     AnimalBiomeRecord newRecord1 = new AnimalBiomeRecord();
                     AnimalBiomeRecord newRecord2 = new AnimalBiomeRecord();
                     newRecord1.biome       = BiomeDef.Named("TemperateSwampArchipelago");
                     newRecord2.biome       = BiomeDef.Named("TemperateSwampArchipelago_Fresh");
                     newRecord1.commonality = current.RaceProps.wildBiomes[j].commonality;
                     newRecord2.commonality = current.RaceProps.wildBiomes[j].commonality;
                     current.RaceProps.wildBiomes.Add(newRecord1);
                     current.RaceProps.wildBiomes.Add(newRecord2);
                 }
                 if (current.RaceProps.wildBiomes[j].biome.defName == "TropicalRainforest")
                 {
                     AnimalBiomeRecord newRecord1 = new AnimalBiomeRecord();
                     AnimalBiomeRecord newRecord2 = new AnimalBiomeRecord();
                     newRecord1.biome       = BiomeDef.Named("TropicalArchipelago");
                     newRecord2.biome       = BiomeDef.Named("TropicalArchipelago_Fresh");
                     newRecord1.commonality = current.RaceProps.wildBiomes[j].commonality;
                     newRecord2.commonality = current.RaceProps.wildBiomes[j].commonality;
                     current.RaceProps.wildBiomes.Add(newRecord1);
                     current.RaceProps.wildBiomes.Add(newRecord2);
                 }
                 if (current.RaceProps.wildBiomes[j].biome.defName == "TropicalSwamp")
                 {
                     AnimalBiomeRecord newRecord1 = new AnimalBiomeRecord();
                     AnimalBiomeRecord newRecord2 = new AnimalBiomeRecord();
                     newRecord1.biome       = BiomeDef.Named("TropicalSwampArchipelago");
                     newRecord2.biome       = BiomeDef.Named("TropicalSwampArchipelago_Fresh");
                     newRecord1.commonality = current.RaceProps.wildBiomes[j].commonality;
                     newRecord2.commonality = current.RaceProps.wildBiomes[j].commonality;
                     current.RaceProps.wildBiomes.Add(newRecord1);
                     current.RaceProps.wildBiomes.Add(newRecord2);
                 }
                 if (current.RaceProps.wildBiomes[j].biome.defName == "Tundra")
                 {
                     AnimalBiomeRecord newRecord1 = new AnimalBiomeRecord();
                     AnimalBiomeRecord newRecord2 = new AnimalBiomeRecord();
                     newRecord1.biome       = BiomeDef.Named("TundraArchipelago");
                     newRecord2.biome       = BiomeDef.Named("TundraArchipelago_Fresh");
                     newRecord1.commonality = current.RaceProps.wildBiomes[j].commonality;
                     newRecord2.commonality = current.RaceProps.wildBiomes[j].commonality;
                     current.RaceProps.wildBiomes.Add(newRecord1);
                     current.RaceProps.wildBiomes.Add(newRecord2);
                 }
             }
         }
     }
 }
Example #24
0
 private static void EditPlantDefs()
 {
     foreach (ThingDef current in DefDatabase <ThingDef> .AllDefsListForReading)
     {
         if (current.plant != null)
         {
             if (current.plant.wildBiomes != null)
             {
                 for (int j = 0; j < current.plant.wildBiomes.Count; j++)
                 {
                     if (current.plant.wildBiomes[j].biome.defName == "Tundra")
                     {
                         PlantBiomeRecord newRecord = new PlantBiomeRecord();
                         newRecord.biome       = BiomeDef.Named("RRP_Permafrost");
                         newRecord.commonality = current.plant.wildBiomes[j].commonality / 2;
                         current.plant.wildBiomes.Add(newRecord);
                     }
                     if (current.plant.wildBiomes[j].biome.defName == "TemperateForest")
                     {
                         if (!current.defName.Contains("Tree"))
                         {
                             PlantBiomeRecord newRecord = new PlantBiomeRecord();
                             newRecord.biome       = BiomeDef.Named("RRP_Grassland");
                             newRecord.commonality = current.plant.wildBiomes[j].commonality / 2;
                             current.plant.wildBiomes.Add(newRecord);
                         }
                     }
                     if (current.plant.wildBiomes[j].biome.defName == "BorealForest")
                     {
                         if (!current.defName.Contains("Tree"))
                         {
                             PlantBiomeRecord newRecord = new PlantBiomeRecord();
                             newRecord.biome       = BiomeDef.Named("RRP_Steppes");
                             newRecord.commonality = current.plant.wildBiomes[j].commonality / 2;
                             current.plant.wildBiomes.Add(newRecord);
                         }
                     }
                     if (current.plant.wildBiomes[j].biome.defName == "AridShrubland")
                     {
                         if (!current.defName.Contains("Acacia"))
                         {
                             PlantBiomeRecord newRecord = new PlantBiomeRecord();
                             newRecord.biome       = BiomeDef.Named("RRP_Savanna");
                             newRecord.commonality = current.plant.wildBiomes[j].commonality / 2;
                             current.plant.wildBiomes.Add(newRecord);
                         }
                     }
                     if (current.plant.wildBiomes[j].biome.defName == "Desert")
                     {
                         if (!current.defName.Contains("Acacia"))
                         {
                             PlantBiomeRecord newRecord = new PlantBiomeRecord();
                             newRecord.biome       = BiomeDef.Named("RRP_TemperateDesert");
                             newRecord.commonality = current.plant.wildBiomes[j].commonality / 2;
                             current.plant.wildBiomes.Add(newRecord);
                             PlantBiomeRecord newRecord2 = new PlantBiomeRecord();
                             newRecord2.biome       = BiomeDef.Named("RRP_Oasis");
                             newRecord2.commonality = current.plant.wildBiomes[j].commonality;
                             current.plant.wildBiomes.Add(newRecord2);
                         }
                     }
                 }
             }
         }
     }
 }