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)); } } }
private ESItem[] GetItems(ThingDef _ItemType, BiomeDef _biome) { // Variables ESItem[] aESI = new ESItem[0]; string strThingDef = _ItemType.defName; float floBasePrice = _ItemType.BaseMarketValue; int intAmount = 0; switch (strThingDef) { case "HerbalMedicine": intAmount = 3; floBasePrice = floBasePrice * GetPlantPriceInflate(_biome); break; case "Beer": intAmount = 3; floBasePrice = floBasePrice * GetPlantPriceInflate(_biome); break; case "Ambrosia": intAmount = 1; floBasePrice = floBasePrice * GetPlantPriceInflate(_biome); break; default: intAmount = 1; floBasePrice = floBasePrice * GetPlantPriceInflate(_biome); break; } aESI = aESI.Concat(new ESItem[] { new ESItem(_ItemType.defName, intAmount, floBasePrice * intAmount) }).ToArray(); return(aESI); }
public static void PushState(Map map) { var world = Current.Game != null ? Current.Game.World : null; if (world == null) { RimRPC.prsnc.details = "Main Menu"; } else { float latitude = (map == null) ? 0f : Find.WorldGrid.LongLatOf(map.Tile).y; float longitude = (map == null) ? 0f : Find.WorldGrid.LongLatOf(map.Tile).x; colonyname = GetColonyName(); years = days / 60; days = GenDate.DaysPassed; dayhour = GenDate.HourOfDay(Find.TickManager.TicksAbs, longitude); colonistnumber = (float)PawnsFinder.AllMapsCaravansAndTravelingTransportPods_Alive_FreeColonists.Count <Pawn>(); //Season season = GenDate.Season(Find.TickManager.TicksAbs, latitude, longitude); //Quadrum updates seem enough. Quadrum quadrum = GenDate.Quadrum(Find.TickManager.TicksAbs, longitude); BiomeDef biome = Find.WorldGrid[map.uniqueID].biome; RimRPC.prsnc.state = "Year " + years + " Day " + days + " (" + dayhour + "h) | " + quadrum; RimRPC.prsnc.details = colonyname + ", " + colonistnumber + " Colonists"; RimRPC.prsnc.largeImageText = "RimWorld"; RimRPC.prsnc.smallImageKey = "inmap"; RimRPC.prsnc.smallImageText = "Playing!"; } DiscordRPC.UpdatePresence(ref RimRPC.prsnc); //Log.Message("[RichPressence] Pushed presence update to RPC."); commented to remove log spam }
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); }
public static string GetSpeciesInZoneText(BiomeDef biome, int oceanCellsCount, int riverCellsCount, int marshCellsCount) { StringBuilder speciesInZone = new StringBuilder(); foreach (PawnKindDef_FishSpecies species in Util_FishIndustry.GetFishSpeciesList(biome)) { if ((oceanCellsCount > 0) && (species.livesInOcean)) { speciesInZone.AppendWithComma(species.label); } else if ((riverCellsCount > 0) && (species.livesInRiver)) { speciesInZone.AppendWithComma(species.label); } else if ((marshCellsCount > 0) && (species.livesInMarsh)) { speciesInZone.AppendWithComma(species.label); } } if (speciesInZone.Length == 0) { speciesInZone.Append("none"); } return(speciesInZone.ToString()); }
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 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 bool get_LowestWildAndCavePlantOrder(BiomeDef __instance, ref float __result) { if (!cachedLowestWildPlantOrder(__instance).HasValue) { cachedLowestWildPlantOrder(__instance) = 2.14748365E+09f; List <ThingDef> allWildPlants = __instance.AllWildPlants; for (int i = 0; i < allWildPlants.Count; i++) { ThingDef wildPlant = allWildPlants[i]; if (null != wildPlant) { cachedLowestWildPlantOrder(__instance) = Mathf.Min(cachedLowestWildPlantOrder(__instance).Value, wildPlant.plant.wildOrder); } } List <ThingDef> allDefsListForReading = DefDatabase <ThingDef> .AllDefsListForReading; for (int j = 0; j < allDefsListForReading.Count; j++) { if (allDefsListForReading[j].category == ThingCategory.Plant && allDefsListForReading[j].plant.cavePlant) { cachedLowestWildPlantOrder(__instance) = Mathf.Min(cachedLowestWildPlantOrder(__instance).Value, allDefsListForReading[j].plant.wildOrder); } } } __result = cachedLowestWildPlantOrder(__instance).Value; return(false); }
/// <summary> /// Initializes the weather data from the given <see cref="ModSettingsPack" /> settings /// and <see cref="WeatherDef" />, creating our settings in the process. /// </summary> /// <param name="settings">The setting pack to use</param> /// <param name="biome">The biome to use</param> /// <param name="weather">The weather to base this off of</param> /// <param name="visibilityFunc">Function which returns if we should display this now</param> public WeatherData(ModSettingsPack settings, BiomeDef biome, WeatherDef weather, SettingHandle.ShouldDisplay visibilityFunc) { this.weather = weather; var curCommonality = biome.baseWeatherCommonalities.FirstOrDefault(wc => wc.weather == weather)?.commonality ?? 0f; // Init our settings... SpacerDrawer.GenerateSpacer(GenText.ToTitleCaseSmart(weather.label), settings, visibilityFunc); commonality = settings.GetHandle($"weather_{biome.defName}_{weather.defName}", " " + "ColdDesertNights_BiomeWeather".Translate(), "ColdDesertNights_BiomeWeather_Desc".Translate(curCommonality), curCommonality, Validators.FloatRangeValidator(0f, float.MaxValue)); allowRepeating = settings.GetHandle($"weather_{biome.defName}_{weather.defName}_repeating", " " + "ColdDesertNights_BiomeWeatherRepeating".Translate(), "ColdDesertNights_BiomeWeatherRepeating_Desc".Translate( (weather.repeatable ? "ColdDesertNights_Checked" : "ColdDesertNights_Unchecked").Translate()), weather.repeatable); allowEarly = settings.GetHandle($"weather_{biome.defName}_{weather.defName}_early", " " + "ColdDesertNights_BiomeWeatherEarly".Translate(), "ColdDesertNights_BiomeWeatherEarly_Desc".Translate( (Favorability.Neutral <= weather.favorability ? "ColdDesertNights_Checked" : "ColdDesertNights_Unchecked").Translate()), Favorability.Neutral <= weather.favorability); // And set our visibility predicates... commonality.VisibilityPredicate = allowRepeating.VisibilityPredicate = allowEarly.VisibilityPredicate = visibilityFunc; }
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 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); }
public static bool CachePlantCommonalitiesIfShould(BiomeDef __instance) { if (cachedPlantCommonalities(__instance) != null) { return(false); } cachedPlantCommonalities(__instance) = new Dictionary <ThingDef, float>(); for (int i = 0; i < wildPlants(__instance).Count; i++) { if (wildPlants(__instance)[i].plant != null) { cachedPlantCommonalities(__instance)[wildPlants(__instance)[i].plant] = wildPlants(__instance)[i].commonality; } } foreach (ThingDef allDef in DefDatabase <ThingDef> .AllDefs) { if (allDef.plant != null && allDef.plant.wildBiomes != null) { for (int j = 0; j < allDef.plant.wildBiomes.Count; j++) { if (allDef.plant.wildBiomes[j].biome == __instance) { cachedPlantCommonalities(__instance).Add(allDef, allDef.plant.wildBiomes[j].commonality); } } } } cachedPlantCommonalitiesSum(__instance) = cachedPlantCommonalities(__instance).Sum((KeyValuePair <ThingDef, float> x) => x.Value); return(false); }
/// <summary> /// Initialize weather specific settings /// </summary> /// <param name="settings">The settings instance to use</param> /// <param name="biome">The biome we're working with</param> /// <param name="key">The key to use</param> /// <param name="weathers">The weathers to iterate through</param> /// <param name="visibilityFunc">Our base visibility function</param> private void InitWeatherSettings(ModSettingsPack settings, BiomeDef biome, string key, List <WeatherDef> weathers, SettingHandle.ShouldDisplay visibilityFunc) { // Per-biome rain and snowfall multipliers foreach (var weather in weathers) { weatherCommonalities[weather] = new WeatherData(settings, biome, weather, visibilityFunc); } SpacerDrawer.GenerateSpacer("ColdDesertNights_WeatherMiscSettings".Translate(), settings, visibilityFunc); // If we're allowed to bypass the rain limits settingIgnoreRainLimit = settings.GetHandle( $"ignore_rain_limit_{key}", " " + "ColdDesertNights_IgnoreRainLimit".Translate(), "ColdDesertNights_IgnoreRainLimit_Desc".Translate(), false); // Force weather into the given range minWeatherTemperature = settings.GetHandle( $"weather_temp_min_{key}", " " + "ColdDesertNights_WeatherTempMin".Translate(), "ColdDesertNights_WeatherTempMin_Desc".Translate(), -999f); maxWeatherTemperature = settings.GetHandle( $"weather_temp_max_{key}", " " + "ColdDesertNights_WeatherTempMax".Translate(), "ColdDesertNights_WeatherTempMax_Desc".Translate(), 999f); // Set our visibility predicates: settingIgnoreRainLimit.VisibilityPredicate = minWeatherTemperature.VisibilityPredicate = maxWeatherTemperature.VisibilityPredicate = visibilityFunc; }
private static float ExpectedAnimalCount(PawnKindDef k, BiomeDef b) { float num = b.CommonalityOfAnimal(k); float result; if (num == 0f) { result = 0f; } else { float num2 = DefDatabase <PawnKindDef> .AllDefs.Sum((PawnKindDef ki) => b.CommonalityOfAnimal(ki)); float num3 = num / num2; float num4 = 10000f / b.animalDensity; float num5 = 62500f / num4; float totalCommonality = DefDatabase <PawnKindDef> .AllDefs.Sum((PawnKindDef ki) => b.CommonalityOfAnimal(ki)); float num6 = DefDatabase <PawnKindDef> .AllDefs.Sum((PawnKindDef ki) => k.ecoSystemWeight *(b.CommonalityOfAnimal(ki) / totalCommonality)); float num7 = num5 / num6; float num8 = num7 * num3; result = num8; } return(result); }
public static void PushState(Map map) { var world = Current.Game != null ? Current.Game.World : null; if (world == null) { RimRPC.prsnc.details = "Main Menu"; } else { float latitude = (map == null) ? 0f : Find.WorldGrid.LongLatOf(map.Tile).y; float longitude = (map == null) ? 0f : Find.WorldGrid.LongLatOf(map.Tile).x; colonyname = GetColonyName(); years = days / 60; colonistnumber = (float)PawnsFinder.AllMapsCaravansAndTravelingTransportPods_Alive_FreeColonists.Count <Pawn>(); days = GenDate.DaysPassed; dayhour = GenDate.HourOfDay(Find.TickManager.TicksAbs, longitude); quadrum = GenDate.Quadrum(Find.TickManager.TicksAbs, longitude); BiomeDef biome = Find.WorldGrid[map.uniqueID].biome; RimRPC.prsnc.state = BuildString("state"); RimRPC.prsnc.details = BuildString("details"); RimRPC.prsnc.largeImageText = "RimWorld"; RimRPC.prsnc.smallImageKey = "inmap"; RimRPC.prsnc.smallImageText = "Playing!"; if (RWRPCMod.settings.RPC_Time) { RimRPC.prsnc.startTimestamp = RimRPC.started; } } DiscordRPC.UpdatePresence(ref RimRPC.prsnc); }
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); } }
internal static float _CommonalityOfPlant(this BiomeDef _this, ThingDef plantDef) { var cachedPlantCommonalities = _this.cachedPlantCommonalities(); if (cachedPlantCommonalities == null) { cachedPlantCommonalities = new Dictionary <ThingDef, float>(); for (int i = 0; i < _this.wildPlants().Count; i++) { cachedPlantCommonalities.Add(_this.wildPlants()[i].plant, _this.wildPlants()[i].commonality); } foreach (ThingDef current in DefDatabase <ThingDef> .AllDefs) { if (current.plant != null && current.plant.wildBiomes != null) { for (int index = 0; index < current.plant.wildBiomes.Count; ++index) { if (current.plant.wildBiomes[index].biome.defName == _this.defName) { cachedPlantCommonalities.Add(current.plant.wildBiomes[index].plant, current.plant.wildBiomes[index].commonality); } } } } _this.cachedPlantCommonalitiesSet(cachedPlantCommonalities); } float result; if (cachedPlantCommonalities.TryGetValue(plantDef, out result)) { return(result); } return(0f); }
public static void PushState(Map map) { var world = Current.Game != null ? Current.Game.World : null; if (world == null) { RimRPC.prsnc.details = "Main Menu"; } else { float latitude = (map == null) ? 0f : Find.WorldGrid.LongLatOf(map.Tile).y; float longitude = (map == null) ? 0f : Find.WorldGrid.LongLatOf(map.Tile).x; colonyname = GetColonyName(); days = GenDate.DaysPassed; dayhour = GenDate.HourOfDay(Find.TickManager.TicksAbs, longitude); //Season season = GenDate.Season(Find.TickManager.TicksAbs, latitude, longitude); //Quadrum updates seem enough. Quadrum quadrum = GenDate.Quadrum(Find.TickManager.TicksAbs, longitude); BiomeDef biome = Find.WorldGrid[map.uniqueID].biome; RimRPC.prsnc.state = "Day " + days + " (" + dayhour + "h) | " + quadrum; RimRPC.prsnc.details = colonyname; RimRPC.prsnc.largeImageText = "RimWorld"; RimRPC.prsnc.smallImageKey = "inmap"; RimRPC.prsnc.smallImageText = "Playing!"; } DiscordRPC.UpdatePresence(ref RimRPC.prsnc); Log.Message("[RichPressence] Pushed presence update to RPC."); }
internal static float _CommonalityOfAnimal(this BiomeDef _this, PawnKindDef animalDef) { var cachedAnimalCommonalities = _this.cachedAnimalCommonalities(); if (cachedAnimalCommonalities == null) { cachedAnimalCommonalities = new Dictionary <PawnKindDef, float>(); for (int index = 0; index < _this.wildAnimals().Count; ++index) { cachedAnimalCommonalities.Add(_this.wildAnimals()[index].animal, _this.wildAnimals()[index].commonality); } foreach (PawnKindDef current in DefDatabase <PawnKindDef> .AllDefs) { if (current.RaceProps.wildBiomes != null) { for (int index = 0; index < current.RaceProps.wildBiomes.Count; ++index) { if (current.RaceProps.wildBiomes[index].biome.defName == _this.defName) { cachedAnimalCommonalities.Add(current.RaceProps.wildBiomes[index].animal, current.RaceProps.wildBiomes[index].commonality); } } } } _this.cachedAnimalCommonalitiesSet(cachedAnimalCommonalities); } float num; if (cachedAnimalCommonalities.TryGetValue(animalDef, out num)) { return(num); } return(0.0f); }
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; } }
internal static float _MTBDaysOfDisease(this BiomeDef _this, IncidentDef diseaseInc) { var cachedDiseaseCommonalities = _this.cachedDiseaseCommonalities(); if (cachedDiseaseCommonalities == null) { cachedDiseaseCommonalities = new Dictionary <IncidentDef, float>(); for (int i = 0; i < _this.diseases().Count; i++) { cachedDiseaseCommonalities.Add(_this.diseases()[i].diseaseInc, _this.diseases()[i].mtbDays); } foreach (IncidentDef current in DefDatabase <IncidentDef> .AllDefs) { if (current.diseaseBiomeRecords != null) { for (int index = 0; index < current.diseaseBiomeRecords.Count; ++index) { if (current.diseaseBiomeRecords[index].biome.defName == _this.defName) { cachedDiseaseCommonalities.Add(current.diseaseBiomeRecords[index].diseaseInc, current.diseaseBiomeRecords[index].mtbDays); } } } } _this.cachedDiseaseCommonalitiesSet(cachedDiseaseCommonalities); } float result; if (cachedDiseaseCommonalities.TryGetValue(diseaseInc, out result)) { return(result); } return(9999999f); }
private float GetPlantPriceInflate(BiomeDef _biome) { switch (_biome.defName) { case "IceSheet": return(1.9f); case "ExtremeDesert": return(1.9f); case "SeaIce": return(1.9f); case "Desert": return(1.7f); case "Tundra": return(1.8f); case "AridShrubland": return(1.4f); case "BorealForest": return(1.3f); case "TemperateForest": return(1.1f); case "TropicalRainforest": return(1f); default: return(1.9f); } }
public static void getPocketDimensionBiome(Map __instance, ref BiomeDef __result) { if (__instance.info?.parent != null && __instance.info.parent is MapParent_PocketDimension) { __result = PocketDimensionDefOf.CM_PocketDimensionBiome; } }
internal static Dictionary <IncidentDef, float> cachedDiseaseCommonalities(this BiomeDef obj) { if (_cachedDiseaseCommonalities == null) { _cachedDiseaseCommonalities = typeof(BiomeDef).GetField("cachedDiseaseCommonalities", BindingFlags.Instance | BindingFlags.NonPublic); } return((Dictionary <IncidentDef, float>)_cachedDiseaseCommonalities.GetValue(obj)); }
internal static List <BiomeDiseaseRecord> diseases(this BiomeDef obj) { if (_diseases == null) { _diseases = typeof(BiomeDef).GetField("diseases", BindingFlags.Instance | BindingFlags.NonPublic); } return((List <BiomeDiseaseRecord>)_diseases.GetValue(obj)); }
internal static List <BiomePlantRecord> wildPlants(this BiomeDef obj) { if (_wildPlants == null) { _wildPlants = typeof(BiomeDef).GetField("wildPlants", BindingFlags.Instance | BindingFlags.NonPublic); } return((List <BiomePlantRecord>)_wildPlants.GetValue(obj)); }
public static List <PawnKindDef_FishSpecies> GetFishSpeciesList(BiomeDef biome) { if (fishSpeciesListDico.ContainsKey(biome) == false) { fishSpeciesListDico.Add(biome, BuildFishSpeciesListForMap(biome)); } return(fishSpeciesListDico.TryGetValue(biome)); }
internal static void cachedDiseaseCommonalitiesSet(this BiomeDef obj, Dictionary <IncidentDef, float> value) { if (_cachedDiseaseCommonalities == null) { _cachedDiseaseCommonalities = typeof(BiomeDef).GetField("cachedDiseaseCommonalities", BindingFlags.Instance | BindingFlags.NonPublic); } _cachedDiseaseCommonalities.SetValue(obj, value); }
/// <summary> /// Обновить указанный слой посредством дополнения (небольшая нагрузка) /// </summary> /// <param name="layer">Слой</param> /// <param name="material">Материал для поиска подслоя</param> /// <param name="subMeshes">Список подслоев</param> /// <param name="b">Биом</param> public void UpdateLayer(WorldLayer layer, Material material, List <LayerSubMesh> subMeshes, BiomeDef b) { int subMeshIndex; LayerSubMesh subMesh = GetSubMesh(material, subMeshes, out subMeshIndex); List <int> tileIds = new List <int>(); List <Tile> tiles = Find.WorldGrid.tiles.Where(tile => tile.biome == b).ToList(); for (int i3 = 0; i3 < Find.WorldGrid.TilesCount; i3++) { Tile temp = Find.WorldGrid[i3]; if (tiles.Contains(temp)) { tileIds.Add(i3); } } World world = Find.World; WorldGrid grid = world.grid; List <int> tileIDToVerts_offsets = grid.tileIDToVerts_offsets; List <Vector3> verts = grid.verts; List <List <int> > triangleIndexToTileID = new List <List <int> >(); List <Vector3> elevationValues = new List <Vector3>(); triangleIndexToTileID.Clear(); subMesh.Clear(MeshParts.All); foreach (int tileID in tileIds) { int colorsAndUVsIndex = 0; Tile tile = tiles[tileID]; BiomeDef biome = tile.biome; while (subMeshIndex >= triangleIndexToTileID.Count) { triangleIndexToTileID.Add(new List <int>()); } int count = subMesh.verts.Count; int num = 0; int num2 = (tileID + 1 >= tileIDToVerts_offsets.Count) ? verts.Count : tileIDToVerts_offsets[tileID + 1]; for (int j = tileIDToVerts_offsets[tileID]; j < num2; j++) { subMesh.verts.Add(verts[j]); subMesh.uvs.Add(elevationValues[colorsAndUVsIndex]); colorsAndUVsIndex++; if (j < num2 - 2) { subMesh.tris.Add(count + num + 2); subMesh.tris.Add(count + num + 1); subMesh.tris.Add(count); triangleIndexToTileID[subMeshIndex].Add(tileID); } num++; } } FinalizeMesh(MeshParts.All, subMesh); }
private static void MapBiomePostfix(Map __instance, ref BiomeDef __result) { bool flag = __instance.ParentHolder is DeepRim.UndergroundMapParent; if (flag) { __result = DefDatabase <BiomeDef> .GetNamed("Cave", true); } }