protected virtual bool CanInteractWithAnimal(Pawn pawn, Pawn animal, bool forced) { LocalTargetInfo target = animal; if (!pawn.CanReserve(target, 1, -1, null, forced)) { return(false); } if (animal.Downed) { JobFailReason.Is(WorkGiver_InteractAnimal.CantInteractAnimalDownedTrans, null); return(false); } if (!animal.Awake()) { JobFailReason.Is(WorkGiver_InteractAnimal.CantInteractAnimalAsleepTrans, null); return(false); } if (!animal.CanCasuallyInteractNow(false)) { JobFailReason.Is(WorkGiver_InteractAnimal.CantInteractAnimalBusyTrans, null); return(false); } int num = TrainableUtility.MinimumHandlingSkill(animal); if (num > pawn.skills.GetSkill(SkillDefOf.Animals).Level) { JobFailReason.Is("AnimalsSkillTooLow".Translate(new object[] { num }), null); return(false); } return(true); }
public static void DoExtraAnimalIcons(Transferable trad, Rect rect, ref float curX) { Pawn pawn = trad.AnyThing as Pawn; if (pawn == null || !pawn.RaceProps.Animal) { return; } if (pawn.relations.GetFirstDirectRelationPawn(PawnRelationDefOf.Bond) != null) { Rect rect2 = new Rect(curX - BondIconWidth, (rect.height - BondIconWidth) / 2f, BondIconWidth, BondIconWidth); curX -= BondIconWidth; GUI.DrawTexture(rect2, BondIcon); if (Mouse.IsOver(rect2)) { string iconTooltipText = TrainableUtility.GetIconTooltipText(pawn); if (!iconTooltipText.NullOrEmpty()) { TooltipHandler.TipRegion(rect2, iconTooltipText); } } } if (pawn.health.hediffSet.HasHediff(HediffDefOf.Pregnant, mustBeVisible: true)) { Rect rect3 = new Rect(curX - PregnancyIconWidth, (rect.height - PregnancyIconWidth) / 2f, PregnancyIconWidth, PregnancyIconWidth); curX -= PregnancyIconWidth; if (Mouse.IsOver(rect3)) { TooltipHandler.TipRegion(rect3, PawnColumnWorker_Pregnant.GetTooltipText(pawn)); } GUI.DrawTexture(rect3, PregnantIcon); } }
public override void DoCell(Rect rect, Pawn pawn, PawnTable table) { if (CanAssignMaster(pawn)) { TrainableUtility.MasterSelectButton(rect.ContractedBy(2f), pawn, paintable: true); } }
public override IEnumerable <Thing> PlayerStartingThings() { int i = 0; if (i < count) { _003CPlayerStartingThings_003Ec__Iterator1 _003CPlayerStartingThings_003Ec__Iterator = (_003CPlayerStartingThings_003Ec__Iterator1) /*Error near IL_003e: stateMachine*/; PawnKindDef kind = (animalKind == null) ? RandomPets().RandomElementByWeight((PawnKindDef td) => td.RaceProps.petness) : animalKind; Pawn animal = PawnGenerator.GeneratePawn(kind, Faction.OfPlayer); if (animal.Name == null || animal.Name.Numerical) { animal.Name = PawnBioAndNameGenerator.GeneratePawnName(animal); } if (Rand.Value < bondToRandomPlayerPawnChance && animal.training.CanAssignToTrain(TrainableDefOf.Obedience).Accepted) { Pawn pawn = (from p in Find.GameInitData.startingAndOptionalPawns.Take(Find.GameInitData.startingPawnCount) where TrainableUtility.CanBeMaster(p, animal, checkSpawned: false) && !p.story.traits.HasTrait(TraitDefOf.Psychopath) select p).RandomElementWithFallback(); if (pawn != null) { animal.training.Train(TrainableDefOf.Obedience, null, complete: true); animal.training.SetWantedRecursive(TrainableDefOf.Obedience, checkOn: true); pawn.relations.AddDirectRelation(PawnRelationDefOf.Bond, animal); animal.playerSettings.Master = pawn; } } yield return((Thing)animal); /*Error: Unable to find new state assignment for yield return*/; } }
public static void DoExtraAnimalIcons(Transferable trad, Rect rect, ref float curX) { Pawn pawn = trad.AnyThing as Pawn; if (pawn != null && pawn.RaceProps.Animal) { if (pawn.relations.GetFirstDirectRelationPawn(PawnRelationDefOf.Bond, null) != null) { Rect rect2 = new Rect(curX - TransferableUIUtility.BondIconWidth, (rect.height - TransferableUIUtility.BondIconWidth) / 2f, TransferableUIUtility.BondIconWidth, TransferableUIUtility.BondIconWidth); curX -= TransferableUIUtility.BondIconWidth; GUI.DrawTexture(rect2, TransferableUIUtility.BondIcon); string iconTooltipText = TrainableUtility.GetIconTooltipText(pawn); if (!iconTooltipText.NullOrEmpty()) { TooltipHandler.TipRegion(rect2, iconTooltipText); } } if (pawn.health.hediffSet.HasHediff(HediffDefOf.Pregnant, true)) { Rect rect3 = new Rect(curX - TransferableUIUtility.PregnancyIconWidth, (rect.height - TransferableUIUtility.PregnancyIconWidth) / 2f, TransferableUIUtility.PregnancyIconWidth, TransferableUIUtility.PregnancyIconWidth); curX -= TransferableUIUtility.PregnancyIconWidth; TooltipHandler.TipRegion(rect3, PawnColumnWorker_Pregnant.GetTooltipText(pawn)); GUI.DrawTexture(rect3, TransferableUIUtility.PregnantIcon); } } }
public static void DrawTrainingCard(Rect rect, Pawn pawn) { GUI.BeginGroup(rect); string label = "TrainableIntelligence".Translate() + ": " + pawn.RaceProps.TrainableIntelligence.label; Widgets.Label(new Rect(0f, 0f, rect.width, 25f), label); if (pawn.training.IsCompleted(TrainableDefOf.Obedience)) { Rect rect2 = new Rect(0f, 20f, rect.width, 25f); Widgets.Label(rect2, "Master".Translate() + ": "); Vector2 center = rect2.center; rect2.xMin = center.x; string label2 = TrainableUtility.MasterString(pawn); if (Widgets.ButtonText(rect2, label2, true, false, true)) { TrainableUtility.OpenMasterSelectMenu(pawn); } } float num = 50f; List <TrainableDef> trainableDefsInListOrder = TrainableUtility.TrainableDefsInListOrder; for (int i = 0; i < trainableDefsInListOrder.Count; i++) { if (TrainingCardUtility.TryDrawTrainableRow(new Rect(0f, num, rect.width, 28f), pawn, trainableDefsInListOrder[i])) { num = (float)(num + 28.0); } } GUI.EndGroup(); }
public static void OpenMasterSelectMenu(Pawn p) { List <FloatMenuOption> list = new List <FloatMenuOption>(); list.Add(new FloatMenuOption("(" + "NoneLower".Translate() + ")", delegate { p.playerSettings.master = null; }, MenuOptionPriority.Default, null, null, 0f, null, null)); foreach (Pawn item in PawnsFinder.AllMaps_FreeColonistsSpawned) { string text = RelationsUtility.LabelWithBondInfo(item, p); int level = item.skills.GetSkill(SkillDefOf.Animals).Level; int num = TrainableUtility.MinimumHandlingSkill(p); Action action; if (level >= num) { Pawn localCol = item; action = delegate { p.playerSettings.master = localCol; }; } else { action = null; text = text + " (" + "SkillTooLow".Translate(SkillDefOf.Animals.LabelCap, level, num) + ")"; } list.Add(new FloatMenuOption(text, action, MenuOptionPriority.Default, null, null, 0f, null, null)); } Find.WindowStack.Add(new FloatMenu(list)); }
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); } 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; } } yield return animal; } }
public static void ShowDesignationWarnings(Pawn pawn, bool showManhunterOnTameFailWarning = true) { if (showManhunterOnTameFailWarning) { float manhunterOnTameFailChance = pawn.RaceProps.manhunterOnTameFailChance; if (manhunterOnTameFailChance >= 0.015f) { string text = "MessageAnimalManhuntsOnTameFailed".Translate(pawn.kindDef.GetLabelPlural().CapitalizeFirst(), manhunterOnTameFailChance.ToStringPercent(), pawn.Named("ANIMAL")); Messages.Message(text, pawn, MessageTypeDefOf.CautionInput, historical: false); } } IEnumerable <Pawn> source = from c in pawn.Map.mapPawns.FreeColonistsSpawned where c.workSettings.WorkIsActive(WorkTypeDefOf.Handling) select c; if (!source.Any()) { source = pawn.Map.mapPawns.FreeColonistsSpawned; } if (source.Any()) { Pawn pawn2 = source.MaxBy((Pawn c) => c.skills.GetSkill(SkillDefOf.Animals).Level); int level = pawn2.skills.GetSkill(SkillDefOf.Animals).Level; int num = TrainableUtility.MinimumHandlingSkill(pawn); if (num > level) { string text2 = "MessageNoHandlerSkilledEnough".Translate(pawn.kindDef.label, num.ToStringCached(), SkillDefOf.Animals.LabelCap, pawn2.LabelShort, level, pawn.Named("ANIMAL"), pawn2.Named("HANDLER")); Messages.Message(text2, pawn, MessageTypeDefOf.CautionInput, historical: false); } } }
public override void DoCell(Rect rect, Pawn pawn, PawnTable table) { if (this.CanAssignMaster(pawn)) { Rect rect2 = rect.ContractedBy(2f); TrainableUtility.MasterSelectButton(rect2, pawn, true); } }
protected override bool AnimalMasterCheck(Pawn p, Pawn animal) { if (animal.playerSettings.RespectedMaster != p) { return(TrainableUtility.MinimumHandlingSkill(animal) <= p.skills.GetSkill(SkillDefOf.Animals).Level); } return(false); }
public void TrainingTrackerTickRare() { if (this.pawn.Suspended) { this.countDecayFrom += 250; } else if (!this.pawn.Spawned) { this.countDecayFrom += 250; } else if (this.steps[TrainableDefOf.Tameness] == 0) { this.countDecayFrom = Find.TickManager.TicksGame; } else if (Find.TickManager.TicksGame >= this.countDecayFrom + TrainableUtility.DegradationPeriodTicks(this.pawn.def)) { TrainableDef trainableDef = (from kvp in this.steps where kvp.Value > 0 select kvp.Key).Except((from kvp in this.steps where kvp.Value > 0 && kvp.Key.prerequisites != null select kvp).SelectMany((KeyValuePair <TrainableDef, int> kvp) => kvp.Key.prerequisites)).RandomElement <TrainableDef>(); if (trainableDef == TrainableDefOf.Tameness && !TrainableUtility.TamenessCanDecay(this.pawn.def)) { this.countDecayFrom = Find.TickManager.TicksGame; } else { this.countDecayFrom = Find.TickManager.TicksGame; DefMap <TrainableDef, int> defMap; TrainableDef def; (defMap = this.steps)[def = trainableDef] = defMap[def] - 1; if (this.steps[trainableDef] <= 0 && this.learned[trainableDef]) { this.learned[trainableDef] = false; if (this.pawn.Faction == Faction.OfPlayer) { if (trainableDef == TrainableDefOf.Tameness) { this.pawn.SetFaction(null, null); Messages.Message("MessageAnimalReturnedWild".Translate(new object[] { this.pawn.LabelShort }), this.pawn, MessageTypeDefOf.NegativeEvent, true); } else { Messages.Message("MessageAnimalLostSkill".Translate(new object[] { this.pawn.LabelShort, trainableDef.LabelCap }), this.pawn, MessageTypeDefOf.NegativeEvent, true); } } } } } }
protected override void PaintedIcon(Pawn pawn) { if (!(GetIconFor(pawn) != BondBrokenIcon) && pawn.training.HasLearned(TrainableDefOf.Obedience)) { pawn.playerSettings.Master = (from master in TrainableUtility.GetAllColonistBondsFor(pawn) where TrainableUtility.CanBeMaster(master, pawn) select master).FirstOrDefault(); } }
public static void MasterSelectButton(Rect rect, Pawn pawn, bool paintable) { Rect rect2 = rect; Func <Pawn, Pawn> getPayload = new Func <Pawn, Pawn>(TrainableUtility.MasterSelectButton_GetMaster); Func <Pawn, IEnumerable <Widgets.DropdownMenuElement <Pawn> > > menuGenerator = new Func <Pawn, IEnumerable <Widgets.DropdownMenuElement <Pawn> > >(TrainableUtility.MasterSelectButton_GenerateMenu); string buttonLabel = TrainableUtility.MasterString(pawn).Truncate(rect.width, null); string dragLabel = TrainableUtility.MasterString(pawn); Widgets.Dropdown <Pawn, Pawn>(rect2, pawn, getPayload, menuGenerator, buttonLabel, null, dragLabel, null, null, paintable); }
public static bool CanBeMaster(Pawn master, Pawn animal, bool checkSpawned = true) { if ((checkSpawned && !master.Spawned) || master.IsPrisoner) { return(false); } int level = master.skills.GetSkill(SkillDefOf.Animals).Level; int num = TrainableUtility.MinimumHandlingSkill(animal); return(level >= num); }
public override void DoCell(Rect rect, Pawn pawn, PawnTable table) { if (this.CanAssignMaster(pawn)) { Rect rect2 = rect.ContractedBy(2f); string label = TrainableUtility.MasterString(pawn).Truncate(rect2.width, null); if (Widgets.ButtonText(rect2, label, true, false, true)) { TrainableUtility.OpenMasterSelectMenu(pawn); } } }
public static string GetWildnessExplanation(ThingDef def) { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendLine("WildnessExplanation".Translate()); stringBuilder.AppendLine(); stringBuilder.AppendLine(string.Format("{0}: {1}", "TrainingDecayInterval".Translate(), TrainableUtility.DegradationPeriodTicks(def).ToStringTicksToDays("F1"))); if (!TrainableUtility.TamenessCanDecay(def)) { stringBuilder.AppendLine("TamenessWillNotDecay".Translate()); } return(stringBuilder.ToString()); }
protected override void PaintedIcon(Pawn pawn) { if (this.GetIconFor(pawn) != PawnColumnWorker_Bond.BondBrokenIcon) { return; } if (!pawn.training.HasLearned(TrainableDefOf.Obedience)) { return; } pawn.playerSettings.Master = (from master in TrainableUtility.GetAllColonistBondsFor(pawn) where TrainableUtility.CanBeMaster(master, pawn, true) select master).FirstOrDefault <Pawn>(); }
public static void DrawTrainingCard(Rect rect, Pawn pawn) { Text.Font = GameFont.Small; Rect rect2 = new Rect(TrainabilityLeft, TrainabilityTop, 30f, 30f); TooltipHandler.TipRegionByKey(rect2, "RenameAnimal"); if (Widgets.ButtonImage(rect2, TexButton.Rename)) { Find.WindowStack.Add(new Dialog_NamePawn(pawn)); } Listing_Standard listing_Standard = new Listing_Standard(); listing_Standard.Begin(rect); listing_Standard.Label("CreatureTrainability".Translate(pawn.def.label).CapitalizeFirst() + ": " + pawn.RaceProps.trainability.LabelCap, 22f); listing_Standard.Label("CreatureWildness".Translate(pawn.def.label).CapitalizeFirst() + ": " + pawn.RaceProps.wildness.ToStringPercent(), 22f, TrainableUtility.GetWildnessExplanation(pawn.def)); if (pawn.training.HasLearned(TrainableDefOf.Obedience)) { Rect rect3 = listing_Standard.GetRect(25f); Widgets.Label(rect3, "Master".Translate() + ": "); rect3.xMin = rect3.center.x; TrainableUtility.MasterSelectButton(rect3, pawn, paintable: false); listing_Standard.Gap(); Rect rect4 = listing_Standard.GetRect(25f); bool checkOn = pawn.playerSettings.followDrafted; Widgets.CheckboxLabeled(rect4, "CreatureFollowDrafted".Translate(), ref checkOn); if (checkOn != pawn.playerSettings.followDrafted) { pawn.playerSettings.followDrafted = checkOn; } Rect rect5 = listing_Standard.GetRect(25f); bool checkOn2 = pawn.playerSettings.followFieldwork; Widgets.CheckboxLabeled(rect5, "CreatureFollowFieldwork".Translate(), ref checkOn2); if (checkOn2 != pawn.playerSettings.followFieldwork) { pawn.playerSettings.followFieldwork = checkOn2; } } listing_Standard.Gap(); float num = 50f; List <TrainableDef> trainableDefsInListOrder = TrainableUtility.TrainableDefsInListOrder; for (int i = 0; i < trainableDefsInListOrder.Count; i++) { if (TryDrawTrainableRow(listing_Standard.GetRect(28f), pawn, trainableDefsInListOrder[i])) { num += 28f; } } listing_Standard.End(); }
protected override Texture2D GetIconFor(Pawn pawn) { IEnumerable <Pawn> allColonistBondsFor = TrainableUtility.GetAllColonistBondsFor(pawn); if (!allColonistBondsFor.Any()) { return(null); } if (allColonistBondsFor.Any((Pawn bond) => bond == pawn.playerSettings.Master)) { return(BondIcon); } return(BondBrokenIcon); }
public void TrainingTrackerTickRare() { if (pawn.Suspended) { countDecayFrom += 250; } else if (!pawn.Spawned) { countDecayFrom += 250; } else if (steps[TrainableDefOf.Tameness] == 0) { countDecayFrom = Find.TickManager.TicksGame; } else { if (Find.TickManager.TicksGame < countDecayFrom + TrainableUtility.DegradationPeriodTicks(pawn.def)) { return; } TrainableDef trainableDef = (from kvp in steps where kvp.Value > 0 select kvp.Key).Except(steps.Where((KeyValuePair <TrainableDef, int> kvp) => kvp.Value > 0 && kvp.Key.prerequisites != null).SelectMany((KeyValuePair <TrainableDef, int> kvp) => kvp.Key.prerequisites)).RandomElement(); if (trainableDef == TrainableDefOf.Tameness && !TrainableUtility.TamenessCanDecay(pawn.def)) { countDecayFrom = Find.TickManager.TicksGame; return; } countDecayFrom = Find.TickManager.TicksGame; steps[trainableDef]--; if (steps[trainableDef] > 0 || !learned[trainableDef]) { return; } learned[trainableDef] = false; if (pawn.Faction == Faction.OfPlayer) { if (trainableDef == TrainableDefOf.Tameness) { pawn.SetFaction(null); Messages.Message("MessageAnimalReturnedWild".Translate(pawn.LabelShort, pawn), pawn, MessageTypeDefOf.NegativeEvent); } else { Messages.Message("MessageAnimalLostSkill".Translate(pawn.LabelShort, trainableDef.LabelCap, pawn.Named("ANIMAL")), pawn, MessageTypeDefOf.NegativeEvent); } } } }
public static string GetIconTooltipText(Pawn pawn) { string text = string.Empty; if (pawn.playerSettings != null && pawn.playerSettings.Master != null) { text += string.Format("{0}: {1}\n", "Master".Translate(), pawn.playerSettings.Master.LabelShort); } IEnumerable <Pawn> allColonistBondsFor = TrainableUtility.GetAllColonistBondsFor(pawn); if (allColonistBondsFor.Any <Pawn>()) { text += string.Format("{0}: {1}\n", "BondedTo".Translate(), (from bond in allColonistBondsFor select bond.LabelShort).ToCommaList(true)); } return(text.TrimEndNewlines()); }
private static IEnumerable <Widgets.DropdownMenuElement <Pawn> > MasterSelectButton_GenerateMenu(Pawn p) { yield return(new Widgets.DropdownMenuElement <Pawn> { option = new FloatMenuOption("(" + "NoneLower".Translate() + ")", delegate() { p.playerSettings.Master = null; }, MenuOptionPriority.Default, null, null, 0f, null, null), payload = null }); using (IEnumerator <Pawn> enumerator = PawnsFinder.AllMaps_FreeColonistsSpawned.GetEnumerator()) { while (enumerator.MoveNext()) { Pawn col = enumerator.Current; string lab = RelationsUtility.LabelWithBondInfo(col, p); Action action = null; int level = col.skills.GetSkill(SkillDefOf.Animals).Level; int minLevel = TrainableUtility.MinimumHandlingSkill(p); if (level < minLevel) { action = null; lab = lab + " (" + "SkillTooLow".Translate(new object[] { SkillDefOf.Animals.LabelCap, level, minLevel }) + ")"; } else if (TrainableUtility.CanBeMaster(col, p, true)) { action = delegate() { p.playerSettings.Master = col; }; } yield return(new Widgets.DropdownMenuElement <Pawn> { option = new FloatMenuOption(lab, action, MenuOptionPriority.Default, null, null, 0f, null, null), payload = col }); } } yield break; }
public static void DrawTrainingCard(Rect rect, Pawn pawn) { Text.Font = GameFont.Small; Rect rect2 = new Rect(TrainingCardUtility.TrainabilityLeft, TrainingCardUtility.TrainabilityTop, 30f, 30f); TooltipHandler.TipRegion(rect2, "RenameAnimal".Translate()); if (Widgets.ButtonImage(rect2, TexButton.Rename)) { Find.WindowStack.Add(new Dialog_NamePawn(pawn)); } Listing_Standard listing_Standard = new Listing_Standard(); listing_Standard.Begin(rect); listing_Standard.Label("CreatureTrainability".Translate(new object[] { pawn.def.label }).CapitalizeFirst() + ": " + pawn.RaceProps.trainability.LabelCap, -1f, null); Listing_Standard arg_FE_0 = listing_Standard; string label = "CreatureWildness".Translate(new object[] { pawn.def.label }).CapitalizeFirst() + ": " + pawn.RaceProps.wildness.ToStringPercent(); string wildnessExplanation = TrainableUtility.GetWildnessExplanation(pawn.def); arg_FE_0.Label(label, -1f, wildnessExplanation); if (pawn.training.HasLearned(TrainableDefOf.Obedience)) { Rect rect3 = listing_Standard.GetRect(25f); Widgets.Label(rect3, "Master".Translate() + ": "); rect3.xMin = rect3.center.x; TrainableUtility.MasterSelectButton(rect3, pawn, false); } listing_Standard.Gap(12f); float num = 50f; List <TrainableDef> trainableDefsInListOrder = TrainableUtility.TrainableDefsInListOrder; for (int i = 0; i < trainableDefsInListOrder.Count; i++) { if (TrainingCardUtility.TryDrawTrainableRow(listing_Standard.GetRect(28f), pawn, trainableDefsInListOrder[i])) { num += 28f; } } listing_Standard.End(); }
protected override Texture2D GetIconFor(Pawn pawn) { IEnumerable <Pawn> allColonistBondsFor = TrainableUtility.GetAllColonistBondsFor(pawn); Texture2D result; if (!allColonistBondsFor.Any <Pawn>()) { result = null; } else if (allColonistBondsFor.Any((Pawn bond) => bond == pawn.playerSettings.Master)) { result = PawnColumnWorker_Bond.BondIcon; } else { result = PawnColumnWorker_Bond.BondBrokenIcon; } return(result); }
public override Job JobOnThing(Pawn pawn, Thing t, bool forced = false) { Pawn pawn2 = t as Pawn; if (pawn2 == null || !pawn2.RaceProps.Animal) { return(null); } if (pawn2.Faction != pawn.Faction) { return(null); } if (TrainableUtility.TrainedTooRecently(pawn2)) { JobFailReason.Is(WorkGiver_InteractAnimal.AnimalInteractedTooRecentlyTrans); return(null); } if (pawn2.training == null) { return(null); } TrainableDef trainableDef = pawn2.training.NextTrainableToTrain(); if (trainableDef == null) { return(null); } if (!CanInteractWithAnimal(pawn, pawn2, forced)) { return(null); } if (pawn2.RaceProps.EatsFood && !HasFoodToInteractAnimal(pawn, pawn2)) { Job job = TakeFoodForAnimalInteractJob(pawn, pawn2); if (job == null) { JobFailReason.Is(WorkGiver_InteractAnimal.NoUsableFoodTrans); } return(job); } return(new Job(JobDefOf.Train, t)); }
public static void ShowDesignationWarnings(Pawn pawn) { float manhunterOnTameFailChance = PawnUtility.GetManhunterOnTameFailChance(pawn); if (manhunterOnTameFailChance > 0.02f) { string text = "MessageAnimalManhuntsOnTameFailed".Translate(new object[] { pawn.kindDef.GetLabelPlural(-1).CapitalizeFirst(), manhunterOnTameFailChance.ToStringPercent() }); Messages.Message(text, pawn, MessageTypeDefOf.CautionInput, false); } IEnumerable <Pawn> source = from c in pawn.Map.mapPawns.FreeColonistsSpawned where c.workSettings.WorkIsActive(WorkTypeDefOf.Handling) select c; if (!source.Any <Pawn>()) { source = pawn.Map.mapPawns.FreeColonistsSpawned; } if (source.Any <Pawn>()) { Pawn pawn2 = source.MaxBy((Pawn c) => c.skills.GetSkill(SkillDefOf.Animals).Level); int level = pawn2.skills.GetSkill(SkillDefOf.Animals).Level; int num = TrainableUtility.MinimumHandlingSkill(pawn); if (num > level) { string text2 = "MessageNoHandlerSkilledEnough".Translate(new object[] { pawn.kindDef.label, num.ToStringCached(), SkillDefOf.Animals.LabelCap, pawn2.LabelShort, level }); Messages.Message(text2, pawn, MessageTypeDefOf.CautionInput, false); } } }
private void DoRow(Rect rect, TransferableOneWay trad, int index, float availableMass) { if (index % 2 == 1) { Widgets.DrawLightHighlight(rect); } Text.Font = GameFont.Small; GUI.BeginGroup(rect); float num = rect.width; int maxCount = trad.MaxCount; Rect rect2 = new Rect(num - 240f, 0f, 240f, rect.height); TransferableOneWayWidget.stoppingPoints.Clear(); if (this.availableMassGetter != null && (!(trad.AnyThing is Pawn) || this.includePawnsMassInMassUsage)) { float num2 = availableMass + this.GetMass(trad.AnyThing) * (float)trad.CountToTransfer; int threshold = (num2 > 0f) ? Mathf.FloorToInt(num2 / this.GetMass(trad.AnyThing)) : 0; TransferableOneWayWidget.stoppingPoints.Add(new TransferableCountToTransferStoppingPoint(threshold, "M<", ">M")); } Pawn pawn = trad.AnyThing as Pawn; bool flag = pawn != null && (pawn.IsColonist || pawn.IsPrisonerOfColony); Rect rect3 = rect2; int min = 0; int max = maxCount; List <TransferableCountToTransferStoppingPoint> extraStoppingPoints = TransferableOneWayWidget.stoppingPoints; TransferableUIUtility.DoCountAdjustInterface(rect3, trad, index, min, max, false, extraStoppingPoints, this.playerPawnsReadOnly && flag); num -= 240f; if (this.drawMarketValue) { Rect rect4 = new Rect(num - 100f, 0f, 100f, rect.height); Text.Anchor = TextAnchor.MiddleLeft; this.DrawMarketValue(rect4, trad); num -= 100f; } if (this.drawMass) { Rect rect5 = new Rect(num - 100f, 0f, 100f, rect.height); Text.Anchor = TextAnchor.MiddleLeft; this.DrawMass(rect5, trad, availableMass); num -= 100f; } if (this.drawDaysUntilRot) { Rect rect6 = new Rect(num - 75f, 0f, 75f, rect.height); Text.Anchor = TextAnchor.MiddleLeft; this.DrawDaysUntilRot(rect6, trad); num -= 75f; } if (this.drawItemNutrition) { Rect rect7 = new Rect(num - 75f, 0f, 75f, rect.height); Text.Anchor = TextAnchor.MiddleLeft; this.DrawItemNutrition(rect7, trad); num -= 75f; } if (this.drawForagedFoodPerDay) { Rect rect8 = new Rect(num - 75f, 0f, 75f, rect.height); Text.Anchor = TextAnchor.MiddleLeft; if (!this.DrawGrazeability(rect8, trad)) { this.DrawForagedFoodPerDay(rect8, trad); } num -= 75f; } if (this.drawNutritionEatenPerDay) { Rect rect9 = new Rect(num - 75f, 0f, 75f, rect.height); Text.Anchor = TextAnchor.MiddleLeft; this.DrawNutritionEatenPerDay(rect9, trad); num -= 75f; } if (this.ShouldShowCount(trad)) { Rect rect10 = new Rect(num - 75f, 0f, 75f, rect.height); Widgets.DrawHighlightIfMouseover(rect10); Text.Anchor = TextAnchor.MiddleLeft; Rect rect11 = rect10; rect11.xMin += 5f; rect11.xMax -= 5f; Widgets.Label(rect11, maxCount.ToStringCached()); TooltipHandler.TipRegion(rect10, this.sourceCountDesc); } num -= 75f; if (this.drawEquippedWeapon) { Rect rect12 = new Rect(num - 30f, 0f, 30f, rect.height); Rect iconRect = new Rect(num - 30f, (rect.height - 30f) / 2f, 30f, 30f); this.DrawEquippedWeapon(rect12, iconRect, trad); num -= 30f; } Pawn pawn2 = trad.AnyThing as Pawn; if (pawn2 != null && pawn2.def.race.Animal) { Rect rect13 = new Rect(num - TransferableOneWayWidget.BondIconWidth, (rect.height - TransferableOneWayWidget.BondIconWidth) / 2f, TransferableOneWayWidget.BondIconWidth, TransferableOneWayWidget.BondIconWidth); num -= TransferableOneWayWidget.BondIconWidth; Rect rect14 = new Rect(num - TransferableOneWayWidget.PregnancyIconWidth, (rect.height - TransferableOneWayWidget.PregnancyIconWidth) / 2f, TransferableOneWayWidget.PregnancyIconWidth, TransferableOneWayWidget.PregnancyIconWidth); num -= TransferableOneWayWidget.PregnancyIconWidth; string iconTooltipText = TrainableUtility.GetIconTooltipText(pawn2); if (!iconTooltipText.NullOrEmpty()) { TooltipHandler.TipRegion(rect13, iconTooltipText); } if (pawn2.relations.GetFirstDirectRelationPawn(PawnRelationDefOf.Bond, null) != null) { GUI.DrawTexture(rect13, TransferableOneWayWidget.BondIcon); } if (pawn2.health.hediffSet.HasHediff(HediffDefOf.Pregnant, true)) { TooltipHandler.TipRegion(rect14, PawnColumnWorker_Pregnant.GetTooltipText(pawn2)); GUI.DrawTexture(rect14, TransferableOneWayWidget.PregnantIcon); } } Rect idRect = new Rect(0f, 0f, num, rect.height); TransferableUIUtility.DrawTransferableInfo(trad, idRect, Color.white); GenUI.ResetLabelAlign(); GUI.EndGroup(); }
public void Debug_MakeDegradeHappenSoon() { this.countDecayFrom = Find.TickManager.TicksGame - TrainableUtility.DegradationPeriodTicks(this.pawn.def) - 500; }
protected override ThoughtState CurrentStateInternal(Pawn p) { List <DirectPawnRelation> directRelations = p.relations.DirectRelations; for (int i = 0; i < directRelations.Count; i++) { DirectPawnRelation directPawnRelation = directRelations[i]; Pawn otherPawn = directPawnRelation.otherPawn; if (directPawnRelation.def == PawnRelationDefOf.Bond && !otherPawn.Dead && otherPawn.Spawned && otherPawn.Faction == Faction.OfPlayer && otherPawn.training.IsCompleted(TrainableDefOf.Obedience) && p.skills.GetSkill(SkillDefOf.Animals).Level >= TrainableUtility.MinimumHandlingSkill(otherPawn) && this.AnimalMasterCheck(p, otherPawn)) { return(ThoughtState.ActiveWithReason(otherPawn.LabelShort)); } } return(false); }