Ejemplo n.º 1
0
        public static bool Prefix(World __instance, ref bool __result, int tile)
        {
            BiomeDef biome = __instance.grid[tile].biome;
            // Set via modext caves
            ModExt_Biome_GenStep_BetterCaves extCaves = biome.GetModExtension <ModExt_Biome_GenStep_BetterCaves>();

            if (extCaves != null)
            {
                __result = true;
                return(false);
            }
            // Set via modext feature control
            ModExt_Biome_FeatureControl extFtControl = biome.GetModExtension <ModExt_Biome_FeatureControl>();

            if (extFtControl != null)
            {
                if (extFtControl.overwriteCaves == GenFeatureTristate.Add)
                {
                    __result = true;
                    return(false);
                }
                if (extFtControl.overwriteCaves == GenFeatureTristate.Remove)
                {
                    __result = false;
                    return(false);
                }
            }
            return(true);
        }
        public static void Postfix(ref TerrainDef __result, IntVec3 c, Map map)
        {
            BiomeDef biome = map.Biome;
            // General cell terrain replcement
            ModExt_Biome_Replacement extReplacement = biome.GetModExtension <ModExt_Biome_Replacement>() ?? ModExt_Biome_Replacement.Default;

            // Replace sand (mostly from beach)
            if (__result == RimWorld.TerrainDefOf.Sand)
            {
                __result = extReplacement.sandReplacement;
            }
            // Replace gravel
            if (__result == RimWorld.TerrainDefOf.Gravel)
            {
                __result = extReplacement.gravelReplacement;
            }

            // Addtitional island terrainPatchMaker by fertility
            if (biome.HasModExtension <ModExt_Biome_GenStep_Islands>())
            {
                TerrainDef newTerrain = IslandNoises.TerrainAtFromTerrainPatchMakerByFertility(c, map, __result);
                if (newTerrain != null)
                {
                    __result = newTerrain;
                }
            }

            // Post-terrain-gen terrain replacement
            // Replace filler stone
            if (__result == TerrainDefOf.FillerStone)
            {
                __result = GenStep_RocksFromGrid.RockDefAt(c).building.naturalTerrain;
            }
        }
Ejemplo n.º 3
0
        public static float GetMaxFertByBiome(BiomeDef biome)
        {
            if (!biome.HasModExtension <BiomesMap>())
            {
                return(1.2f);
            }
            if (biome.GetModExtension <BiomesMap>().isOasis)
            {
                return(17f);
            }
            if (biome.GetModExtension <BiomesMap>().isIsland)
            {
                return(17f);
            }

            return(1.2f);
        }
Ejemplo n.º 4
0
        public static void Prefix(BiomeDef __instance)
        {
            BiomeSeasonalSettings biomeSettings = __instance.GetModExtension <BiomeSeasonalSettings>();

            if (biomeSettings != null && biomeSettings.diseaseCacheUpdated == false)
            {
                // Log.Warning("updating cachedDiseaseCommonalities");
                Traverse.Create(__instance).Field("cachedDiseaseCommonalities").SetValue(null);
                biomeSettings.diseaseCacheUpdated = true;
            }
        }
 // Token: 0x06000053 RID: 83 RVA: 0x00005F24 File Offset: 0x00004124
 public static string GetCamoDefBiome(BiomeDef biome)
 {
     if (biome.HasModExtension <CompCamoDefs>())
     {
         string text = biome?.GetModExtension <CompCamoDefs>().CamoType;
         if (CamoGearUtility.CamoTypes().Contains(text))
         {
             return(text);
         }
     }
     return("notDefined");
 }
        public static void Postfix(WildPlantSpawner __instance, IntVec3 c, float plantDensity, float wholeMapNumDesiredPlants, bool setRandomGrowth, ref bool __result)
        {
            if (__result == false)
            {
                Map map = Traverse.Create(__instance).Field("map").GetValue <Map>();

                if (!(plantDensity <= 0.0) && c.GetPlant(map) == null && c.GetCover(map) == null && c.GetEdifice(map) == null && PlantUtility.SnowAllowsPlanting(c, map))
                {
                    //check if we're on water or salt.
                    TerrainDef            terrain  = c.GetTerrain(map);
                    BiomeSeasonalSettings biomeSet = map.Biome.GetModExtension <BiomeSeasonalSettings>();
                    if (biomeSet.specialPlants != null)
                    {
                        //spawn any special plants
                        WildPlantSpawner.tmpPossiblePlants

                        this.CalculatePlantsWhichCanGrowAt(c, WildPlantSpawner.tmpPossiblePlants, cavePlants, plantDensity);

                        if (!WildPlantSpawner.tmpPossiblePlants.Any())
                        {
                            return(false);
                        }
                        this.CalculateDistancesToNearbyClusters(c);
                        WildPlantSpawner.tmpPossiblePlantsWithWeight.Clear();
                        for (int i = 0; i < WildPlantSpawner.tmpPossiblePlants.Count; i++)
                        {
                            float value = this.PlantChoiceWeight(WildPlantSpawner.tmpPossiblePlants[i], c, WildPlantSpawner.distanceSqToNearbyClusters, wholeMapNumDesiredPlants, plantDensity);
                            WildPlantSpawner.tmpPossiblePlantsWithWeight.Add(new KeyValuePair <ThingDef, float>(WildPlantSpawner.tmpPossiblePlants[i], value));
                        }
                        KeyValuePair <ThingDef, float> keyValuePair = default(KeyValuePair <ThingDef, float>);
                        if (!((IEnumerable <KeyValuePair <ThingDef, float> >)WildPlantSpawner.tmpPossiblePlantsWithWeight).TryRandomElementByWeight <KeyValuePair <ThingDef, float> >((Func <KeyValuePair <ThingDef, float>, float>)((KeyValuePair <ThingDef, float> x) => x.Value), out keyValuePair))
                        {
                            return(false);
                        }
                        Plant plant = (Plant)ThingMaker.MakeThing(keyValuePair.Key, null);
                        if (setRandomGrowth)
                        {
                            plant.Growth = Rand.Range(0.07f, 1f);
                            if (plant.def.plant.LimitedLifespan)
                            {
                                plant.Age = Rand.Range(0, Mathf.Max(plant.def.plant.LifespanTicks - 50, 0));
                            }
                        }
                        GenSpawn.Spawn(plant, c, map, WipeMode.Vanish);
                        return(true);
                    }

                    PlantDef = c.GetPlant(map);
                    if (__result == true && plantDef != null && c != null && map != null)
                    {
                        BiomeDef biome = map.Biome;
                        BiomeSeasonalSettings biomeSettings = biome.GetModExtension <BiomeSeasonalSettings>();
                        if (biomeSettings != null)
                        {
                            if (!biomeSettings.canPutOnTerrain(c, plantDef, map))
                            {
                                __result = false;
                            }
                        }
                    }
                }
            }
        }