public TipSignal?GetAnimalTooltip(TrainableDef def = null) { var builder = new StringBuilder(); builder.AppendLine(Lang.Get("Model.Bio.Trainability", Base.RaceProps.trainability.LabelCap)); builder.AppendLine(Lang.Get("Model.Bio.Wildness", Base.RaceProps.wildness.ToStringPercent())); builder.AppendLine($"{"TrainingDecayInterval".Translate()}: {TrainableUtility.DegradationPeriodTicks(Base.def).ToStringTicksToDays()}"); if (!TrainableUtility.TamenessCanDecay(Base.def)) { builder.AppendLine("TamenessWillNotDecay".Translate()); } builder.AppendLine(Lang.Get("Model.Bio.Petness", Base.RaceProps.petness.ToStringPercent())); builder.AppendLine(Lang.Get("Model.Bio.Diet", Base.RaceProps.ResolvedDietCategory.ToStringHuman())); var master = Base.playerSettings?.Master?.LabelShort; if (!master.NullOrEmpty()) { builder.AppendLine(); builder.AppendLine(Lang.Get("Model.Bio.Master", master)); } if (def != null) { builder.AppendLine(); builder.AppendLine(def.description); } var text = builder.ToStringTrimmed().Size(Theme.RegularTextStyle.ActualSize); return(new TipSignal(() => text, GUIPlus.TooltipId)); }
public override Job GetJob(Pawn meeseeks, CompMeeseeksMemory memory, SavedJob savedJob, SavedTargetInfo jobTarget, ref JobAvailability jobAvailabilty) { Job job = null; WorkGiver_Scanner scanner = savedJob.WorkGiverScanner; if (scanner != null && jobTarget != null && jobTarget.HasThing && !jobTarget.ThingDestroyed && jobTarget.Thing is Pawn) { Pawn targetPawn = jobTarget.Thing as Pawn; if (targetPawn.Dead) { Logger.MessageFormat(this, "{0} dead.", targetPawn); jobAvailabilty = JobAvailability.Complete; } else if (this.TrainingCompleted(meeseeks, targetPawn, jobTarget)) { jobAvailabilty = JobAvailability.Complete; } else if (targetPawn.RaceProps.EatsFood && !HasFoodToInteractAnimal(meeseeks, targetPawn)) { job = TakeFoodForAnimalInteractJob(meeseeks, targetPawn); } else if (TrainableUtility.TrainedTooRecently(targetPawn)) { jobAvailabilty = JobAvailability.Delayed; } else if (targetPawn.MapHeld != meeseeks.MapHeld) { Logger.MessageFormat(this, "{0} not on map with {1}.", targetPawn); job = ExitMapJob(meeseeks); } else if (targetPawn.Spawned) { job = this.GetJobOnTarget(meeseeks, jobTarget, scanner); if (job == null) { jobAvailabilty = JobAvailability.Delayed; } } else { Logger.WarningFormat(this, "Could not get handling job for {0}.", targetPawn); jobAvailabilty = JobAvailability.Delayed; } } else { Logger.WarningFormat(this, "Unable to get scanner or target for job."); } if (job != null) { jobAvailabilty = JobAvailability.Available; } return(job); }
public IEnumerable <StatDrawEntry> SpecialDisplayStats(ThingDef parentDef) { yield return(new StatDrawEntry(StatCategoryDefOf.Basics, "Race".Translate(), parentDef.LabelCap, 2000, "")); yield return(new StatDrawEntry(StatCategoryDefOf.Basics, "Diet".Translate(), this.foodType.ToHumanString().CapitalizeFirst(), 0, "")); if (parentDef.race.leatherDef != null) { yield return(new StatDrawEntry(StatCategoryDefOf.Basics, "LeatherType".Translate(), parentDef.race.leatherDef.LabelCap, 0, "")); } if (parentDef.race.Animal || this.wildness > 0f) { yield return(new StatDrawEntry(StatCategoryDefOf.Basics, "Wildness".Translate(), this.wildness.ToStringPercent(), 0, "") { overrideReportText = TrainableUtility.GetWildnessExplanation(parentDef) }); } yield return(new StatDrawEntry(StatCategoryDefOf.Basics, "HarmedRevengeChance".Translate(), PawnUtility.GetManhunterOnDamageChance(parentDef.race).ToStringPercent(), 0, "") { overrideReportText = "HarmedRevengeChanceExplanation".Translate() }); yield return(new StatDrawEntry(StatCategoryDefOf.Basics, "TameFailedRevengeChance".Translate(), parentDef.race.manhunterOnTameFailChance.ToStringPercent(), 0, "")); if (this.intelligence < Intelligence.Humanlike && this.trainability != null) { yield return(new StatDrawEntry(StatCategoryDefOf.Basics, "Trainability".Translate(), this.trainability.LabelCap, 0, "")); } yield return(new StatDrawEntry(StatCategoryDefOf.Basics, "StatsReport_LifeExpectancy".Translate(), this.lifeExpectancy.ToStringByStyle(ToStringStyle.Integer, ToStringNumberSense.Absolute), 0, "")); if (this.intelligence < Intelligence.Humanlike) { yield return(new StatDrawEntry(StatCategoryDefOf.Basics, "AnimalFilthRate".Translate(), (PawnUtility.AnimalFilthChancePerCell(parentDef, parentDef.race.baseBodySize) * 1000f).ToString("F2"), 0, "") { overrideReportText = "AnimalFilthRateExplanation".Translate(new object[] { 1000.ToString() }) }); } if (this.packAnimal) { yield return(new StatDrawEntry(StatCategoryDefOf.Basics, "PackAnimal".Translate(), "Yes".Translate(), 0, "") { overrideReportText = "PackAnimalExplanation".Translate() }); } if (parentDef.race.nuzzleMtbHours > 0f) { yield return(new StatDrawEntry(StatCategoryDefOf.PawnSocial, "NuzzleInterval".Translate(), Mathf.RoundToInt(parentDef.race.nuzzleMtbHours * 2500f).ToStringTicksToPeriod(), 0, "") { overrideReportText = "NuzzleIntervalExplanation".Translate() }); } yield break; }
private static void RecheckTaming(ref bool __result, Pawn pawn, Pawn animal) { bool newResult = false; // We're only interested in reversing a failure to interact if (!__result) { // If the reason for failure is AnimalsSkillTooLow int animalSkillReq = TrainableUtility.MinimumHandlingSkill(animal); if (JobFailReason.Reason == "AnimalsSkillTooLow".Translate(animalSkillReq)) { // If the colonist has Inspired Taming if (pawn.InspirationDef == InspirationDefOf.Inspired_Taming) { // Get colonist's current Animal skill level int curSkill = pawn.skills.GetSkill(SkillDefOf.Animals).Level; // How much skill boost should be added by Inspired Taming int skillBoost = 0; switch (BoostSettings.Boost) { case BoostSettings.BoostType.Unlimited: // Boost skill to max skillBoost = 20 - curSkill; break; case BoostSettings.BoostType.Percentage: // Boost skill by percentage skillBoost = (int)Math.Floor(curSkill * BoostSettings.BoostPercentage); break; case BoostSettings.BoostType.Levels: // Boost skill by number of levels skillBoost = (int)BoostSettings.BoostLevels; break; } if ((curSkill + skillBoost) >= animalSkillReq) { // Allow the colonist to tame the animal newResult = true; } else { // The colonist's skill is still too low to tame the animal JobFailReason.Is("TIT_AnimalSkillStillTooLow".Translate(animalSkillReq, curSkill, skillBoost), null); newResult = false; } } } } // Pass the original result, but allow Inspired Taming to override it if applicable __result = __result || newResult; }
public static void DrawTrainingCard(Rect rect, Pawn pawn) { try { GUI.BeginGroup(rect); Rect rect2 = new Rect(0f, 0f, rect.width, 25f); string text = "Master".Translate() + ": "; Vector2 vector = Text.CalcSize(text); Widgets.Label(rect2, text); Rect rect3 = new Rect(rect2.x + vector.x + 6f, rect2.y, 200f, rect2.height); if (pawn.training.IsCompleted(TrainableDefOf.Obedience)) { rect3.y -= 1f; string label = TrainableUtility.MasterString(pawn); if (Widgets.TextButton(rect3, label, true, false)) { TrainableUtility.OpenMasterSelectMenu(pawn); } } else { GUI.color = new Color(0.7f, 0.7f, 0.7f); Widgets.Label(rect3, "None".Translate()); GUI.color = Color.white; } List <TrainableDef> trainableDefsInListOrder = TrainableUtility.TrainableDefsInListOrder; int count = trainableDefsInListOrder.Count; float height = (float)(count * 28 + 20); Rect rect4 = new Rect(0f, rect2.y + 35f, rect.width, height); TabDrawer.DrawBox(rect4); Rect rect5 = rect4.ContractedBy(10f); rect5.height = 28f; for (int i = 0; i < trainableDefsInListOrder.Count; i++) { if (TrainingCardUtility.TryDrawTrainableRow(rect5, pawn, trainableDefsInListOrder[i])) { rect5.y += 28f; } } Text.Anchor = TextAnchor.UpperRight; string label2 = "TrainableIntelligence".Translate() + ": " + pawn.RaceProps.trainableIntelligence.GetLabel(); Widgets.Label(new Rect(0f, rect4.y + rect4.height + 5f, rect4.width - 2f, 25f), label2); Text.Anchor = TextAnchor.UpperLeft; } finally { GUI.EndGroup(); } }
private void DoHandlerFloatMenu(Pawn target) { var settings = target.handlerSettings(); var minSkill = TrainableUtility.MinimumHandlingSkill(target); var options = new List <FloatMenuOption>(); options.Add(new FloatMenuOption(HandlerMode.Any.Label(), () => settings.Mode = HandlerMode.Any)); options.Add(new FloatMenuOption(HandlerMode.Level.Label(), () => settings.Mode = HandlerMode.Level)); foreach (var handler in HandlerUtility.HandlersOrdered(target.Map)) { options.Add(new FloatMenuOption(HandlerUtility.HandlerLabel(handler, minSkill), () => settings.Handler = handler)); } Find.WindowStack.Add(new FloatMenu(options)); }
// Token: 0x06002241 RID: 8769 RVA: 0x00101EB8 File Offset: 0x001002B8 public override IEnumerable <Thing> PlayerStartingThings() { for (int i = 0; i < this.count; i++) { PawnKindDef kind; if (this.animalKind != null) { kind = this.animalKind; } else { kind = this.RandomPets().RandomElementByWeight((PawnKindDef td) => td.RaceProps.petness); } Pawn animal = PawnGenerator.GeneratePawn(kind, Faction.OfPlayer); if (animal.Name == null || animal.Name.Numerical) { animal.Name = PawnBioAndNameGenerator.GeneratePawnName(animal, NameStyle.Full, null); } Rand.PushState(); if (Rand.Value < this.bondToRandomPlayerPawnChance && animal.training.CanAssignToTrain(TrainableDefOf.Obedience).Accepted) { Pawn pawn = (from p in Find.GameInitData.startingAndOptionalPawns.Take(Find.GameInitData.startingPawnCount) where TrainableUtility.CanBeMaster(p, animal, false) && !p.story.traits.HasTrait(TraitDefOf.Psychopath) select p).RandomElementWithFallback(null); if (pawn != null) { animal.training.Train(TrainableDefOf.Obedience, null, true); animal.training.SetWantedRecursive(TrainableDefOf.Obedience, true); pawn.relations.AddDirectRelation(PawnRelationDefOf.Bond, animal); animal.playerSettings.Master = pawn; } } Rand.PopState(); if (gender != Gender.None) { animal.gender = gender; } yield return(animal); } yield break; }
public Pawn GetMaster(Pawn animal, MasterMode mode) { var master = animal.playerSettings.Master; var options = animal.kindDef.GetMasterOptions(manager, mode); // if the animal is bonded, and we care about bonds, there's no discussion if (RespectBonds) { var bondee = animal.relations.GetFirstDirectRelationPawn(PawnRelationDefOf.Bond, p => !p.Dead); if (bondee != null && TrainableUtility.CanBeMaster(bondee, animal)) { return(bondee); } } Logger.Follow( $"Getting master for {animal.LabelShort}:\n\tcurrent: {master?.LabelShort ?? "None"}\n\toptions:\n"); #if DEBUG_FOLLOW foreach (var option in options) { Logger.Follow($"\t\t{option.LabelShort}\n"); } #endif // cop out if no options if (options.NullOrEmpty()) { return(null); } // if we currently have a master, our current master is a valid option, // and all the options have roughly equal amounts of pets following them, we don't need to take action if (master != null && options.Contains(master) && RoughlyEquallyDistributed(options)) { return(master); } // otherwise, assign a master that has the least amount of current followers. return(options.MinBy(p => p.GetFollowers().Count)); }
/// <summary> /// Jobs the on thing. /// </summary> /// <param name="pawn">The pawn.</param> /// <param name="t">The t.</param> /// <param name="forced">if set to <c>true</c> [forced].</param> /// <returns></returns> public override Job JobOnThing(Pawn pawn, Thing t, bool forced = false) { var dbgLog = pawn.jobs?.debugLog == true; Pawn pawn2 = t as Pawn; if (pawn2 == null || !(pawn2.RaceProps.Animal || pawn2.GetIntelligence() == Intelligence.Animal)) { if (dbgLog) { Log.Message($"{pawn2?.Name?.ToStringFull ?? "NULL"} is null or not an animals or animalistic"); } return(null); } if (pawn2.Faction != pawn.Faction) { if (dbgLog) { Log.Message($"{pawn2.Name} is not part of the same faction as {pawn.Name}"); } return(null); } if (TrainableUtility.TrainedTooRecently(pawn2)) { if (dbgLog) { Log.Message($"{pawn2.Name} was trained to recently"); } JobFailReason.Is(WorkGiver_InteractAnimal.AnimalInteractedTooRecentlyTrans); return(null); } if (pawn2.training == null) { if (dbgLog) { Log.Message($"{pawn2.Name} has no training message"); } return(null); } if (pawn2.training.NextTrainableToTrain() == null) { if (dbgLog) { Log.Message($"{pawn2.Name} has no trainability to train"); } return(null); } if (!CanInteractWithAnimal(pawn, pawn2, forced)) { if (dbgLog) { Log.Message($"{pawn2.Name} cannot interact with {pawn.Name}"); } return(null); } if (pawn2.RaceProps.EatsFood && !HasFoodToInteractAnimal(pawn, pawn2)) { Job job = TakeFoodForAnimalInteractJob(pawn, pawn2); if (job == null) { if (dbgLog) { Log.Message($"{pawn.Name} cannot get food for {pawn2.Name}"); } JobFailReason.Is(WorkGiver_InteractAnimal.NoUsableFoodTrans); } return(job); } return(JobMaker.MakeJob(JobDefOf.Train, t)); }
private static void DoPlayLoad() { GraphicDatabase.Clear(); DeepProfiler.Start("Load all active mods."); try { LoadedModManager.LoadAllActiveMods(); } finally { DeepProfiler.End(); } DeepProfiler.Start("Load language metadata."); try { LanguageDatabase.LoadAllMetadata(); } finally { DeepProfiler.End(); } LongEventHandler.SetCurrentEventText("LoadingDefs".Translate()); DeepProfiler.Start("Copy all Defs from mods to global databases."); try { foreach (Type item in typeof(Def).AllSubclasses()) { GenGeneric.InvokeStaticMethodOnGenericType(typeof(DefDatabase <>), item, "AddAllInMods"); } } finally { DeepProfiler.End(); } DeepProfiler.Start("Resolve cross-references between non-implied Defs."); try { DirectXmlCrossRefLoader.ResolveAllWantedCrossReferences(FailMode.Silent); } finally { DeepProfiler.End(); } DeepProfiler.Start("Rebind defs (early)."); try { DefOfHelper.RebindAllDefOfs(true); } finally { DeepProfiler.End(); } DeepProfiler.Start("Generate implied Defs (pre-resolve)."); try { DefGenerator.GenerateImpliedDefs_PreResolve(); } finally { DeepProfiler.End(); } DeepProfiler.Start("Resolve cross-references between Defs made by the implied defs."); try { DirectXmlCrossRefLoader.ResolveAllWantedCrossReferences(FailMode.LogErrors); } finally { DeepProfiler.End(); } DeepProfiler.Start("Rebind DefOfs (final)."); try { DefOfHelper.RebindAllDefOfs(false); } finally { DeepProfiler.End(); } DeepProfiler.Start("Other def binding, resetting and global operations."); try { PlayerKnowledgeDatabase.ReloadAndRebind(); LessonAutoActivator.Reset(); CostListCalculator.Reset(); PawnApparelGenerator.Reset(); RestUtility.Reset(); ThoughtUtility.Reset(); PawnWeaponGenerator.Reset(); ThinkTreeKeyAssigner.Reset(); ThingCategoryNodeDatabase.FinalizeInit(); TrainableUtility.Reset(); HaulAIUtility.Reset(); GenConstruct.Reset(); WorkGiver_FillFermentingBarrel.Reset(); WorkGiver_DoBill.Reset(); Pawn.Reset(); WorkGiver_InteractAnimal.Reset(); WorkGiver_Warden_DoExecution.Reset(); WorkGiver_GrowerSow.Reset(); WorkGiver_Miner.Reset(); MedicalCareUtility.Reset(); InspectPaneUtility.Reset(); GraphicDatabaseHeadRecords.Reset(); DateReadout.Reset(); ResearchProjectDef.GenerateNonOverlappingCoordinates(); WorkGiver_FixBrokenDownBuilding.CacheTranslations(); ItemCollectionGeneratorUtility.Reset(); BaseGen.Reset(); HealthUtility.Reset(); ResourceCounter.ResetDefs(); WildSpawner.Reset(); ApparelProperties.Reset(); } finally { DeepProfiler.End(); } DeepProfiler.Start("Resolve references."); try { foreach (Type item2 in typeof(Def).AllSubclasses()) { if (item2 != typeof(ThingDef)) { GenGeneric.InvokeStaticMethodOnGenericType(typeof(DefDatabase <>), item2, "ResolveAllReferences", true); } } DefDatabase <ThingDef> .ResolveAllReferences(true); } finally { DeepProfiler.End(); } DeepProfiler.Start("Generate implied Defs (post-resolve)."); try { DefGenerator.GenerateImpliedDefs_PostResolve(); } finally { DeepProfiler.End(); } if (Prefs.DevMode) { DeepProfiler.Start("Error check all defs."); try { foreach (Type item3 in typeof(Def).AllSubclasses()) { GenGeneric.InvokeStaticMethodOnGenericType(typeof(DefDatabase <>), item3, "ErrorCheckAllDefs"); } } finally { DeepProfiler.End(); } } LongEventHandler.SetCurrentEventText("Initializing".Translate()); DeepProfiler.Start("Load keyboard preferences."); try { KeyPrefs.Init(); } finally { DeepProfiler.End(); } DeepProfiler.Start("Short hash giving."); try { ShortHashGiver.GiveAllShortHashes(); } finally { DeepProfiler.End(); } LongEventHandler.ExecuteWhenFinished(delegate { DeepProfiler.Start("Load backstories."); try { BackstoryDatabase.ReloadAllBackstories(); } finally { DeepProfiler.End(); } }); LongEventHandler.ExecuteWhenFinished(delegate { DeepProfiler.Start("Inject selected language data into game data."); try { LanguageDatabase.activeLanguage.InjectIntoData(); GenLabel.ClearCache(); } finally { DeepProfiler.End(); } }); LongEventHandler.ExecuteWhenFinished(delegate { StaticConstructorOnStartupUtility.CallAll(); if (Prefs.DevMode) { StaticConstructorOnStartupUtility.ReportProbablyMissingAttributes(); } }); }
protected override void DrawPawnRow(Rect rect, Pawn p) { // sizes for stuff float x = 16f; float heightOffset = (rect.height - x) / 2; float widthOffset = (50 - x) / 2; GUI.BeginGroup(rect); float num = 175f; if (p.training.IsCompleted(TrainableDefOf.Obedience)) { Rect rect2 = new Rect(num, 0f, 90f, rect.height); Rect rect3 = rect2.ContractedBy(2f); string label = (p.playerSettings.master == null) ? "NoneLower".Translate() : p.playerSettings.master.LabelBaseShort; Text.Font = GameFont.Small; if (Widgets.TextButton(rect3, label)) { TrainableUtility.OpenMasterSelectMenu(p); } } num += 90f; Rect recta = new Rect(num + widthOffset, heightOffset, x, x); Texture2D labelSex = GenderTextures[(int)p.gender]; TipSignal tipSex = p.gender.ToString(); GUI.DrawTexture(recta, labelSex); TooltipHandler.TipRegion(recta, tipSex); num += 50f; Rect rectb = new Rect(num + widthOffset, heightOffset, x, x); var labelAge = p.RaceProps.lifeStageAges.Count > 3 ? LifeStageTextures[3] : LifeStageTextures[p.ageTracker.CurLifeStageIndex]; TipSignal tipAge = p.ageTracker.CurLifeStage.LabelCap + ", " + p.ageTracker.AgeBiologicalYears; GUI.DrawTexture(rectb, labelAge); TooltipHandler.TipRegion(rectb, tipAge); num += 50f; Rect rectc = new Rect(num, 0f, 50f, 30f); Rect rectc1 = new Rect(num + 17f, heightOffset, x, x); bool slaughter = Find.DesignationManager.DesignationOn(p, DesignationDefOf.Slaughter) != null; if (slaughter) { GUI.DrawTexture(rectc1, WorkBoxCheckTex); TooltipHandler.TipRegion(rectc, "Fluffy.StopSlaughter".Translate()); } else { TooltipHandler.TipRegion(rectc, "Fluffy.MarkSlaughter".Translate()); } if (Widgets.InvisibleButton(rectc)) { if (slaughter) { Widgets_Animals.UnSlaughterAnimal(p); SoundDefOf.CheckboxTurnedOff.PlayOneShotOnCamera(); } else { Widgets_Animals.SlaughterAnimal(p); SoundDefOf.CheckboxTurnedOn.PlayOneShotOnCamera(); } } if (Mouse.IsOver(rectc)) { GUI.DrawTexture(rectc1, TexUI.HighlightTex); } num += 50f; Rect trainingRect = new Rect(num, 0f, 80f, 30f); Widgets_Animals.DoTrainingRow(trainingRect, p); num += 90f; Rect rect4 = new Rect(num, 0f, 350f, rect.height); AreaAllowedGUI.DoAllowedAreaSelectors(rect4, p, AllowedAreaMode.Animal); GUI.EndGroup(); }
public static IntRange Clamp(this IntRange level, Pawn target) { var minSkill = TrainableUtility.MinimumHandlingSkill(target); return(new IntRange(Math.Max(level.min, minSkill), Math.Max(level.max, minSkill))); }
private static void DoPlayLoad() { DeepProfiler.Start("GraphicDatabase.Clear()"); try { GraphicDatabase.Clear(); } finally { DeepProfiler.End(); } DeepProfiler.Start("Load all active mods."); try { LoadedModManager.LoadAllActiveMods(); } finally { DeepProfiler.End(); } DeepProfiler.Start("Load language metadata."); try { LanguageDatabase.InitAllMetadata(); } finally { DeepProfiler.End(); } LongEventHandler.SetCurrentEventText("LoadingDefs".Translate()); DeepProfiler.Start("Copy all Defs from mods to global databases."); try { foreach (Type item in typeof(Def).AllSubclasses()) { GenGeneric.InvokeStaticMethodOnGenericType(typeof(DefDatabase <>), item, "AddAllInMods"); } } finally { DeepProfiler.End(); } DeepProfiler.Start("Resolve cross-references between non-implied Defs."); try { DirectXmlCrossRefLoader.ResolveAllWantedCrossReferences(FailMode.Silent); } finally { DeepProfiler.End(); } DeepProfiler.Start("Rebind defs (early)."); try { DefOfHelper.RebindAllDefOfs(earlyTryMode: true); } finally { DeepProfiler.End(); } DeepProfiler.Start("TKeySystem.BuildMappings()"); try { TKeySystem.BuildMappings(); } finally { DeepProfiler.End(); } DeepProfiler.Start("Inject selected language data into game data (early pass)."); try { LanguageDatabase.activeLanguage.InjectIntoData_BeforeImpliedDefs(); } finally { DeepProfiler.End(); } DeepProfiler.Start("Generate implied Defs (pre-resolve)."); try { DefGenerator.GenerateImpliedDefs_PreResolve(); } finally { DeepProfiler.End(); } DeepProfiler.Start("Resolve cross-references between Defs made by the implied defs."); try { DirectXmlCrossRefLoader.ResolveAllWantedCrossReferences(FailMode.LogErrors); } finally { DirectXmlCrossRefLoader.Clear(); DeepProfiler.End(); } DeepProfiler.Start("Rebind DefOfs (final)."); try { DefOfHelper.RebindAllDefOfs(earlyTryMode: false); } finally { DeepProfiler.End(); } DeepProfiler.Start("Other def binding, resetting and global operations (pre-resolve)."); try { PlayerKnowledgeDatabase.ReloadAndRebind(); LessonAutoActivator.Reset(); CostListCalculator.Reset(); Pawn.ResetStaticData(); PawnApparelGenerator.Reset(); RestUtility.Reset(); ThoughtUtility.Reset(); ThinkTreeKeyAssigner.Reset(); ThingCategoryNodeDatabase.FinalizeInit(); TrainableUtility.Reset(); HaulAIUtility.Reset(); GenConstruct.Reset(); MedicalCareUtility.Reset(); InspectPaneUtility.Reset(); GraphicDatabaseHeadRecords.Reset(); DateReadout.Reset(); ResearchProjectDef.GenerateNonOverlappingCoordinates(); BaseGen.Reset(); ResourceCounter.ResetDefs(); ApparelProperties.ResetStaticData(); WildPlantSpawner.ResetStaticData(); PawnGenerator.Reset(); TunnelHiveSpawner.ResetStaticData(); Hive.ResetStaticData(); ExpectationsUtility.Reset(); WealthWatcher.ResetStaticData(); SkillUI.Reset(); QuestNode_GetThingPlayerCanProduce.ResetStaticData(); Pawn_PsychicEntropyTracker.ResetStaticData(); ColoredText.ResetStaticData(); QuestNode_GetRandomNegativeGameCondition.ResetStaticData(); RoyalTitleUtility.ResetStaticData(); RewardsGenerator.ResetStaticData(); WorkGiver_FillFermentingBarrel.ResetStaticData(); WorkGiver_DoBill.ResetStaticData(); WorkGiver_InteractAnimal.ResetStaticData(); WorkGiver_Warden_DoExecution.ResetStaticData(); WorkGiver_GrowerSow.ResetStaticData(); WorkGiver_Miner.ResetStaticData(); WorkGiver_FixBrokenDownBuilding.ResetStaticData(); WorkGiver_ConstructDeliverResources.ResetStaticData(); } finally { DeepProfiler.End(); } DeepProfiler.Start("Resolve references."); try { DeepProfiler.Start("ThingCategoryDef resolver"); try { DefDatabase <ThingCategoryDef> .ResolveAllReferences(); } finally { DeepProfiler.End(); } DeepProfiler.Start("RecipeDef resolver"); try { DeepProfiler.enabled = false; DefDatabase <RecipeDef> .ResolveAllReferences(onlyExactlyMyType : true, parallel : true); DeepProfiler.enabled = true; } finally { DeepProfiler.End(); } DeepProfiler.Start("Static resolver calls"); try { foreach (Type item2 in typeof(Def).AllSubclasses()) { if (!(item2 == typeof(ThingDef)) && !(item2 == typeof(ThingCategoryDef)) && !(item2 == typeof(RecipeDef))) { GenGeneric.InvokeStaticMethodOnGenericType(typeof(DefDatabase <>), item2, "ResolveAllReferences", true, false); } } } finally { DeepProfiler.End(); } DeepProfiler.Start("ThingDef resolver"); try { DefDatabase <ThingDef> .ResolveAllReferences(); } finally { DeepProfiler.End(); } } finally { DeepProfiler.End(); } DeepProfiler.Start("Generate implied Defs (post-resolve)."); try { DefGenerator.GenerateImpliedDefs_PostResolve(); } finally { DeepProfiler.End(); } DeepProfiler.Start("Other def binding, resetting and global operations (post-resolve)."); try { PawnWeaponGenerator.Reset(); BuildingProperties.FinalizeInit(); ThingSetMakerUtility.Reset(); } finally { DeepProfiler.End(); } if (Prefs.DevMode) { DeepProfiler.Start("Error check all defs."); try { foreach (Type item3 in typeof(Def).AllSubclasses()) { GenGeneric.InvokeStaticMethodOnGenericType(typeof(DefDatabase <>), item3, "ErrorCheckAllDefs"); } } finally { DeepProfiler.End(); } } LongEventHandler.SetCurrentEventText("Initializing".Translate()); DeepProfiler.Start("Load keyboard preferences."); try { KeyPrefs.Init(); } finally { DeepProfiler.End(); } DeepProfiler.Start("Short hash giving."); try { ShortHashGiver.GiveAllShortHashes(); } finally { DeepProfiler.End(); } LongEventHandler.ExecuteWhenFinished(delegate { DeepProfiler.Start("Load backstories."); try { BackstoryDatabase.ReloadAllBackstories(); } finally { DeepProfiler.End(); } }); LongEventHandler.ExecuteWhenFinished(delegate { DeepProfiler.Start("Inject selected language data into game data."); try { LanguageDatabase.activeLanguage.InjectIntoData_AfterImpliedDefs(); GenLabel.ClearCache(); } finally { DeepProfiler.End(); } }); LongEventHandler.ExecuteWhenFinished(delegate { DeepProfiler.Start("Static constructor calls"); try { StaticConstructorOnStartupUtility.CallAll(); if (Prefs.DevMode) { StaticConstructorOnStartupUtility.ReportProbablyMissingAttributes(); } } finally { DeepProfiler.End(); } DeepProfiler.Start("Garbage Collection"); try { AbstractFilesystem.ClearAllCache(); GC.Collect(int.MaxValue, GCCollectionMode.Forced); } finally { DeepProfiler.End(); } }); }
public IEnumerable <StatDrawEntry> SpecialDisplayStats(ThingDef parentDef, StatRequest req) { yield return(new StatDrawEntry(StatCategoryDefOf.BasicsPawn, "Race".Translate(), parentDef.LabelCap, parentDef.description, 2100)); if (!parentDef.race.IsMechanoid) { string text = foodType.ToHumanString().CapitalizeFirst(); yield return(new StatDrawEntry(StatCategoryDefOf.BasicsPawn, "Diet".Translate(), text, "Stat_Race_Diet_Desc".Translate(text), 1500)); } if (req.HasThing && req.Thing is Pawn && (req.Thing as Pawn).needs != null && (req.Thing as Pawn).needs.food != null) { yield return(new StatDrawEntry(StatCategoryDefOf.BasicsPawn, "HungerRate".Translate(), ((req.Thing as Pawn).needs.food.FoodFallPerTickAssumingCategory(HungerCategory.Fed) * 60000f).ToString("0.##"), NutritionEatenPerDayExplanation_NewTemp(req.Thing as Pawn), 1600)); } if (parentDef.race.leatherDef != null) { yield return(new StatDrawEntry(StatCategoryDefOf.BasicsPawn, "LeatherType".Translate(), parentDef.race.leatherDef.LabelCap, "Stat_Race_LeatherType_Desc".Translate(), 3550, null, new Dialog_InfoCard.Hyperlink[1] { new Dialog_InfoCard.Hyperlink(parentDef.race.leatherDef) })); } if (parentDef.race.Animal || wildness > 0f) { yield return(new StatDrawEntry(StatCategoryDefOf.BasicsPawn, "Wildness".Translate(), wildness.ToStringPercent(), TrainableUtility.GetWildnessExplanation(parentDef), 2050)); yield return(new StatDrawEntry(StatCategoryDefOf.BasicsPawn, "HarmedRevengeChance".Translate(), PawnUtility.GetManhunterOnDamageChance(parentDef.race).ToStringPercent(), "HarmedRevengeChanceExplanation".Translate(), 510)); yield return(new StatDrawEntry(StatCategoryDefOf.BasicsPawn, "TameFailedRevengeChance".Translate(), parentDef.race.manhunterOnTameFailChance.ToStringPercent(), "Stat_Race_Animal_TameFailedRevengeChance_Desc".Translate(), 511)); } if ((int)intelligence < 2 && trainability != null) { yield return(new StatDrawEntry(StatCategoryDefOf.BasicsPawn, "Trainability".Translate(), trainability.LabelCap, "Stat_Race_Trainability_Desc".Translate(), 2500)); } yield return(new StatDrawEntry(StatCategoryDefOf.BasicsPawn, "StatsReport_LifeExpectancy".Translate(), lifeExpectancy.ToStringByStyle(ToStringStyle.Integer), "Stat_Race_LifeExpectancy_Desc".Translate(), 2000)); if ((int)intelligence < 2 && !parentDef.race.IsMechanoid) { yield return(new StatDrawEntry(StatCategoryDefOf.BasicsPawn, "AnimalFilthRate".Translate(), (PawnUtility.AnimalFilthChancePerCell(parentDef, parentDef.race.baseBodySize) * 1000f).ToString("F2"), "AnimalFilthRateExplanation".Translate(1000.ToString()), 2203)); } if (parentDef.race.Animal) { yield return(new StatDrawEntry(StatCategoryDefOf.BasicsPawn, "PackAnimal".Translate(), packAnimal ? "Yes".Translate() : "No".Translate(), "PackAnimalExplanation".Translate(), 2202)); if (parentDef.race.nuzzleMtbHours > 0f) { yield return(new StatDrawEntry(StatCategoryDefOf.PawnSocial, "NuzzleInterval".Translate(), Mathf.RoundToInt(parentDef.race.nuzzleMtbHours * 2500f).ToStringTicksToPeriod(), "NuzzleIntervalExplanation".Translate(), 500)); } } }
public static bool HasBondRelation(this Pawn p) => TrainableUtility.GetAllColonistBondsFor(p).Any();