public static bool TryAppendRelationsWithColonistsInfo(ref string text, ref string title, Pawn pawn)
        {
            Pawn mostImportantColonyRelative = PawnRelationUtility.GetMostImportantColonyRelative(pawn);

            if (mostImportantColonyRelative == null)
            {
                return(false);
            }
            if (title != null)
            {
                title = title + " " + "RelationshipAppendedLetterSuffix".Translate();
            }
            string genderSpecificLabel = mostImportantColonyRelative.GetMostImportantRelation(pawn).GetGenderSpecificLabel(pawn);

            if (mostImportantColonyRelative.IsColonist)
            {
                text = text + "\n\n" + "RelationshipAppendedLetterTextColonist".Translate(new object[]
                {
                    mostImportantColonyRelative.LabelShort,
                    genderSpecificLabel
                }).AdjustedFor(pawn, "PAWN");
            }
            else
            {
                text = text + "\n\n" + "RelationshipAppendedLetterTextPrisoner".Translate(new object[]
                {
                    mostImportantColonyRelative.LabelShort,
                    genderSpecificLabel
                }).AdjustedFor(pawn, "PAWN");
            }
            return(true);
        }
Example #2
0
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            int tile;

            if (!this.TryFindTile(out tile))
            {
                return(false);
            }
            Site site = SiteMaker.TryMakeSite_SingleSitePart(SiteCoreDefOf.DownedRefugee, (!Rand.Chance(0.3f)) ? "DownedRefugeeQuestThreat" : null, tile, null, true, null, true, null);

            if (site == null)
            {
                return(false);
            }
            site.sitePartsKnown = true;
            Pawn pawn = DownedRefugeeQuestUtility.GenerateRefugee(tile);

            site.GetComponent <DownedRefugeeComp>().pawn.TryAdd(pawn, true);
            int randomInRange = SiteTuning.QuestSiteRefugeeTimeoutDaysRange.RandomInRange;

            site.GetComponent <TimeoutComp>().StartTimeout(randomInRange * 60000);
            Find.WorldObjects.Add(site);
            string text  = this.def.letterLabel;
            string text2 = string.Format(this.def.letterText.AdjustedFor(pawn, "PAWN"), new object[]
            {
                randomInRange,
                pawn.ageTracker.AgeBiologicalYears,
                pawn.story.Title,
                SitePartUtility.GetDescriptionDialogue(site, site.parts.FirstOrDefault <SitePart>())
            }).CapitalizeFirst();
            Pawn mostImportantColonyRelative = PawnRelationUtility.GetMostImportantColonyRelative(pawn);

            if (mostImportantColonyRelative != null)
            {
                PawnRelationDef mostImportantRelation = mostImportantColonyRelative.GetMostImportantRelation(pawn);
                if (mostImportantRelation != null && mostImportantRelation.opinionOffset > 0)
                {
                    pawn.relations.relativeInvolvedInRescueQuest = mostImportantColonyRelative;
                    text2 = text2 + "\n\n" + "RelatedPawnInvolvedInQuest".Translate(new object[]
                    {
                        mostImportantColonyRelative.LabelShort,
                        mostImportantRelation.GetGenderSpecificLabel(pawn)
                    }).AdjustedFor(pawn, "PAWN");
                }
                else
                {
                    PawnRelationUtility.TryAppendRelationsWithColonistsInfo(ref text2, pawn);
                }
                text = text + " " + "RelationshipAppendedLetterSuffix".Translate();
            }
            if (pawn.relations != null)
            {
                pawn.relations.everSeenByPlayer = true;
            }
            Find.LetterStack.ReceiveLetter(text, text2, this.def.letterDef, site, null, null);
            return(true);
        }
