private void DrawNutritionEatenPerDay(Rect rect, TransferableOneWay trad) { if (!trad.HasAnyThing) { return; } Pawn p = trad.AnyThing as Pawn; if (p == null || !p.RaceProps.EatsFood || p.Dead || p.needs.food == null) { return; } Widgets.DrawHighlightIfMouseover(rect); string text = (p.needs.food.FoodFallPerTickAssumingCategory(HungerCategory.Fed, ignoreMalnutrition: true) * 60000f).ToString("0.##"); DietCategory resolvedDietCategory = p.RaceProps.ResolvedDietCategory; if (resolvedDietCategory != DietCategory.Omnivorous) { text = text + " (" + resolvedDietCategory.ToStringHumanShort() + ")"; } GUI.color = new Color(1f, 0.5f, 0f); Widgets.Label(rect, text); GUI.color = Color.white; if (Mouse.IsOver(rect)) { TooltipHandler.TipRegion(rect, () => RaceProperties.NutritionEatenPerDayExplanation_NewTemp(p, showDiet: true, showLegend: true, showCalculations: false), trad.GetHashCode() ^ 0x17016B3E); } }
private static void Postfix(ThingDef t, RaceProperties __instance, ref bool __result) { if (__result && __instance.Humanlike && DefDatabase <ThingDef> .AllDefsListForReading.First((ThingDef x) => x.race == __instance) is ThingDef thingDef) { __result = RaceAddonTools.CheckFood(thingDef, t); } }
static void PostFix(ref RaceProperties __instance, ref bool __result) { if (__instance.FleshType == FleshTypeDefOf.Mechanoid && __instance?.body.defName == "VFEV_Odin") { __result = false; } }
public static void FillOrderProcessorFromPawnKindDef(ThingOrderProcessor orderProcessor, PawnKindDef pawnKind) { ThingDef pawnThingDef = pawnKind.race; RaceProperties raceProps = pawnThingDef.race; //Assemble all required materials for a fully grown adult. //Meat is worth the full nutritional value. ThingDef meatDef = raceProps.meatDef; float meatBaseNutrition = meatDef.ingestible.CachedNutrition; float meatAmount = pawnThingDef.GetStatValueAbstract(StatDefOf.MeatAmount) * raceProps.baseBodySize; //Leather is worth half of the meat value. float leatherAmount = pawnThingDef.GetStatValueAbstract(StatDefOf.LeatherAmount) * raceProps.baseBodySize; int proteinAmount = (int)(meatAmount * meatBaseNutrition * 15f) + (int)(leatherAmount * meatBaseNutrition * 15f); int nutritionAmount = (int)(proteinAmount * 4.5f); { ThingOrderRequest orderRequest = new ThingOrderRequest(QEThingDefOf.QE_ProteinMash, proteinAmount); orderProcessor.desiredIngredients.Add(orderRequest); } { ThingOrderRequest orderRequest = new ThingOrderRequest(QEThingDefOf.QE_NutrientSolution, nutritionAmount); orderProcessor.desiredIngredients.Add(orderRequest); } }
public static void Postfix(ref bool __result, RaceProperties __instance) { if (__instance.FleshType == PRFDefOf.PRFDroneFlesh) { __result = false; } }
public override void DefsLoaded() { if (!this.ModIsActive) { return; } IEnumerable <ThingDef> thingDefs = DefDatabase <ThingDef> .AllDefs.Where <ThingDef>((Func <ThingDef, bool>)(def => { RaceProperties race = def.race; if ((race != null ? (race.intelligence == Intelligence.Humanlike ? 1 : 0) : 0) == 0) { return(false); } return(true); })); foreach (ThingDef thingDef in thingDefs) { if (thingDef.inspectorTabsResolved == null) { thingDef.inspectorTabsResolved = new List <InspectTabBase>(1); } thingDef.inspectorTabsResolved.Add(InspectTabManager.GetSharedInstance(typeof(ITab_Pawn_Religion))); if (thingDef.comps == null) { thingDef.comps = new List <CompProperties>(1); } thingDef.comps.Add((CompProperties) new CompProperties_ReligionComp()); } }
public static int CountProducts_Postfix(int prev, Bill_Production bill) { // Sanity/compatibility check if (bill.recipe.specialProducts.Contains(Verse.SpecialProductType.Butchery)) { // Find the allowed meat types based on allowed corpse types in ingredient filter HashSet <ThingDef> allowedMeatDefs = new HashSet <ThingDef>(); foreach (ThingDef allowedThingDef in bill.ingredientFilter.AllowedThingDefs) { if (allowedThingDef.ingestible != null && allowedThingDef.ingestible.sourceDef != null) { RaceProperties race = allowedThingDef.ingestible.sourceDef.race; if (race != null && race.meatDef != null) { allowedMeatDefs.Add(race.meatDef); } } } // Substract from the normal result any meat types not allowed foreach (ThingDef meatDef in ThingCategoryDefOf.MeatRaw.childThingDefs) { if (!allowedMeatDefs.Contains(meatDef)) { prev -= bill.Map.resourceCounter.GetCount(meatDef); } } } // return (possibly adjusted) result return(prev); }
public static void FillOrderProcessorFromPawnKindDef(ThingOrderProcessor orderProcessor, PawnKindDef pawnKind) { ThingDef pawnThingDef = pawnKind.race; RaceProperties raceProps = pawnThingDef.race; //Assemble all required materials for a fully grown adult. ThingDef meatDef = raceProps.meatDef; float meatBaseNutrition = meatDef.ingestible.CachedNutrition; float meatAmount = pawnThingDef.GetStatValueAbstract(StatDefOf.MeatAmount); int nutritionAmount, proteinAmount; //protein cost = Meat * base Meat nutrition (vanilla is .05) * magic multiplier of 27 //Minimum protein cost is 25, max is 750. Multiply by mod setting for clone ingredients //finally, round up to the nearest number divisible by 5 proteinAmount = (int)(Math.Ceiling((meatAmount * meatBaseNutrition * 27f).Clamp(25, 750) * QEESettings.instance.cloneTotalResourcesFloat / 5) * 5); nutritionAmount = 4 * proteinAmount; { ThingOrderRequest orderRequest = new ThingOrderRequest(QEThingDefOf.QE_ProteinMash, proteinAmount); orderProcessor.desiredIngredients.Add(orderRequest); } { ThingOrderRequest orderRequest = new ThingOrderRequest(QEThingDefOf.QE_NutrientSolution, nutritionAmount); orderProcessor.desiredIngredients.Add(orderRequest); } }
public static bool IsCorpseOfColonist(ref bool __result, Corpse corpse) { if (corpse == null) { __result = false; return(false); } Pawn InnerPawn = corpse.InnerPawn; if (InnerPawn == null) { __result = false; return(false); } ThingDef def = InnerPawn.def; if (def == null) { __result = false; return(false); } RaceProperties race = def.race; if (race == null) { __result = false; return(false); } __result = InnerPawn.Faction == Faction.OfPlayer && race.Humanlike && (!InnerPawn.IsQuestLodger() && !InnerPawn.IsSlave) && !corpse.IsInAnyStorage(); return(false); }
public static void Postfix(RaceProperties __instance, ref bool __result) { if (__result && __instance.FleshType.isConstruct()) { __result = false; // Log.Message("Construct found " + __instance.FleshType + " IsFlesh = " + __result); } }
public void Init() { race = new RaceProperties(); graphicInt = new Graphic(); graphicInt = def.graphicData.GraphicColoredFor(this); }
public static bool BoatsNotFlesh(ref bool __result, RaceProperties __instance) { if (__instance.FleshType == FleshTypeDefOf_Ships.WoodenShip || __instance.FleshType == FleshTypeDefOf_Ships.MetalShip) { __result = false; return(false); } return(true); }
static bool IsFlesh(RaceProperties __instance, ref bool __result) { if (__instance.FleshType == DefDatabase <FleshTypeDef> .GetNamed("MD3_Droid")) { __result = false; return(false); } return(true); }
public bool IsAffectedPredator(Pawn animal) { RaceProperties race = animal.def.race; if (race.predator && animal.Faction == Faction.OfPlayer) { return(false); // if colony predator, don't affect } return(!race.predator || race.maxPreyBodySize < HumanBodySize); // otherwise, return whether the animal would prey upon humans }
private static ThingDef humanlikeDef() { RaceProperties humanlikeRace = new RaceProperties(); humanlikeRace.intelligence = Intelligence.Humanlike; ThingDef def = new ThingDef(); def.race = humanlikeRace; return(def); }
static bool Prefix(ref bool __result, RaceProperties __instance) { if (__instance.FleshType == Globals.AutocleanerMechanoid) { __result = false; return(false); } return(true); }
public Consumer(string s, RaceProperties r, int infant, int teen, int adult, float nut, float food) { label = s; numAdult = adult; numTeen = teen; numInfant = infant; numTotal = numAdult + numTeen + numInfant; totalNutr = nut; numFood = food; prop = r; }
public static bool IsValidGuestPawn(this Pawn pawn) { if (pawn == null) { return(false); } if (pawn.Destroyed) { return(false); } if (!pawn.Spawned) { return(false); } if (pawn.thingIDNumber == 0) { return(false); } if (pawn.Name == null) { return(false); } if (pawn.Dead) { return(false); } RaceProperties raceProps = pawn.RaceProps; if (raceProps == null || !raceProps.Humanlike) { return(false); } if (pawn.guest == null) { return(false); } if (pawn.guest.HostFaction != Faction.OfPlayer && pawn.Map.ParentFaction != Faction.OfPlayer) { return(false); } if (pawn.Faction == null) { return(false); } if (pawn.IsPrisonerOfColony || pawn.Faction == Faction.OfPlayer) { return(false); } if (pawn.HostileTo(Faction.OfPlayer)) { return(false); } return(true); }
public static void PrepareIniRaceMode(RaceProperties properties) { var ini = Path.Combine(FileUtils.GetDocumentsCfgDirectory(), "race.ini"); var iniFile = new IniFile(ini); for (var i = 1; i < 100; i++) { var key = "CAR_" + i; if (iniFile.ContainsKey(key)) { iniFile.Remove(key); } else { break; } } iniFile.Save(); DisableGhostCar(); IniFile.Write(ini, "RACE", "CARS", properties.BotCars.Count() + 1); IniFile.Write(ini, "RACE", "AI_LEVEL", properties.AiLevel.RoundToInt()); IniFile.Write(ini, "RACE", "DRIFT_MODE", "0"); IniFile.Write(ini, "RACE", "RACE_LAPS", properties.RaceLaps); IniFile.Write(ini, "RACE", "FIXED_SETUP", properties.FixedSetup); IniFile.Write(ini, "RACE", "PENALTIES", properties.Penalties); IniFile.Write(ini, "GROOVE", "VIRTUAL_LAPS", "10"); IniFile.Write(ini, "GROOVE", "MAX_LAPS", "30"); IniFile.Write(ini, "GROOVE", "STARTING_LAPS", "0"); IniFile.Write(ini, "SESSION_0", "NAME", "Quick Race"); IniFile.Write(ini, "SESSION_0", "TYPE", "3"); IniFile.Write(ini, "SESSION_0", "LAPS", properties.RaceLaps); IniFile.Write(ini, "SESSION_0", "STARTING_POSITION", properties.StartingPosition); IniFile.Write(ini, "SESSION_0", "DURATION_MINUTES", "0"); IniFile.Write(ini, "SESSION_0", "SPAWN_SET", "START"); var j = 0; foreach (var botCar in properties.BotCars) { var section = "CAR_" + ++j; IniFile.Write(ini, section, "MODEL", botCar.CarId); IniFile.Write(ini, section, "MODEL_CONFIG", ""); IniFile.Write(ini, section, "SETUP", botCar.Setup); IniFile.Write(ini, section, "AI_LEVEL", botCar.AiLevel.RoundToInt()); IniFile.Write(ini, section, "SKIN", botCar.SkinId); IniFile.Write(ini, section, "DRIVER_NAME", botCar.DriverName); IniFile.Write(ini, section, "NATIONALITY", botCar.Nationality); } }
protected virtual bool DoesMatch(Corpse corpse) { if (corpse == null) { return(false); } RaceProperties race = corpse.InnerPawn.RaceProps; return(race.Humanlike && !race.Animal && HasBionic(corpse) == harvestable); }
/// <summary> /// Converts the age from one race to the equivalent age of another race /// </summary> /// <param name="originalRace">The original race.</param> /// <param name="endRace">The end race.</param> /// <param name="originalAge">The original age.</param> /// <returns></returns> /// <exception cref="ArgumentNullException"> /// originalRace /// or /// endRace /// </exception> public static float ConvertAge([NotNull] RaceProperties originalRace, [NotNull] RaceProperties endRace, float originalAge) { if (originalRace == null) { throw new ArgumentNullException(nameof(originalRace)); } if (endRace == null) { throw new ArgumentNullException(nameof(endRace)); } return(ConvertAge(originalAge, originalRace.lifeExpectancy, endRace.lifeExpectancy)); }
/// <summary> Converts the age of the given pawn into an equivalent age of the given race. </summary> /// <param name="originalPawn"> The original pawn. </param> /// <param name="race"> The end race. </param> public static float ConvertAge([NotNull] Pawn originalPawn, [NotNull] RaceProperties race) { if (originalPawn?.RaceProps == null) { throw new ArgumentNullException(nameof(originalPawn)); } if (race == null) { throw new ArgumentNullException(nameof(race)); } return(ConvertAge(originalPawn.RaceProps, race, originalPawn.ageTracker.AgeBiologicalYears)); }
// Token: 0x060000E7 RID: 231 RVA: 0x00007CC8 File Offset: 0x00005EC8 private static void MSPainlessData_Setup_Pawns() { HediffGiverSetDef Organic = DefDatabase <HediffGiverSetDef> .GetNamed("OrganicStandard", true); MSPainlessData.MSPainlessData_Setup.MSPainlessDataSetup_Comp(typeof(MSPainlessData.CompProperties_MSPainlessData), delegate(ThingDef def) { RaceProperties race = def.race; if (race != null && race.Humanlike) { RaceProperties race2 = def.race; return((race2?.hediffGiverSets) != null && def.race.hediffGiverSets.Contains(Organic)); } return(false); }); }
public static void Notify_PawnKilled(Pawn killed, Pawn killer) { killer.records.Increment(RecordDefOf.Kills); RaceProperties raceProps = killed.RaceProps; if (raceProps.Humanlike) { killer.records.Increment(RecordDefOf.KillsHumanlikes); } if (raceProps.Animal) { killer.records.Increment(RecordDefOf.KillsAnimals); } if (raceProps.IsMechanoid) { killer.records.Increment(RecordDefOf.KillsMechanoids); } }
public static void Notify_PawnDowned(Pawn downed, Pawn instigator) { instigator.records.Increment(RecordDefOf.PawnsDowned); RaceProperties raceProps = downed.RaceProps; if (raceProps.Humanlike) { instigator.records.Increment(RecordDefOf.PawnsDownedHumanlikes); } if (raceProps.Animal) { instigator.records.Increment(RecordDefOf.PawnsDownedAnimals); } if (raceProps.IsMechanoid) { instigator.records.Increment(RecordDefOf.PawnsDownedMechanoids); } }
static (float bodySize, float hungerSize) GetFoodStats([NotNull] RaceProperties human, [NotNull] RaceProperties animal) { //'gamma' is a ratio describing how long it takes an animal to become hungry //larger values mean the animal needs to eat less often float gammaH = human.baseBodySize / human.baseHungerRate; float gammaA = animal.baseBodySize / animal.baseHungerRate; float f = Mathf.Pow(Math.Abs((gammaA - gammaH) / gammaH), 0.5f); //scale things back a bit if the animal has very different hunger characteristics then humans float a = 1 / (1f + f); float hGamma = Mathf.Lerp(gammaA, gammaH, a); //body size is just an average of animal and human float hBSize = Mathf.Lerp(animal.baseBodySize, human.baseBodySize, a); float hHRate = hBSize / hGamma; //calculate the hunger rate the hybrid should have to have an average gamma value between the animal and human return(hBSize, hHRate); }
private static RaceProperties GenerateHybridProperties([NotNull] RaceProperties human, [NotNull] RaceProperties animal) { (float hSize, float hHRate) = GetFoodStats(human, animal); return(new RaceProperties { thinkTreeMain = human.thinkTreeMain, //most of these are just guesses, have to figure out what's safe to change and what isn't thinkTreeConstant = human.thinkTreeConstant, intelligence = human.intelligence, makesFootprints = true, lifeExpectancy = human.lifeExpectancy, leatherDef = animal.leatherDef, nameCategory = human.nameCategory, body = human.body, baseBodySize = hSize, baseHealthScale = Mathf.Lerp(human.baseHealthScale, animal.baseHealthScale, HEALTH_SCALE_LERP_VALUE), baseHungerRate = hHRate, foodType = GenerateFoodFlags(animal.foodType), gestationPeriodDays = human.gestationPeriodDays, wildness = animal.wildness / 2, meatColor = animal.meatColor, meatMarketValue = animal.meatMarketValue, manhunterOnDamageChance = animal.manhunterOnDamageChance, manhunterOnTameFailChance = animal.manhunterOnTameFailChance, litterSizeCurve = human.litterSizeCurve, lifeStageAges = MakeLifeStages(human.lifeStageAges, animal.lifeStageAges), soundMeleeHitPawn = animal.soundMeleeHitPawn, soundMeleeHitBuilding = animal.soundMeleeHitBuilding, trainability = GetTrainability(animal.trainability), soundMeleeMiss = animal.soundMeleeMiss, specialShadowData = human.specialShadowData, soundCallIntervalRange = animal.soundCallIntervalRange, ageGenerationCurve = human.ageGenerationCurve, hediffGiverSets = human.hediffGiverSets.ToList(), meatDef = animal.meatDef, meatLabel = animal.meatLabel, useMeatFrom = animal.useMeatFrom, deathActionWorkerClass = animal.deathActionWorkerClass, // Boommorphs should explode. corpseDef = human.corpseDef, packAnimal = animal.packAnimal }); }
protected virtual bool DoesMatch(Corpse corpse) { if (corpse == null) { return(false); } RaceProperties race = corpse.InnerPawn.RaceProps; if (race.Humanlike) { IEnumerable <BodyPartRecord> source = from x in corpse.InnerPawn.health.hediffSet.GetNotMissingParts(BodyPartHeight.Undefined, BodyPartDepth.Undefined) where DissectionUtility.DissectableBodyParts.Contains(x.def) select x; bool hasDissectableParts = source.Any(); return((corpse.InnerPawn.health.hediffSet.HasHediff(DissectionDefOf.DissectedHediff) || !hasDissectableParts) == ShouldBeDissected()); } return(false); }
private static void CanEverEat(ref bool __result, RaceProperties __instance, ThingDef t) { if (!__instance.Humanlike) { return; } ThingDef race; if (!RaceDb.TryGetValue(__instance, out race)) { race = DefDatabase <ThingDef> .AllDefsListForReading.ToList() .Concat(U.DefDatabaseAllDefs("AlienRace.ThingDef_AlienRace").Cast <ThingDef>().ToList()) .First(td => td.race == __instance); RaceDb[__instance] = race; } __result = __result && (bool)_canEatMethod.Invoke(null, new object[] { t, race }); }
public static void Notify_PawnDiedPostfix(Pawn victim) { RaceProperties raceProps = victim.RaceProps; var pawnIsImplanted = victim.health?.hediffSet?.GetFirstHediffOfDef(QEHediffDefOf.Clonebay_Implant); if (raceProps.Humanlike && victim.IsColonist && pawnIsImplanted != null) { Thing genomeSequence = GenomeUtility.MakeGenomeSequence(victim, QEThingDefOf.Clonebay_GenomeSequencerFilled); if (genomeSequence == null) { Log.Warning("CloneBay: Failed to create a new genomesequence"); return; } GenomeSequence genome = genomeSequence as GenomeSequence; IntVec3 cell = victim.Position; victim.equipment.DropAllEquipment(cell); victim.apparel.DropAll(cell); victim.inventory.DropAllNearPawn(cell); Pawn prevPawn = victim as Pawn; foreach (Building_PawnVatGrower vatToUse in victim.Map.listerBuildings.AllBuildingsColonistOfClass <Building_PawnVatGrower>()) { if (vatToUse.status != CrafterStatus.Crafting) { float fuel = vatToUse.TryGetComp <CompRefuelable>().Fuel; if (fuel > 99) { vatToUse.Notify_CraftingStarted(genome, prevPawn, cell); vatToUse.TryGetComp <CompRefuelable>().ConsumeFuel(100); } break; } } } }
public static void PrepareIniRaceMode(RaceProperties properties) { var ini = Path.Combine(FileUtils.GetDocumentsCfgDirectory(), "race.ini"); var iniFile = new IniFile(ini); for (var i = 1; i < 100; i++) { var key = "CAR_" + i; if (iniFile.ContainsKey(key)) { iniFile.Remove(key); } else { break; } } iniFile.Save(); DisableGhostCar(); IniFile.Write(ini, "RACE", "CARS", properties.BotCars.Count() + 1); IniFile.Write(ini, "RACE", "AI_LEVEL", properties.AiLevel); IniFile.Write(ini, "RACE", "DRIFT_MODE", "0"); IniFile.Write(ini, "RACE", "RACE_LAPS", properties.RaceLaps); IniFile.Write(ini, "RACE", "FIXED_SETUP", properties.FixedSetup); IniFile.Write(ini, "RACE", "PENALTIES", properties.Penalties); IniFile.Write(ini, "GROOVE", "VIRTUAL_LAPS", "10"); IniFile.Write(ini, "GROOVE", "MAX_LAPS", "30"); IniFile.Write(ini, "GROOVE", "STARTING_LAPS", "0"); IniFile.Write(ini, "SESSION_0", "NAME", "Quick Race"); IniFile.Write(ini, "SESSION_0", "TYPE", "3"); IniFile.Write(ini, "SESSION_0", "LAPS", properties.RaceLaps); IniFile.Write(ini, "SESSION_0", "STARTING_POSITION", properties.StartingPosition); IniFile.Write(ini, "SESSION_0", "DURATION_MINUTES", "0"); IniFile.Write(ini, "SESSION_0", "SPAWN_SET", "START"); var j = 0; foreach (var botCar in properties.BotCars) { var section = "CAR_" + ++j; IniFile.Write(ini, section, "MODEL", botCar.CarId); IniFile.Write(ini, section, "MODEL_CONFIG", ""); IniFile.Write(ini, section, "SETUP", botCar.Setup); IniFile.Write(ini, section, "AI_LEVEL", botCar.AiLevel); IniFile.Write(ini, section, "SKIN", botCar.SkinId); IniFile.Write(ini, section, "DRIVER_NAME", botCar.DriverName); IniFile.Write(ini, section, "NATIONALITY", botCar.Nationality); } }
public static void StartRace(string acRoot, string carName, string skinName, string trackName, string trackConfig, RaceProperties properties) { PrepareIni(carName, skinName, trackName, trackConfig); PrepareIniRaceMode(properties); Start(acRoot); }