// Link a building with a facility // affectedDef must have CompAffectedByFacilities // facilityDef must have CompFacility public static bool LinkFacility( ThingDef affectedDef, ThingDef facilityDef ) { // Get comps var affectedComp = affectedDef.GetCompProperties<CompProperties_AffectedByFacilities>(); var facilityComp = facilityDef.GetCompProperties<CompProperties_Facility>(); if( ( affectedComp == null )|| ( facilityComp == null ) ) { // Bad call return false; } // Add the facility to the building affectedComp.linkableFacilities.AddUnique( facilityDef ); // Is the facility in the dictionary? if( !facilityComps.ContainsKey( facilityDef ) ) { // Add the facility to the dictionary facilityComps.Add( facilityDef, facilityComp ); } // Building is [now] linked to the facility return true; }
public static bool RaceAllowsSurgery(this ThingDef alienDef, RecipeDef recipeDef) { ThingDef ingredientDef = recipeDef.fixedIngredientFilter?.AnyAllowedDef; ThingDef productDef = recipeDef.ProducedThingDef; ThingDef bloodDef = alienDef.GetBloodDef(); //null coalescing is schweet. Screw you spaghetti code return(ingredientDef == bloodDef || productDef == bloodDef || (ingredientDef?.GetCompProperties <CompProperties_RestrictUsableByRace>()?.allowedRaces?.Contains(alienDef) ?? productDef?.GetCompProperties <CompProperties_RestrictUsableByRace>()?.allowedRaces?.Contains(alienDef) ?? false)); }
// RimWorld.FoodUtility.WillEat (ThingDef) public static bool WillEat_NothingDef(Pawn p, ThingDef food, Pawn getter, bool careIfNotAcceptableForTitle, ref bool __result) { if (p.IsVampire()) { if (food?.GetCompProperties <CompProperties_BloodItem>() is CompProperties_BloodItem c) { __result = true; return(false); } __result = false; return(false); } return(true); }
/// <summary> /// Generates a readout text for a projectile with the damage amount, type, secondary explosion and other CE stats for /// display in info-box /// </summary> /// <param name="projectileDef">The projectile's ThingDef</param> /// <returns>Formatted string listing projectile stats</returns> public static string GetProjectileReadout(this ThingDef projectileDef, Thing weapon) { // Append ammo stats var props = projectileDef?.projectile as ProjectilePropertiesCE; if (props == null) { Log.Error("CE tried getting projectile readout with null props"); return(""); } var stringBuilder = new StringBuilder(); // Damage type/amount var dmgList = " " + "CE_DescDamage".Translate() + ": "; if (!props.secondaryDamage.NullOrEmpty()) { // If we have multiple damage types, put every one in its own line stringBuilder.AppendLine(dmgList); stringBuilder.AppendLine(" " + GenText.ToStringByStyle(props.GetDamageAmount(weapon), ToStringStyle.Integer) + " (" + props.damageDef.LabelCap + ")"); foreach (var sec in props.secondaryDamage) { var secondaryChance = sec.chance >= 1.0f ? "" : $"({GenText.ToStringByStyle(sec.chance, ToStringStyle.PercentZero)} {"CE_Chance".Translate()})"; stringBuilder.AppendLine($" {GenText.ToStringByStyle(sec.amount, ToStringStyle.Integer)} ({sec.def.LabelCap}) {secondaryChance}"); } } else { stringBuilder.AppendLine(dmgList + GenText.ToStringByStyle(props.GetDamageAmount(weapon), ToStringStyle.Integer) + " (" + props.damageDef.LabelCap + ")"); } // Explosion radius if (props.explosionRadius > 0) { stringBuilder.AppendLine(" " + "CE_DescExplosionRadius".Translate() + ": " + props.explosionRadius.ToStringByStyle(ToStringStyle.FloatOne)); } // Sharp / blunt AP if (props.explosionRadius > 0) { if (props.damageDef.armorCategory != CE_DamageArmorCategoryDefOf.Heat && props.damageDef.armorCategory != CE_DamageArmorCategoryDefOf.Electric && props.damageDef != DamageDefOf.Stun && props.damageDef != DamageDefOf.Extinguish && props.damageDef != DamageDefOf.Smoke) { stringBuilder.AppendLine(" " + "CE_DescBluntPenetration".Translate() + ": " + GenExplosionCE.GetExplosionAP(props) + " " + "CE_MPa".Translate()); } } else { stringBuilder.AppendLine(" " + "CE_DescSharpPenetration".Translate() + ": " + props.armorPenetrationSharp.ToStringByStyle(ToStringStyle.FloatTwo) + " " + "CE_mmRHA".Translate()); stringBuilder.AppendLine(" " + "CE_DescBluntPenetration".Translate() + ": " + props.armorPenetrationBlunt.ToStringByStyle(ToStringStyle.FloatTwo) + " " + "CE_MPa".Translate()); } // Secondary explosion var secExpProps = projectileDef.GetCompProperties <CompProperties_ExplosiveCE>(); if (secExpProps != null) { if (secExpProps.explosiveRadius > 0) { stringBuilder.AppendLine(" " + "CE_DescSecondaryExplosion".Translate() + ":"); stringBuilder.AppendLine(" " + " " + "CE_DescDamage".Translate() + ": " + secExpProps.damageAmountBase.ToStringByStyle(ToStringStyle.Integer) + " (" + secExpProps.explosiveDamageType.LabelCap + ")"); stringBuilder.AppendLine(" " + " " + "CE_DescExplosionRadius".Translate() + ": " + secExpProps.explosiveRadius.ToStringByStyle(ToStringStyle.FloatOne)); } } // Pellets if (props.pelletCount > 1) { stringBuilder.AppendLine(" " + "CE_DescPelletCount".Translate() + ": " + GenText.ToStringByStyle(props.pelletCount, ToStringStyle.Integer)); } if (props.spreadMult != 1) { stringBuilder.AppendLine(" " + "CE_DescSpreadMult".Translate() + ": " + props.spreadMult.ToStringByStyle(ToStringStyle.PercentZero)); } // Fragments var fragmentComp = projectileDef.GetCompProperties <CompProperties_Fragments>(); if (fragmentComp != null) { stringBuilder.AppendLine(" " + "CE_DescFragments".Translate() + ":"); foreach (var fragmentDef in fragmentComp.fragments) { var fragmentProps = fragmentDef?.thingDef?.projectile as ProjectilePropertiesCE; stringBuilder.AppendLine(" " + " " + fragmentDef.LabelCap); stringBuilder.AppendLine(" " + " " + " " + "CE_DescSharpPenetration".Translate() + ": " + fragmentProps?.armorPenetrationSharp.ToStringByStyle(ToStringStyle.FloatTwo) + " " + "CE_mmRHA".Translate()); stringBuilder.AppendLine(" " + " " + " " + "CE_DescBluntPenetration".Translate() + ": " + fragmentProps?.armorPenetrationBlunt.ToStringByStyle(ToStringStyle.FloatTwo) + " " + "CE_MPa".Translate()); } } return(stringBuilder.ToString()); }
private static Animal MakeRow(ThingDef d) { var row = new Animal { Label = d.LabelCap, Description = d.DescriptionDetailed }; try { row.TexturePath = d.modContentPack.RootDir + @"\Textures\" + d.graphicData.texPath; } catch { } var fields = typeof(StatDefOf).GetFields(); foreach (var field in fields) { var rowProp = typeof(Animal).GetProperty(field.Name); if (rowProp != null) { var statDef = (StatDef)field.GetValue(null); float?value = d.GetStatValueAbstract(statDef); rowProp.SetValue(row, value.Nullify().ByStyle(statDef.toStringStyle), null); } } row.MeleeDPS_ = d.AnimalMeleeDps().Nullify().RoundTo2(); row.MeleeArmorPenetration = d.AnimalArmorPenetration().ToPercent(); row.ManhunterOnTameFailChance = d.race.manhunterOnTameFailChance.ToPercent(); row.Predator = d.race.predator; row.Wildness = d.race.wildness.ToPercent(); row.Petness = d.race.petness.ToPercent(); row.PackAnimal = d.race.packAnimal; row.HerdAnimal = d.race.herdAnimal; row.Trainability = d.race.trainability?.LabelCap; var milkable = d.GetCompProperties <CompProperties_Milkable>(); if (milkable != null) { row.MilkDef = milkable.milkDef.LabelCap; row.MilkIntervalDays = milkable.milkIntervalDays; row.MilkAmount = milkable.milkAmount; } var shearable = d.GetCompProperties <CompProperties_Shearable>(); if (shearable != null) { row.WoolDef = shearable.woolDef.LabelCap; row.ShearIntervalDays = shearable.shearIntervalDays; row.WoolAmount = shearable.woolAmount; } var rescueDef = DefDatabase <TrainableDef> .AllDefs.FirstOrDefault(td => td.defName == "Rescue"); var tr = d.race?.trainability?.intelligenceOrder; if (tr != null && rescueDef != null) { row.Train1 = tr >= TrainabilityDefOf.None.intelligenceOrder; row.Train2 = tr >= TrainabilityDefOf.Simple.intelligenceOrder; row.Train3 = tr >= TrainabilityDefOf.Intermediate.intelligenceOrder && d.race.baseBodySize >= rescueDef.minBodySize; row.Train4 = tr >= TrainabilityDefOf.Advanced.intelligenceOrder; } return(row); }
private bool CanCauseOverdose(ThingDef drug) { return(drug.GetCompProperties <CompProperties_Drug>()?.CanCauseOverdose ?? false); }
public static bool IsUpgradable(this ThingDef def, out CompProperties_Upgradable upgradableCompProps) { upgradableCompProps = def.GetCompProperties <CompProperties_Upgradable>(); return(upgradableCompProps != null); }
public override bool CanEverMatch(ThingDef def) { var compProperties = def.GetCompProperties <CompProperties_Rottable>(); return((compProperties != null) && !compProperties.rotDestroys); }
public override void Generate(Map map, GenStepParams parms) { //Log.Error("running"); List <ThingDef> source = (from x in DefDatabase <ThingDef> .AllDefsListForReading where x.category == ThingCategory.Plant && x.GetCompProperties <CompProperties_WaterPlant>() != null && x.GetCompProperties <CompProperties_WaterPlant>().allowedBiomes.Contains(map.Biome.defName) select x).ToList <ThingDef>(); //Log.Error("1"); if (source == null || source.Count == 0) { return; } //Log.Error(source[0].defName); foreach (IntVec3 c in map.AllCells) { ThingDef source2 = source[Rand.RangeInclusive(0, source.Count - 1)]; if (c.GetEdifice(map) == null && c.GetCover(map) == null && c.GetFirstBuilding(map) == null) { if (source2.GetCompProperties <CompProperties_WaterPlant>().allowedTiles.Contains(c.GetTerrain(map))) { if (Rand.Chance(source2.GetCompProperties <CompProperties_WaterPlant>().spawnChance)) { Plant plant = (Plant)ThingMaker.MakeThing(source2, null); 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); } } else { if (source2.GetCompProperties <CompProperties_WaterPlant>().growNearWater) { bool flag = false; for (int i = c.x - 1; i < c.x + 2; i++) { for (int j = c.z - 1; j < c.z + 2; j++) { IntVec3 temp = new IntVec3(i, 0, j); if (temp.InBounds(map) && source2.GetCompProperties <CompProperties_WaterPlant>().allowedTiles.Contains(temp.GetTerrain(map)) && !IsWater(temp, map) && !(temp.GetTerrain(map).defName == "Marsh")) { if (Rand.Chance(source2.GetCompProperties <CompProperties_WaterPlant>().spawnChance)) { Plant plant = (Plant)ThingMaker.MakeThing(source2, null); 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); flag = true; } } if (flag) { break; } } if (flag) { break; } } } } } } }
public static CommunityCoreLibrary.CompProperties_LowIdleDraw CompProperties_LowIdleDraw(this ThingDef thingDef) { return(thingDef.GetCompProperties <CompProperties_LowIdleDraw>()); }
public static CommunityCoreLibrary.CompProperties_ColoredLight CompProperties_ColoredLight(this ThingDef thingDef) { return(thingDef.GetCompProperties <CompProperties_ColoredLight>()); }
internal static ThingDef CreateNanoBedDefFromSupportedBed(this ThingDef bed, Action <ThingDef> fnAdditionalProcessing, List <ThingDef> linkableBuildings, List <CompProperties_Facility> facilities) { Type typeRimworldBed = typeof(Building_Bed); Type bedToClone = bed.GetType(); if (typeRimworldBed.IsAssignableFrom(bedToClone)) { throw new Exception("Type [" + bedToClone.Name + "] is not supported."); } FieldInfo[] fields = typeof(ThingDef).GetFields(BindingFlags.Public | BindingFlags.Instance); ThingDef nBed = new ThingDef(); foreach (FieldInfo field in fields) { field.SetValue(nBed, field.GetValue(bed)); } nBed.comps = new List <CompProperties>(); for (int i = 0; i < bed.comps.Count; i++) { ConstructorInfo constructor = bed.comps[i].GetType().GetConstructor(Type.EmptyTypes); CompProperties comp = (CompProperties)constructor.Invoke(null); fields = comp.GetType().GetFields(BindingFlags.Public | BindingFlags.Instance); foreach (FieldInfo field in fields) { field.SetValue(comp, field.GetValue(bed.comps[i])); } nBed.comps.Add(comp); } nBed.statBases.Add(new StatModifier() { stat = StatDef.Named("Ogre_NanoApparelRate"), value = 0 }); nBed.statBases.Add(new StatModifier() { stat = StatDef.Named("Ogre_NanoWeaponsRate"), value = 0 }); CompProperties_Power power = new CompProperties_Power(); power.compClass = typeof(CompPowerTrader); power.basePowerConsumption = 60f; power.shortCircuitInRain = false; nBed.comps.Add(power); CompProperties_Flickable flick = new CompProperties_Flickable(); flick.compClass = typeof(CompFlickable); nBed.comps.Add(flick); CompProperties_Refuelable fuel = new CompProperties_Refuelable(); fuel.fuelConsumptionRate = 0; fuel.fuelCapacity = 25.0f * bed.size.x; // same way it calculates in BedUtility fuel.consumeFuelOnlyWhenUsed = true; fuel.fuelFilter = new ThingFilter(); fuel.fuelFilter.SetAllow(ThingDef.Named("Ogre_NanoTechFuel"), true); nBed.comps.Add(fuel); Dictionary <string, int> cost = new Dictionary <string, int>() { { "ComponentIndustrial", 2 }, { "Steel", 30 }, { "Plasteel", 15 } }; if (!bed.building.bed_humanlike) { cost["Steel"] = 15; cost["Plasteel"] = 5; } if (nBed.costList == null) { nBed.costList = new List <ThingDefCountClass>(); } Dictionary <string, ThingDefCountClass> current = nBed.costList.ToDictionary(x => x.thingDef.defName, y => y); foreach (string item in cost.Keys) { ThingDefCountClass count = null; if (!current.TryGetValue(item, out count)) { count = new ThingDefCountClass(ThingDef.Named(item), cost[item]); nBed.costList.Add(count); } else { count.count += cost[item]; } } bool found = false; nBed.researchPrerequisites = new List <ResearchProjectDef>(); if (bed.researchPrerequisites != null && bed.researchPrerequisites.Count > 0) { foreach (ResearchProjectDef d in bed.researchPrerequisites) { if (d.defName == "Ogre_NanoTech") { found = true; } nBed.researchPrerequisites.Add(d); } } if (!found) { nBed.researchPrerequisites.Add(ResearchProjectDef.Named("Ogre_NanoTech")); } nBed.defName += "_NanoBed"; nBed.description += "\n\n" + TranslatorFormattedStringExtensions.Translate("NanoTech.Description.Short"); nBed.label = TranslatorFormattedStringExtensions.Translate("NanoTech.ModName.Short") + " " + nBed.label; nBed.thingClass = typeof(NanoBed); nBed.tradeability = Tradeability.None; nBed.scatterableOnMapGen = false; nBed.tickerType = TickerType.Rare; nBed.constructionSkillPrerequisite = 8; nBed.uiIconScale = 0.9f; nBed.techLevel = TechLevel.Industrial; nBed.shortHash = 0; nBed.designationCategory = DefDatabase <DesignationCategoryDef> .AllDefsListForReading.Find(x => x.defName == "Ogre_NanoRepairTech_DesignationCategory"); MethodInfo newBluePrintDef = typeof(RimWorld.ThingDefGenerator_Buildings).GetMethod("NewBlueprintDef_Thing", BindingFlags.Static | BindingFlags.NonPublic); nBed.blueprintDef = (ThingDef)newBluePrintDef.Invoke(null, new object[] { nBed, false, null }); MethodInfo newFrameDef = typeof(RimWorld.ThingDefGenerator_Buildings).GetMethod("NewFrameDef_Thing", BindingFlags.Static | BindingFlags.NonPublic); nBed.frameDef = (ThingDef)newFrameDef.Invoke(null, new object[] { nBed }); if (bed.building.bed_humanlike) { CompProperties_AffectedByFacilities abf = nBed.GetCompProperties <CompProperties_AffectedByFacilities>(); if (abf == null) { abf = new CompProperties_AffectedByFacilities(); nBed.comps.Add(abf); } if (abf.linkableFacilities == null) { abf.linkableFacilities = new List <ThingDef>(); } abf.linkableFacilities.AddRange(linkableBuildings); foreach (CompProperties_Facility f in facilities) { f.linkableBuildings.Add(nBed); } } if (fnAdditionalProcessing != null) { fnAdditionalProcessing.Invoke(nBed); } typeof(ShortHashGiver).GetMethod("GiveShortHash", BindingFlags.NonPublic | BindingFlags.Static).Invoke(null, new object[] { nBed, typeof(ThingDef) }); return(nBed); }
/// <summary> /// checks if this generator handles the given props. /// </summary> /// <param name="thingDef">The thing definition.</param> /// <returns></returns> public override bool HandlesThingDef(ThingDef thingDef) { return(CheckComp(thingDef?.GetCompProperties <MutationGenomeStorageProps>())); }
private static bool <GenerateAddictionsAndTolerancesFor> m__0(ThingDef x) { return(x.category == ThingCategory.Item && x.GetCompProperties <CompProperties_Drug>() != null); }
public static CompProperties_Rottable CompProperties_Rottable(this ThingDef thingDef) { return(thingDef.GetCompProperties <CompProperties_Rottable>()); }
public static bool IsTreasureDef(ThingDef def) { return(def.GetCompProperties <CompProperties_Treasure>() != null); }
private static bool WillRotSoon(this ThingDef d) { return(d.GetCompProperties <CompProperties_Rottable>()?.daysToRotStart < 6); }
public override bool CanEverMatch(ThingDef def) { return(def.IsIngestible && def.GetCompProperties <CompProperties_Ingredients>() != null || AlwaysMatches(def)); }
public override bool CanEverMatch(ThingDef def) { return(def.GetCompProperties <CompProperties_Rottable>() != null || def.IsIngestible); }
private bool CanCauseOverdose(ThingDef drug) { CompProperties_Drug compProperties = drug.GetCompProperties <CompProperties_Drug>(); return(compProperties != null && compProperties.CanCauseOverdose); }
public override bool AlwaysMatches(ThingDef def) { CompProperties_Rottable compProperties = def.GetCompProperties <CompProperties_Rottable>(); return((compProperties != null && compProperties.rotDestroys) || (compProperties == null && def.IsIngestible)); }
public static CompProperties_Drug GetDrugComp(ThingDef d) { return(d.GetCompProperties <CompProperties_Drug>()); }
private bool CanInjectInto(ThingDef thingDef) { return(thingDef.GetCompProperties <CompProperties_AffectedByFacilities>() != null); }
private static FoodCategory DetermineFoodCategory(ThingDef def) { if (def == null) { throw new ArgumentNullException(nameof(def)); } // List all foods with a race as huntable if (def.race != null) { return(FoodCategory.Hunt); } if (def.ingestible != null) { // If food has no nutritional value or is a drug ignore it if (def.ingestible.CachedNutrition <= 0f || def.IsDrug) { return(FoodCategory.Ignore); } FoodPreferability foodPref = def.ingestible.preferability; FoodTypeFlags foodType = def.ingestible.foodType; if (foodPref == FoodPreferability.NeverForNutrition) { return(FoodCategory.Ignore); } if (foodPref == FoodPreferability.MealFine) { return(FoodCategory.MealFine); } if (foodPref == FoodPreferability.MealAwful) { return(FoodCategory.MealAwful); } if (foodPref == FoodPreferability.MealSimple) { if (def == ThingDefOf.MealSurvivalPack || def == ThingDefOf.Pemmican) { return(FoodCategory.MealSurvival); } return(FoodCategory.MealSimple); } if (foodPref == FoodPreferability.MealLavish) { return(FoodCategory.MealLavish); } if ((foodType & FoodTypeFlags.Kibble) != 0) { return(FoodCategory.Kibble); } if ((foodType & FoodTypeFlags.AnimalProduct) != 0) { if (def.GetCompProperties <CompProperties_Hatcher>() != null) { return(FoodCategory.FertEggs); } return(FoodCategory.AnimalProduct); } if (def.ingestible.joyKind == JoyKindDefOf.Gluttonous && def.ingestible.joy >= 0.05f) { return(FoodCategory.Luxury); } if ((foodType & FoodTypeFlags.Tree) != 0) { return(FoodCategory.Tree); } if ((foodType & FoodTypeFlags.Plant) != 0) { if (def == ThingDefOf.Hay) { return(FoodCategory.Hay); } if (def.plant != null && !def.plant.sowTags.NullOrEmpty()) { return(FoodCategory.Plant); } if (def.thingCategories?.Contains(ThingCategoryDefOf.PlantMatter) ?? false) { return(FoodCategory.PlantMatter); } if (foodPref == FoodPreferability.DesperateOnly) { return(FoodCategory.Ignore); } return(FoodCategory.Grass); } if (def.IsCorpse) { if (RimWorld.FoodUtility.IsHumanlikeMeat(def)) { return(FoodCategory.HumanlikeCorpse); } if (def.FirstThingCategory == ThingCategoryDefOf.CorpsesInsect) { return(FoodCategory.InsectCorpse); } if (def.ingestible?.sourceDef?.race?.IsMechanoid ?? false) { return(FoodCategory.Ignore); } return(FoodCategory.Corpse); } if (def.ingestible.tasteThought != null && def.ingestible.tasteThought.stages.All((ThoughtStage arg) => arg.baseMoodEffect < 0)) { if (RimWorld.FoodUtility.IsHumanlikeMeat(def)) { return(FoodCategory.RawHuman); } if (def == ThingDef.Named("Meat_Megaspider") || def.ingestible.tasteThought == ThoughtDefOf.AteInsectMeatAsIngredient) { return(FoodCategory.RawInsect); } return(FoodCategory.RawBad); } if ((def.ingestible.tasteThought == null || def.ingestible.tasteThought.stages.All((ThoughtStage arg) => arg.baseMoodEffect >= 0))) { return(FoodCategory.RawTasty); } } // non ingestible corpse ? if (def.IsCorpse) { return(FoodCategory.Ignore); } return(FoodCategory.Null); }
/// <summary> /// Generates a readout text for a projectile with the damage amount, type, secondary explosion and other CE stats for /// display in info-box /// </summary> /// <param name="projectileDef">The projectile's ThingDef</param> /// <returns>Formatted string listing projectile stats</returns> public static string GetProjectileReadout(this ThingDef projectileDef, Thing weapon) { // Append ammo stats var props = projectileDef?.projectile as ProjectilePropertiesCE; if (props == null) { Log.Error("CE tried getting projectile readout with null props"); return(""); } var stringBuilder = new StringBuilder(); // Damage type/amount var dmgList = " " + "CE_DescDamage".Translate() + ": "; if (!props.secondaryDamage.NullOrEmpty()) { // If we have multiple damage types, put every one in its own line stringBuilder.AppendLine(dmgList); stringBuilder.AppendLine(" " + GenText.ToStringByStyle(props.GetDamageAmount(weapon), ToStringStyle.Integer) + " (" + props.damageDef.LabelCap + ")"); foreach (var sec in props.secondaryDamage) { stringBuilder.AppendLine(" " + GenText.ToStringByStyle(sec.amount, ToStringStyle.Integer) + " (" + sec.def.LabelCap + ")"); } } else { stringBuilder.AppendLine(dmgList + GenText.ToStringByStyle(props.GetDamageAmount(weapon), ToStringStyle.Integer) + " (" + props.damageDef.LabelCap + ")"); } // Explosion radius if (props.explosionRadius > 0) { stringBuilder.AppendLine(" " + "CE_DescExplosionRadius".Translate() + ": " + props.explosionRadius.ToStringByStyle(ToStringStyle.FloatOne)); } // Secondary explosion var secExpProps = projectileDef.GetCompProperties <CompProperties_ExplosiveCE>(); if (secExpProps != null) { if (secExpProps.explosiveRadius > 0) { stringBuilder.AppendLine(" " + "CE_DescSecondaryExplosion".Translate() + ":"); stringBuilder.AppendLine(" " + " " + "CE_DescExplosionRadius".Translate() + ": " + secExpProps.explosiveRadius.ToStringByStyle(ToStringStyle.FloatOne)); stringBuilder.AppendLine(" " + " " + "CE_DescDamage".Translate() + ": " + secExpProps.damageAmountBase.ToStringByStyle(ToStringStyle.Integer) + " (" + secExpProps.explosiveDamageType.LabelCap + ")"); } /* Fragrange never did anything * if (secExpProps.fragRange > 0) * { * stringBuilder.AppendLine(" " + "CE_DescFragRange".Translate() + ": " + secExpProps.fragRange.ToStringByStyle(ToStringStyle.FloatTwo)); * }*/ } // CE stats stringBuilder.AppendLine(" " + "CE_DescSharpPenetration".Translate() + ": " + props.armorPenetrationSharp.ToStringByStyle(ToStringStyle.FloatTwo) + " " + "CE_mmRHA".Translate()); stringBuilder.AppendLine(" " + "CE_DescBluntPenetration".Translate() + ": " + props.armorPenetrationBlunt.ToStringByStyle(ToStringStyle.FloatTwo) + " " + "CE_MPa".Translate()); if (props.pelletCount > 1) { stringBuilder.AppendLine(" " + "CE_DescPelletCount".Translate() + ": " + GenText.ToStringByStyle(props.pelletCount, ToStringStyle.Integer)); } if (props.spreadMult != 1) { stringBuilder.AppendLine(" " + "CE_DescSpreadMult".Translate() + ": " + props.spreadMult.ToStringByStyle(ToStringStyle.PercentZero)); } return(stringBuilder.ToString()); }
public static bool IsShipDef(ThingDef td) { return(td?.GetCompProperties <CompProperties_Ships>() != null); }
public static bool CanEverGetWater(ThingDef water, Pawn pawn) { var compprop = water.GetCompProperties <CompProperties_WaterSource>(); return(compprop != null && compprop.waterAmount > 0.0f && (compprop.waterType >= WaterType.SeaWater && compprop.waterType <= WaterType.ClearWater)); }