Example #3
0
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            int tile;

            if (!this.TryFindTile(out tile))
            {
                return(false);
            }
            Site site = SiteMaker.TryMakeSite_SingleSitePart(SiteCoreDefOf.DownedRefugee, (!Rand.Chance(0.3f)) ? IncidentWorker_QuestDownedRefugee.DownedRefugeeQuestThreatTag : null, null, true, null);

            if (site == null)
            {
                return(false);
            }
            site.Tile = tile;
            Pawn pawn = DownedRefugeeQuestUtility.GenerateRefugee(tile);

            site.GetComponent <DownedRefugeeComp>().pawn.TryAdd(pawn, true);
            int randomInRange = IncidentWorker_QuestDownedRefugee.TimeoutDaysRange.RandomInRange;

            site.GetComponent <TimeoutComp>().StartTimeout(randomInRange * 60000);
            Find.WorldObjects.Add(site);
            string text = string.Format(this.def.letterText.AdjustedFor(pawn), pawn.Label, randomInRange).CapitalizeFirst();
            Pawn   mostImportantColonyRelative = PawnRelationUtility.GetMostImportantColonyRelative(pawn);

            if (mostImportantColonyRelative != null)
            {
                PawnRelationDef mostImportantRelation = mostImportantColonyRelative.GetMostImportantRelation(pawn);
                if (mostImportantRelation != null && mostImportantRelation.opinionOffset > 0)
                {
                    pawn.relations.relativeInvolvedInRescueQuest = mostImportantColonyRelative;
                    text = text + "\n\n" + "RelatedPawnInvolvedInQuest".Translate(new object[]
                    {
                        mostImportantColonyRelative.LabelShort,
                        mostImportantRelation.GetGenderSpecificLabel(pawn)
                    }).AdjustedFor(pawn);
                }
                else
                {
                    PawnRelationUtility.TryAppendRelationsWithColonistsInfo(ref text, pawn);
                }
            }
            if (pawn.relations != null)
            {
                pawn.relations.everSeenByPlayer = true;
            }
            Find.LetterStack.ReceiveLetter(this.def.letterLabel, text, this.def.letterDef, site, null);
            return(true);
        }
        public static bool TryAppendRelationsWithColonistsInfo(ref string text, ref string title, Pawn pawn)
        {
            Pawn mostImportantColonyRelative = PawnRelationUtility.GetMostImportantColonyRelative(pawn);

            if (mostImportantColonyRelative == null)
            {
                return(false);
            }
            if (title != null)
            {
                title = title + " " + "RelationshipAppendedLetterSuffix".Translate();
            }
            string genderSpecificLabel = mostImportantColonyRelative.GetMostImportantRelation(pawn).GetGenderSpecificLabel(pawn);
            string str = "\n\n";

            str   = ((!mostImportantColonyRelative.IsColonist) ? (str + "RelationshipAppendedLetterTextPrisoner".Translate(mostImportantColonyRelative.LabelShort, genderSpecificLabel)) : (str + "RelationshipAppendedLetterTextColonist".Translate(mostImportantColonyRelative.LabelShort, genderSpecificLabel)));
            text += str.AdjustedFor(pawn);
            return(true);
        }
        public static void Notify_PawnsSeenByPlayer_Letter_Send(IEnumerable <Pawn> seenPawns, string relationsInfoHeader, LetterDef letterDef, bool informEvenIfSeenBefore = false, bool writeSeenPawnsNames = true)
        {
            string empty  = string.Empty;
            string empty2 = string.Empty;

            PawnRelationUtility.Notify_PawnsSeenByPlayer_Letter(seenPawns, ref empty, ref empty2, relationsInfoHeader, informEvenIfSeenBefore, writeSeenPawnsNames);
            if (!empty2.NullOrEmpty())
            {
                Pawn pawn = null;
                foreach (Pawn current in seenPawns)
                {
                    if (PawnRelationUtility.GetMostImportantColonyRelative(current) != null)
                    {
                        pawn = current;
                        break;
                    }
                }
                if (pawn == null)
                {
                    pawn = seenPawns.FirstOrDefault <Pawn>();
                }
                Find.LetterStack.ReceiveLetter(empty, empty2, letterDef, pawn, null, null);
            }
        }
Example #6
0
        public static void Notify_PawnsSeenByPlayer_Letter_Send(IEnumerable <Pawn> seenPawns, string relationsInfoHeader, LetterDef letterDef, bool informEvenIfSeenBefore = false, bool writeSeenPawnsNames = true)
        {
            string label = "";
            string text  = "";

            PawnRelationUtility.Notify_PawnsSeenByPlayer_Letter(seenPawns, ref label, ref text, relationsInfoHeader, informEvenIfSeenBefore, writeSeenPawnsNames);
            if (!text.NullOrEmpty())
            {
                Pawn pawn = null;
                foreach (Pawn pawn2 in seenPawns)
                {
                    if (PawnRelationUtility.GetMostImportantColonyRelative(pawn2) != null)
                    {
                        pawn = pawn2;
                        break;
                    }
                }
                if (pawn == null)
                {
                    pawn = seenPawns.FirstOrDefault <Pawn>();
                }
                Find.LetterStack.ReceiveLetter(label, text, letterDef, pawn, null, null);
            }
        }