private void GetLetterText(Pawn prisoner, Site site, SitePart sitePart, int days, out string letter, out string label) { letter = this.def.letterText.Formatted(site.Faction.Name, prisoner.ageTracker.AgeBiologicalYears, prisoner.story.Title, SitePartUtility.GetDescriptionDialogue(site, sitePart), prisoner.Named("PAWN")).AdjustedFor(prisoner, "PAWN").CapitalizeFirst(); if (PawnUtility.EverBeenColonistOrTameAnimal(prisoner)) { letter = letter + "\n\n" + "PawnWasFormerlyColonist".Translate(prisoner.LabelShort, prisoner); } Helper.Log("Was Formally a colonist"); string text; PawnRelationUtility.Notify_PawnsSeenByPlayer(Gen.YieldSingle <Pawn>(prisoner), out text, true, false); label = this.def.letterLabel; if (!text.NullOrEmpty()) { string text2 = letter; letter = string.Concat(new string[] { text2, "\n\n", "PawnHasTheseRelationshipsWithColonists".Translate(prisoner.LabelShort, prisoner), "\n\n", text }); label = label + " " + "RelationshipAppendedLetterSuffix".Translate(); } letter = letter + "\n\n" + "PrisonerRescueTimeout".Translate(days, prisoner.LabelShort, prisoner.Named("PRISONER")); }
private static Pawn GenerateOrRedressPawnInternal(PawnGenerationRequest request) { Pawn result = null; if (!request.Newborn && !request.ForceGenerateNewPawn) { if (request.ForceRedressWorldPawnIfFormerColonist && (from x in GetValidCandidatesToRedress(request) where PawnUtility.EverBeenColonistOrTameAnimal(x) select x).TryRandomElementByWeight((Pawn x) => WorldPawnSelectionWeight(x), out result)) { RedressPawn(result, request); Find.WorldPawns.RemovePawn(result); } if (result == null && request.Inhabitant && request.Tile != -1) { Settlement settlement = Find.WorldObjects.WorldObjectAt <Settlement>(request.Tile); if (settlement != null && settlement.previouslyGeneratedInhabitants.Any() && (from x in GetValidCandidatesToRedress(request) where settlement.previouslyGeneratedInhabitants.Contains(x) select x).TryRandomElementByWeight((Pawn x) => WorldPawnSelectionWeight(x), out result)) { RedressPawn(result, request); Find.WorldPawns.RemovePawn(result); } } if (result == null && Rand.Chance(ChanceToRedressAnyWorldPawn(request)) && GetValidCandidatesToRedress(request).TryRandomElementByWeight((Pawn x) => WorldPawnSelectionWeight(x), out result)) { RedressPawn(result, request); Find.WorldPawns.RemovePawn(result); } } bool redressed; if (result == null) { redressed = false; result = GenerateNewPawnInternal(ref request); if (result == null) { return(null); } if (request.Inhabitant && request.Tile != -1) { Find.WorldObjects.WorldObjectAt <Settlement>(request.Tile)?.previouslyGeneratedInhabitants.Add(result); } } else { redressed = true; } if (Find.Scenario != null) { Find.Scenario.Notify_PawnGenerated(result, request.Context, redressed); } return(result); }
static void Postfix(Pawn pawn) { if (pawn.RaceProps.Humanlike && !pawn.Dead && pawn.Faction?.IsPlayer == true) { if (!PawnUtility.EverBeenColonistOrTameAnimal(pawn)) { if (pawn.WorkTagIsDisabled(WorkTags.Violent)) { pawn.playerSettings.hostilityResponse = StandYourGroundSettings.pacifistDefault; } else { pawn.playerSettings.hostilityResponse = StandYourGroundSettings.violentDefault; } } //if (StandYourGroundSettings.flagAreaRestriction) //{ // if (pawn.Map != null) // { // Log.Message("... checking area"); // List<Pawn> colonists = pawn.Map.mapPawns.FreeColonists; // if (colonists.Count > 2) // { // //Area area = colonists.GroupBy(c => c.playerSettings.AreaRestriction) // // .Select(y => new { Area = y.Key, Count = y.Count() }).OrderByDescending(g => g.Count).First().Area; // Area area = colonists.Where(c => c != pawn).GroupBy(c => c.playerSettings.AreaRestriction) // .Select(y => new { Area = y.Key, Count = y.Count() }).OrderByDescending(g => g.Count).First().Area; // if (area != null) // { // Log.Message("Found area " + area.Label); // Log.Message("Found area " + area); // pawn.playerSettings.AreaRestriction = area; // Log.Message("Pawn assigned to " + pawn.playerSettings.AreaRestriction.Label); // } // } // } //} } }
private string GetCriticalPawnReason(Pawn pawn) { if (pawn.Discarded) { return(null); } if (PawnUtility.EverBeenColonistOrTameAnimal(pawn) && pawn.RaceProps.Humanlike) { return("Colonist"); } if (PawnGenerator.IsBeingGenerated(pawn)) { return("Generating"); } if (PawnUtility.IsFactionLeader(pawn)) { return("FactionLeader"); } if (PawnUtility.IsKidnappedPawn(pawn)) { return("Kidnapped"); } if (pawn.IsCaravanMember()) { return("CaravanMember"); } if (PawnUtility.IsTravelingInTransportPodWorldObject(pawn)) { return("TransportPod"); } if (PawnUtility.ForSaleBySettlement(pawn)) { return("ForSale"); } if (Find.WorldPawns.ForcefullyKeptPawns.Contains(pawn)) { return("ForceKept"); } if (pawn.SpawnedOrAnyParentSpawned) { return("Spawned"); } if (!pawn.Corpse.DestroyedOrNull()) { return("CorpseExists"); } if (pawn.RaceProps.Humanlike && Current.ProgramState == ProgramState.Playing) { if (Find.PlayLog.AnyEntryConcerns(pawn)) { return("InPlayLog"); } if (Find.BattleLog.AnyEntryConcerns(pawn)) { return("InBattleLog"); } } if (Current.ProgramState == ProgramState.Playing && Find.TaleManager.AnyActiveTaleConcerns(pawn)) { return("InActiveTale"); } if (QuestUtility.IsReservedByQuestOrQuestBeingGenerated(pawn)) { return("ReservedByQuest"); } return(null); }
public static IEnumerable <Rule> RulesForPawn(string pawnSymbol, Pawn pawn, Dictionary <string, string> constants = null, bool addRelationInfoSymbol = true, bool addTags = true) { if (pawn == null) { Log.ErrorOnce($"Tried to insert rule {pawnSymbol} for null pawn", 16015097); return(Enumerable.Empty <Rule>()); } TaggedString text = ""; if (addRelationInfoSymbol) { PawnRelationUtility.TryAppendRelationsWithColonistsInfo(ref text, pawn); } return(RulesForPawn(pawnSymbol, pawn.Name, (pawn.story != null) ? pawn.story.Title : null, pawn.kindDef, pawn.gender, pawn.Faction, pawn.ageTracker.AgeBiologicalYears, pawn.ageTracker.AgeChronologicalYears, text, PawnUtility.EverBeenColonistOrTameAnimal(pawn), PawnUtility.EverBeenQuestLodger(pawn), pawn.Faction != null && pawn.Faction.leader == pawn, (pawn.royalty != null) ? pawn.royalty.AllTitlesForReading : null, constants, addTags)); }