Exemple #1
0
 public override void TryOpenComms(Pawn negotiator)
 {
     if (this.CanTradeNow)
     {
         Find.WindowStack.Add(new Dialog_Trade(negotiator, this, false));
         LessonAutoActivator.TeachOpportunity(ConceptDefOf.BuildOrbitalTradeBeacon, OpportunityType.Critical);
         PawnRelationUtility.Notify_PawnsSeenByPlayer_Letter_Send(this.Goods.OfType <Pawn>(), "LetterRelatedPawnsTradeShip".Translate(new object[]
         {
             Faction.OfPlayer.def.pawnsPlural
         }), LetterDefOf.NeutralEvent, false, true);
         TutorUtility.DoModalDialogIfNotKnown(ConceptDefOf.TradeGoodsMustBeNearBeacon);
     }
 }
Exemple #2
0
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            Map map = (Map)parms.target;

            if (!base.TryResolveParms(parms))
            {
                return(false);
            }
            IntVec3 travelDest;

            if (!RCellFinder.TryFindTravelDestFrom(parms.spawnCenter, map, out travelDest))
            {
                Log.Warning("Failed to do traveler incident from " + parms.spawnCenter + ": Couldn't find anywhere for the traveler to go.", false);
                return(false);
            }
            List <Pawn> list = base.SpawnPawns(parms);

            if (list.Count == 0)
            {
                return(false);
            }
            string text;

            if (list.Count == 1)
            {
                text = "SingleTravelerPassing".Translate(new object[]
                {
                    list[0].story.Title,
                    parms.faction.Name,
                    list[0].Name
                });
                text = text.AdjustedFor(list[0], "PAWN");
            }
            else
            {
                text = "GroupTravelersPassing".Translate(new object[]
                {
                    parms.faction.Name
                });
            }
            Messages.Message(text, list[0], MessageTypeDefOf.NeutralEvent, true);
            LordJob_TravelAndExit lordJob = new LordJob_TravelAndExit(travelDest);

            LordMaker.MakeNewLord(parms.faction, lordJob, map, list);
            PawnRelationUtility.Notify_PawnsSeenByPlayer_Letter_Send(list, "LetterRelatedPawnsNeutralGroup".Translate(new object[]
            {
                Faction.OfPlayer.def.pawnsPlural
            }), LetterDefOf.NeutralEvent, true, true);
            return(true);
        }
Exemple #3
0
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            Map map = (Map)parms.target;

            if (!base.TryResolveParms(parms))
            {
                return(false);
            }
            List <Pawn> list = base.SpawnPawns(parms);

            if (list.Count == 0)
            {
                return(false);
            }
            IntVec3 chillSpot = default(IntVec3);

            RCellFinder.TryFindRandomSpotJustOutsideColony(list[0], out chillSpot);
            LordJob_VisitColony lordJob = new LordJob_VisitColony(parms.faction, chillSpot);

            LordMaker.MakeNewLord(parms.faction, lordJob, map, list);
            bool flag = false;

            if (Rand.Value < 0.75)
            {
                flag = this.TryConvertOnePawnToSmallTrader(list, parms.faction, map);
            }
            Pawn   pawn = list.Find((Pawn x) => parms.faction.leader == x);
            string label;
            string text3;

            if (list.Count == 1)
            {
                string text  = (!flag) ? string.Empty : "SingleVisitorArrivesTraderInfo".Translate();
                string text2 = (pawn == null) ? string.Empty : "SingleVisitorArrivesLeaderInfo".Translate();
                label = "LetterLabelSingleVisitorArrives".Translate();
                text3 = "SingleVisitorArrives".Translate(list[0].story.Title.ToLower(), parms.faction.Name, list[0].Name, text, text2);
                text3 = text3.AdjustedFor(list[0]);
            }
            else
            {
                string text4 = (!flag) ? string.Empty : "GroupVisitorsArriveTraderInfo".Translate();
                string text5 = (pawn == null) ? string.Empty : "GroupVisitorsArriveLeaderInfo".Translate(pawn.LabelShort);
                label = "LetterLabelGroupVisitorsArrive".Translate();
                text3 = "GroupVisitorsArrive".Translate(parms.faction.Name, text4, text5);
            }
            PawnRelationUtility.Notify_PawnsSeenByPlayer_Letter(list, ref label, ref text3, "LetterRelatedPawnsNeutralGroup".Translate(), true, true);
            Find.LetterStack.ReceiveLetter(label, text3, LetterDefOf.NeutralEvent, list[0], null);
            return(true);
        }
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            Map map = (Map)parms.target;

            if (!base.TryResolveParms(parms))
            {
                return(false);
            }
            if (parms.faction.HostileTo(Faction.OfPlayer))
            {
                return(false);
            }
            List <Pawn> list = base.SpawnPawns(parms);

            if (list.Count == 0)
            {
                return(false);
            }
            for (int i = 0; i < list.Count; i++)
            {
                if (list[i].needs != null && list[i].needs.food != null)
                {
                    list[i].needs.food.CurLevel = list[i].needs.food.MaxLevel;
                }
            }
            TraderKindDef traderKindDef = null;

            for (int j = 0; j < list.Count; j++)
            {
                Pawn pawn = list[j];
                if (pawn.TraderKind != null)
                {
                    traderKindDef = pawn.TraderKind;
                    break;
                }
            }
            string label = "LetterLabelTraderCaravanArrival".Translate(parms.faction.Name, traderKindDef.label).CapitalizeFirst();
            string text  = "LetterTraderCaravanArrival".Translate(parms.faction.Name, traderKindDef.label).CapitalizeFirst();

            PawnRelationUtility.Notify_PawnsSeenByPlayer_Letter(list, ref label, ref text, "LetterRelatedPawnsNeutralGroup".Translate(), true, true);
            Find.LetterStack.ReceiveLetter(label, text, LetterDefOf.PositiveEvent, list[0], null);
            IntVec3 chillSpot = default(IntVec3);

            RCellFinder.TryFindRandomSpotJustOutsideColony(list[0], out chillSpot);
            LordJob_TradeWithColony lordJob = new LordJob_TradeWithColony(parms.faction, chillSpot);

            LordMaker.MakeNewLord(parms.faction, lordJob, map, list);
            return(true);
        }
Exemple #5
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);
        }
        // Token: 0x06000F15 RID: 3861 RVA: 0x000701C0 File Offset: 0x0006E5C0
        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);

            pawn.health.AddHediff(XenomorphDefOf.RRY_HiddenXenomorphImpregnation);
            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 = this.def.letterText.Formatted(randomInRange, pawn.ageTracker.AgeBiologicalYears, pawn.story.Title, SitePartUtility.GetDescriptionDialogue(site, site.parts.FirstOrDefault <SitePart>()), pawn.Named("PAWN")).AdjustedFor(pawn, "PAWN").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(mostImportantColonyRelative.LabelShort, mostImportantRelation.GetGenderSpecificLabel(pawn), mostImportantColonyRelative.Named("RELATIVE"), pawn.Named("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);
        }
 public override void TryOpenComms(Pawn negotiator)
 {
     if (this.CanTradeNow)
     {
         Find.WindowStack.Add(new Dialog_Trade(negotiator, this));
         LessonAutoActivator.TeachOpportunity(ConceptDefOf.BuildOrbitalTradeBeacon, OpportunityType.Critical);
         string empty  = string.Empty;
         string empty2 = string.Empty;
         PawnRelationUtility.Notify_PawnsSeenByPlayer_Letter(this.Goods.OfType <Pawn>(), ref empty, ref empty2, "LetterRelatedPawnsTradeShip".Translate(), false, true);
         if (!empty2.NullOrEmpty())
         {
             Find.LetterStack.ReceiveLetter(empty, empty2, LetterDefOf.PositiveEvent, (string)null);
         }
         TutorUtility.DoModalDialogIfNotKnown(ConceptDefOf.TradeGoodsMustBeNearBeacon);
     }
 }
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            Map map = (Map)parms.target;

            if (!TryResolveParms(parms))
            {
                return(false);
            }
            List <Pawn> list = SpawnPawns(parms);

            if (list.Count == 0)
            {
                return(false);
            }
            RCellFinder.TryFindRandomSpotJustOutsideColony(list[0], out IntVec3 result);
            LordJob_VisitColony lordJob = new LordJob_VisitColony(parms.faction, result);

            LordMaker.MakeNewLord(parms.faction, lordJob, map, list);
            bool flag = false;

            if (Rand.Value < 0.75f)
            {
                flag = TryConvertOnePawnToSmallTrader(list, parms.faction, map);
            }
            Pawn   pawn = list.Find((Pawn x) => parms.faction.leader == x);
            string letterLabel;
            string letterText;

            if (list.Count == 1)
            {
                string value  = (!flag) ? string.Empty : ("\n\n" + "SingleVisitorArrivesTraderInfo".Translate(list[0].Named("PAWN")).AdjustedFor(list[0]));
                string value2 = (pawn == null) ? string.Empty : ("\n\n" + "SingleVisitorArrivesLeaderInfo".Translate(list[0].Named("PAWN")).AdjustedFor(list[0]));
                letterLabel = "LetterLabelSingleVisitorArrives".Translate();
                letterText  = "SingleVisitorArrives".Translate(list[0].story.Title, parms.faction.Name, list[0].Name.ToStringFull, value, value2, list[0].Named("PAWN")).AdjustedFor(list[0]);
            }
            else
            {
                string value3 = (!flag) ? string.Empty : ("\n\n" + "GroupVisitorsArriveTraderInfo".Translate());
                string value4 = (pawn == null) ? string.Empty : ("\n\n" + "GroupVisitorsArriveLeaderInfo".Translate(pawn.LabelShort, pawn));
                letterLabel = "LetterLabelGroupVisitorsArrive".Translate();
                letterText  = "GroupVisitorsArrive".Translate(parms.faction.Name, value3, value4);
            }
            PawnRelationUtility.Notify_PawnsSeenByPlayer_Letter(list, ref letterLabel, ref letterText, "LetterRelatedPawnsNeutralGroup".Translate(Faction.OfPlayer.def.pawnsPlural), informEvenIfSeenBefore: true);
            Find.LetterStack.ReceiveLetter(letterLabel, letterText, LetterDefOf.NeutralEvent, list[0], parms.faction);
            return(true);
        }
 private void GetLetterText(Pawn prisoner, Site site, SitePart sitePart, int days, out string letter, out string label)
 {
     letter = def.letterText.Formatted(site.Faction.Name, prisoner.ageTracker.AgeBiologicalYears, prisoner.story.Title, SitePartUtility.GetDescriptionDialogue(site, sitePart), prisoner.Named("PAWN")).AdjustedFor(prisoner).CapitalizeFirst();
     if (PawnUtility.EverBeenColonistOrTameAnimal(prisoner))
     {
         letter = letter + "\n\n" + "PawnWasFormerlyColonist".Translate(prisoner.LabelShort, prisoner);
     }
     PawnRelationUtility.Notify_PawnsSeenByPlayer(Gen.YieldSingle(prisoner), out string pawnRelationsInfo, informEvenIfSeenBefore: true, writeSeenPawnsNames: false);
     label = def.letterLabel;
     if (!pawnRelationsInfo.NullOrEmpty())
     {
         string text = letter;
         letter = text + "\n\n" + "PawnHasTheseRelationshipsWithColonists".Translate(prisoner.LabelShort, prisoner) + "\n\n" + pawnRelationsInfo;
         label  = label + " " + "RelationshipAppendedLetterSuffix".Translate();
     }
     letter = letter + "\n\n" + "PrisonerRescueTimeout".Translate(days, prisoner.LabelShort, prisoner.Named("PRISONER"));
 }
Exemple #10
0
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            Map map = (Map)parms.target;

            if (!base.TryResolveParms(parms))
            {
                return(false);
            }
            IntVec3 travelDest = default(IntVec3);

            if (!RCellFinder.TryFindTravelDestFrom(parms.spawnCenter, map, out travelDest))
            {
                Log.Warning("Failed to do traveler incident from " + parms.spawnCenter + ": couldn't find anywhere for the traveler to go.");
                return(false);
            }
            List <Pawn> list = base.SpawnPawns(parms);

            if (list.Count == 0)
            {
                return(false);
            }
            string text;

            if (list.Count == 1)
            {
                text = "SingleTravelerPassing".Translate(list[0].story.Title.ToLower(), parms.faction.Name, list[0].Name);
                text = text.AdjustedFor(list[0]);
            }
            else
            {
                text = "GroupTravelersPassing".Translate(parms.faction.Name);
            }
            Messages.Message(text, list[0], MessageTypeDefOf.NeutralEvent);
            LordJob_TravelAndExit lordJob = new LordJob_TravelAndExit(travelDest);

            LordMaker.MakeNewLord(parms.faction, lordJob, map, list);
            string empty  = string.Empty;
            string empty2 = string.Empty;

            PawnRelationUtility.Notify_PawnsSeenByPlayer_Letter(list, ref empty, ref empty2, "LetterRelatedPawnsNeutralGroup".Translate(), true, true);
            if (!empty2.NullOrEmpty())
            {
                Find.LetterStack.ReceiveLetter(empty, empty2, LetterDefOf.NeutralEvent, list[0], null);
            }
            return(true);
        }
Exemple #11
0
        private string GetLetterText(Pawn prisoner, Faction siteFaction, int days)
        {
            string text = string.Format(base.def.letterText.AdjustedFor(prisoner), siteFaction.Name, prisoner.ageTracker.AgeBiologicalYears, prisoner.story.Title).CapitalizeFirst();

            if (PawnUtility.EverBeenColonistOrTameAnimal(prisoner))
            {
                text = text + "\n\n" + "PawnWasFormerlyColonist".Translate(prisoner.LabelShort);
            }
            string text2 = default(string);

            PawnRelationUtility.Notify_PawnsSeenByPlayer(Gen.YieldSingle(prisoner), out text2, true, false);
            if (!text2.NullOrEmpty())
            {
                string text3 = text;
                text = text3 + "\n\n" + "PawnHasTheseRelationshipsWithColonists".Translate(prisoner.LabelShort) + "\n\n" + text2;
            }
            return(text + "\n\n" + "PrisonerRescueTimeout".Translate(days, prisoner.LabelShort));
        }
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            Map          map    = (Map)parms.target;
            List <Thing> things = ThingSetMakerDefOf.RefugeePod.root.Generate();
            IntVec3      intVec = DropCellFinder.RandomDropSpot(map);
            Pawn         pawn   = this.FindPawn(things);

            pawn.guest.getRescuedThoughtOnUndownedBecauseOfPlayer = true;
            string label = "LetterLabelRefugeePodCrash".Translate();
            string text  = "RefugeePodCrash".Translate().AdjustedFor(pawn, "PAWN");

            text += "\n\n";
            if (pawn.Faction == null)
            {
                text += "RefugeePodCrash_Factionless".Translate(new object[]
                {
                    pawn
                }).AdjustedFor(pawn, "PAWN");
            }
            else if (pawn.Faction.HostileTo(Faction.OfPlayer))
            {
                text += "RefugeePodCrash_Hostile".Translate(new object[]
                {
                    pawn
                }).AdjustedFor(pawn, "PAWN");
            }
            else
            {
                text += "RefugeePodCrash_NonHostile".Translate(new object[]
                {
                    pawn
                }).AdjustedFor(pawn, "PAWN");
            }
            PawnRelationUtility.TryAppendRelationsWithColonistsInfo(ref text, ref label, pawn);
            Find.LetterStack.ReceiveLetter(label, text, LetterDefOf.NeutralEvent, new TargetInfo(intVec, map, false), null, null);
            ActiveDropPodInfo activeDropPodInfo = new ActiveDropPodInfo();

            activeDropPodInfo.innerContainer.TryAddRangeOrTransfer(things, true, false);
            activeDropPodInfo.openDelay = 180;
            activeDropPodInfo.leaveSlag = true;
            DropPodUtility.MakeDropPodAt(intVec, map, activeDropPodInfo);
            return(true);
        }
Exemple #13
0
        public static TaleData_Pawn GenerateFrom(Pawn pawn)
        {
            TaleData_Pawn taleData_Pawn = new TaleData_Pawn();

            taleData_Pawn.pawn                         = pawn;
            taleData_Pawn.kind                         = pawn.kindDef;
            taleData_Pawn.faction                      = pawn.Faction;
            taleData_Pawn.gender                       = (pawn.RaceProps.hasGenders ? pawn.gender : Gender.None);
            taleData_Pawn.age                          = pawn.ageTracker.AgeBiologicalYears;
            taleData_Pawn.chronologicalAge             = pawn.ageTracker.AgeChronologicalYears;
            taleData_Pawn.everBeenColonistOrTameAnimal = PawnUtility.EverBeenColonistOrTameAnimal(pawn);
            taleData_Pawn.everBeenQuestLodger          = PawnUtility.EverBeenQuestLodger(pawn);
            taleData_Pawn.isFactionLeader              = (pawn.Faction != null && pawn.Faction.leader == pawn);
            if (pawn.royalty != null)
            {
                taleData_Pawn.royalTitles = new List <RoyalTitle>();
                foreach (RoyalTitle item in pawn.royalty.AllTitlesForReading)
                {
                    taleData_Pawn.royalTitles.Add(new RoyalTitle(item));
                }
            }
            TaggedString text = "";

            PawnRelationUtility.TryAppendRelationsWithColonistsInfo(ref text, pawn);
            taleData_Pawn.relationInfo = text.Resolve();
            if (pawn.story != null)
            {
                taleData_Pawn.title = pawn.story.title;
            }
            if (pawn.RaceProps.Humanlike)
            {
                taleData_Pawn.name = pawn.Name;
                if (pawn.equipment.Primary != null)
                {
                    taleData_Pawn.primaryEquipment = pawn.equipment.Primary.def;
                }
                if (pawn.apparel.WornApparel.TryRandomElement(out Apparel result))
                {
                    taleData_Pawn.notableApparel = result.def;
                }
            }
            return(taleData_Pawn);
        }
        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);
        }
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            Map          map    = (Map)parms.target;
            List <Thing> things = ItemCollectionGeneratorDefOf.RefugeePod.Worker.Generate(default(ItemCollectionGeneratorParams));
            IntVec3      intVec = DropCellFinder.RandomDropSpot(map);
            Pawn         pawn   = this.FindPawn(things);
            string       label  = "LetterLabelRefugeePodCrash".Translate();
            string       text   = "RefugeePodCrash".Translate();

            PawnRelationUtility.TryAppendRelationsWithColonistsInfo(ref text, ref label, pawn);
            Find.LetterStack.ReceiveLetter(label, text, LetterDefOf.NeutralEvent, new TargetInfo(intVec, map, false), null);
            ActiveDropPodInfo activeDropPodInfo = new ActiveDropPodInfo();

            activeDropPodInfo.innerContainer.TryAddRangeOrTransfer(things, true, false);
            activeDropPodInfo.openDelay = 180;
            activeDropPodInfo.leaveSlag = true;
            DropPodUtility.MakeDropPodAt(intVec, map, activeDropPodInfo, true);
            return(true);
        }
Exemple #16
0
        private void GetLetterText(Pawn prisoner, Site site, SitePart sitePart, int days, out string letter, out string label)
        {
            letter = string.Format(this.def.letterText.AdjustedFor(prisoner, "PAWN"), new object[]
            {
                site.Faction.Name,
                prisoner.ageTracker.AgeBiologicalYears,
                prisoner.story.Title,
                SitePartUtility.GetDescriptionDialogue(site, sitePart)
            }).CapitalizeFirst();
            if (PawnUtility.EverBeenColonistOrTameAnimal(prisoner))
            {
                letter = letter + "\n\n" + "PawnWasFormerlyColonist".Translate(new object[]
                {
                    prisoner.LabelShort
                });
            }
            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(new object[]
                    {
                        prisoner.LabelShort
                    }),
                    "\n\n",
                    text
                });
                label = label + " " + "RelationshipAppendedLetterSuffix".Translate();
            }
            letter = letter + "\n\n" + "PrisonerRescueTimeout".Translate(new object[]
            {
                days,
                prisoner.LabelShort
            });
        }
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            Map map = (Map)parms.target;

            if (!CanSpawnJoiner(map))
            {
                return(false);
            }
            Pawn pawn = GeneratePawn();

            SpawnJoiner(map, pawn);
            if (def.pawnHediff != null)
            {
                pawn.health.AddHediff(def.pawnHediff);
            }
            TaggedString text  = ((def.pawnHediff != null) ? def.letterText.Formatted(pawn.Named("PAWN"), NamedArgumentUtility.Named(def.pawnHediff, "HEDIFF")).AdjustedFor(pawn) : def.letterText.Formatted(pawn.Named("PAWN")).AdjustedFor(pawn));
            TaggedString title = def.letterLabel.Formatted(pawn.Named("PAWN")).AdjustedFor(pawn);

            PawnRelationUtility.TryAppendRelationsWithColonistsInfo(ref text, ref title, pawn);
            SendStandardLetter(title, text, LetterDefOf.PositiveEvent, parms, pawn);
            return(true);
        }
        public static void Notify_PawnsSeenByPlayer_Letter(IEnumerable <Pawn> seenPawns, ref string letterLabel, ref string letterText, string relationsInfoHeader, bool informEvenIfSeenBefore = false, bool writeSeenPawnsNames = true)
        {
            string text = default(string);

            PawnRelationUtility.Notify_PawnsSeenByPlayer(seenPawns, out text, informEvenIfSeenBefore, writeSeenPawnsNames);
            if (!text.NullOrEmpty())
            {
                if (letterLabel.NullOrEmpty())
                {
                    letterLabel = "LetterLabelNoticedRelatedPawns".Translate();
                }
                else
                {
                    letterLabel = letterLabel + " " + "RelationshipAppendedLetterSuffix".Translate();
                }
                if (!letterText.NullOrEmpty())
                {
                    letterText += "\n\n";
                }
                letterText = letterText + relationsInfoHeader + "\n\n" + text;
            }
        }
Exemple #19
0
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            Map map = (Map)parms.target;

            if (!TryFindEntryCell(map, out IntVec3 cell))
            {
                return(false);
            }
            if (!TryFindFormerFaction(out Faction formerFaction))
            {
                return(false);
            }
            Pawn pawn = PawnGenerator.GeneratePawn(PawnKindDefOf.WildMan, formerFaction);

            pawn.SetFaction(null);
            GenSpawn.Spawn(pawn, cell, map);
            TaggedString title = def.letterLabel.Formatted(pawn.LabelShort, pawn.Named("PAWN")).CapitalizeFirst();
            TaggedString text  = def.letterText.Formatted(pawn.NameShortColored, pawn.Named("PAWN")).AdjustedFor(pawn).CapitalizeFirst();

            PawnRelationUtility.TryAppendRelationsWithColonistsInfo(ref text, ref title, pawn);
            SendStandardLetter(title, text, def.letterDef, parms, pawn);
            return(true);
        }
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            Map          map    = (Map)parms.target;
            List <Thing> things = ThingSetMakerDefOf.RefugeePod.root.Generate();
            IntVec3      intVec = DropCellFinder.RandomDropSpot(map);
            Pawn         pawn   = FindPawn(things);

            pawn.guest.getRescuedThoughtOnUndownedBecauseOfPlayer = true;
            string title = "LetterLabelRefugeePodCrash".Translate();
            string str   = "RefugeePodCrash".Translate(pawn.Named("PAWN")).AdjustedFor(pawn);

            str += "\n\n";
            str  = ((pawn.Faction == null) ? (str + "RefugeePodCrash_Factionless".Translate(pawn.Named("PAWN")).AdjustedFor(pawn)) : ((!pawn.Faction.HostileTo(Faction.OfPlayer)) ? (str + "RefugeePodCrash_NonHostile".Translate(pawn.Named("PAWN")).AdjustedFor(pawn)) : (str + "RefugeePodCrash_Hostile".Translate(pawn.Named("PAWN")).AdjustedFor(pawn))));
            PawnRelationUtility.TryAppendRelationsWithColonistsInfo(ref str, ref title, pawn);
            Find.LetterStack.ReceiveLetter(title, str, LetterDefOf.NeutralEvent, new TargetInfo(intVec, map));
            ActiveDropPodInfo activeDropPodInfo = new ActiveDropPodInfo();

            activeDropPodInfo.innerContainer.TryAddRangeOrTransfer(things);
            activeDropPodInfo.openDelay = 180;
            activeDropPodInfo.leaveSlag = true;
            DropPodUtility.MakeDropPodAt(intVec, map, activeDropPodInfo);
            return(true);
        }
        private static float GetParentAgeFactor(Pawn parent, Pawn child, float minAgeToHaveChildren, float usualAgeToHaveChildren, float maxAgeToHaveChildren)
        {
            float num  = PawnRelationUtility.MaxPossibleBioAgeAt(parent.ageTracker.AgeBiologicalYearsFloat, parent.ageTracker.AgeChronologicalYearsFloat, child.ageTracker.AgeChronologicalYearsFloat);
            float num2 = PawnRelationUtility.MinPossibleBioAgeAt(parent.ageTracker.AgeBiologicalYearsFloat, child.ageTracker.AgeChronologicalYearsFloat);
            float result;

            if (num <= 0f)
            {
                result = 0f;
            }
            else if (num2 > num)
            {
                if (num2 > num + 0.1f)
                {
                    Log.Warning(string.Concat(new object[]
                    {
                        "Min possible bio age (",
                        num2,
                        ") is greater than max possible bio age (",
                        num,
                        ")."
                    }), false);
                }
                result = 0f;
            }
            else if (num2 <= usualAgeToHaveChildren && num >= usualAgeToHaveChildren)
            {
                result = 1f;
            }
            else
            {
                float ageFactor  = ChildRelationUtility.GetAgeFactor(num2, minAgeToHaveChildren, maxAgeToHaveChildren, usualAgeToHaveChildren);
                float ageFactor2 = ChildRelationUtility.GetAgeFactor(num, minAgeToHaveChildren, maxAgeToHaveChildren, usualAgeToHaveChildren);
                result = Mathf.Max(ageFactor, ageFactor2);
            }
            return(result);
        }
		private static float MinPossibleAgeGapAtMinAgeToGenerateAsLovers(Pawn p1, Pawn p2)
		{
			float num = p1.ageTracker.AgeChronologicalYearsFloat - 14f;
			if (num < 0f)
			{
				Log.Warning("at < 0");
				return 0f;
			}
			float num2 = PawnRelationUtility.MaxPossibleBioAgeAt(p2.ageTracker.AgeBiologicalYearsFloat, p2.ageTracker.AgeChronologicalYearsFloat, num);
			float num3 = PawnRelationUtility.MinPossibleBioAgeAt(p2.ageTracker.AgeBiologicalYearsFloat, num);
			if (num2 < 0f)
			{
				return -1f;
			}
			if (num2 < 14f)
			{
				return -1f;
			}
			if (num3 <= 14f)
			{
				return 0f;
			}
			return num3 - 14f;
		}
Exemple #23
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);
            }
        }
Exemple #24
0
        private bool DoExecute(IncidentParms parms, List <Pawn> generatedEnemies, IntVec3 existingMapEdgeCell)
        {
            Map  map  = parms.target as Map;
            bool flag = false;

            if (map == null)
            {
                map  = CaravanIncidentUtility.SetupCaravanAttackMap((Caravan)parms.target, generatedEnemies, sendLetterIfRelatedPawns: false);
                flag = true;
            }
            else
            {
                for (int i = 0; i < generatedEnemies.Count; i++)
                {
                    IntVec3 loc = CellFinder.RandomSpawnCellForPawnNear(existingMapEdgeCell, map);
                    GenSpawn.Spawn(generatedEnemies[i], loc, map, Rot4.Random);
                }
            }
            PostProcessGeneratedPawnsAfterSpawning(generatedEnemies);
            LordJob lordJob = CreateLordJob(generatedEnemies, parms);

            if (lordJob != null)
            {
                LordMaker.MakeNewLord(parms.faction, lordJob, map, generatedEnemies);
            }
            TaggedString letterLabel = GetLetterLabel(generatedEnemies[0], parms);
            TaggedString letterText  = GetLetterText(generatedEnemies[0], parms);

            PawnRelationUtility.Notify_PawnsSeenByPlayer_Letter(generatedEnemies, ref letterLabel, ref letterText, GetRelatedPawnsInfoLetterText(parms), informEvenIfSeenBefore: true);
            SendStandardLetter(letterLabel, letterText, GetLetterDef(generatedEnemies[0], parms), parms, generatedEnemies[0]);
            if (flag)
            {
                Find.TickManager.Notify_GeneratedPotentiallyHostileMap();
            }
            return(true);
        }
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            Map map = (Map)parms.target;

            if (!TryFindEntryCell(map, out IntVec3 cell))
            {
                return(false);
            }
            Gender?fixedGender = null;

            if (def.pawnFixedGender != 0)
            {
                fixedGender = def.pawnFixedGender;
            }
            Pawn pawn = PawnGenerator.GeneratePawn(new PawnGenerationRequest(def.pawnKind, Faction.OfPlayer, PawnGenerationContext.NonPlayer, -1, forceGenerateNewPawn: true, newborn: false, allowDead: false, allowDowned: false, canGeneratePawnRelations: true, def.pawnMustBeCapableOfViolence, 20f, forceAddFreeWarmLayerIfNeeded: false, allowGay: true, allowFood: true, allowAddictions: true, inhabitant: false, certainlyBeenInCryptosleep: false, forceRedressWorldPawnIfFormerColonist: false, worldPawnFactionDoesntMatter: false, 0f, null, 1f, null, null, null, null, null, null, null, fixedGender));

            GenSpawn.Spawn(pawn, cell, map);
            TaggedString text  = def.letterText.Formatted(pawn.Named("PAWN")).AdjustedFor(pawn);
            TaggedString title = def.letterLabel.Formatted(pawn.Named("PAWN")).AdjustedFor(pawn);

            PawnRelationUtility.TryAppendRelationsWithColonistsInfo(ref text, ref title, pawn);
            SendStandardLetter(title, text, LetterDefOf.PositiveEvent, parms, pawn);
            return(true);
        }
Exemple #26
0
        public static bool TryAppendRelationsWithColonistsInfo(ref string text, ref string title, Pawn pawn)
        {
            Pawn mostImportantColonyRelative = PawnRelationUtility.GetMostImportantColonyRelative(pawn);
            bool result;

            if (mostImportantColonyRelative == null)
            {
                result = false;
            }
            else
            {
                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");
                }
                result = true;
            }
            return(result);
        }
        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(mostImportantColonyRelative.LabelShort, genderSpecificLabel, mostImportantColonyRelative.Named("RELATIVE"), pawn.Named("PAWN")).AdjustedFor(pawn, "PAWN");
            }
            else
            {
                text = text + "\n\n" + "RelationshipAppendedLetterTextPrisoner".Translate(mostImportantColonyRelative.LabelShort, genderSpecificLabel, mostImportantColonyRelative.Named("RELATIVE"), pawn.Named("PAWN")).AdjustedFor(pawn, "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);
            }
        }
Exemple #29
0
        private bool DoExecute(IncidentParms parms, List <Pawn> generatedEnemies, IntVec3 existingMapEdgeCell)
        {
            Map  map  = parms.target as Map;
            bool flag = false;

            if (map == null)
            {
                map  = CaravanIncidentUtility.SetupCaravanAttackMap((Caravan)parms.target, generatedEnemies, false);
                flag = true;
            }
            else
            {
                for (int i = 0; i < generatedEnemies.Count; i++)
                {
                    IntVec3 loc = CellFinder.RandomSpawnCellForPawnNear(existingMapEdgeCell, map, 4);
                    GenSpawn.Spawn(generatedEnemies[i], loc, map, Rot4.Random, WipeMode.Vanish, false);
                }
            }
            this.PostProcessGeneratedPawnsAfterSpawning(generatedEnemies);
            LordJob lordJob = this.CreateLordJob(generatedEnemies, parms);

            if (lordJob != null)
            {
                LordMaker.MakeNewLord(parms.faction, lordJob, map, generatedEnemies);
            }
            string letterLabel = this.GetLetterLabel(generatedEnemies[0], parms);
            string letterText  = this.GetLetterText(generatedEnemies[0], parms);

            PawnRelationUtility.Notify_PawnsSeenByPlayer_Letter(generatedEnemies, ref letterLabel, ref letterText, this.GetRelatedPawnsInfoLetterText(parms), true, true);
            Find.LetterStack.ReceiveLetter(letterLabel, letterText, this.GetLetterDef(generatedEnemies[0], parms), generatedEnemies[0], parms.faction, null);
            if (flag)
            {
                Find.TickManager.Notify_GeneratedPotentiallyHostileMap();
            }
            return(true);
        }
Exemple #30
0
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            if (parms.target is Map)
            {
                return(IncidentDefOf.TravelerGroup.Worker.TryExecute(parms));
            }
            Caravan caravan = (Caravan)parms.target;
            Faction faction;

            if (!this.TryFindFaction(out faction))
            {
                return(false);
            }
            CameraJumper.TryJumpAndSelect(caravan);
            List <Pawn> pawns                = this.GenerateCaravanPawns(faction);
            Caravan     metCaravan           = CaravanMaker.MakeCaravan(pawns, faction, -1, false);
            string      text                 = "CaravanMeeting".Translate(caravan.Name, faction.Name, PawnUtility.PawnKindsToCommaList(metCaravan.PawnsListForReading, true)).CapitalizeFirst();
            DiaNode     diaNode              = new DiaNode(text);
            Pawn        bestPlayerNegotiator = BestCaravanPawnUtility.FindBestNegotiator(caravan);

            if (metCaravan.CanTradeNow)
            {
                DiaOption diaOption = new DiaOption("CaravanMeeting_Trade".Translate());
                diaOption.action = delegate
                {
                    Find.WindowStack.Add(new Dialog_Trade(bestPlayerNegotiator, metCaravan, false));
                    PawnRelationUtility.Notify_PawnsSeenByPlayer_Letter_Send(metCaravan.Goods.OfType <Pawn>(), "LetterRelatedPawnsTradingWithOtherCaravan".Translate(Faction.OfPlayer.def.pawnsPlural), LetterDefOf.NeutralEvent, false, true);
                };
                if (bestPlayerNegotiator == null)
                {
                    diaOption.Disable("CaravanMeeting_TradeIncapable".Translate());
                }
                diaNode.options.Add(diaOption);
            }
            DiaOption diaOption2 = new DiaOption("CaravanMeeting_Attack".Translate());

            diaOption2.action = delegate
            {
                LongEventHandler.QueueLongEvent(delegate
                {
                    Pawn t                   = caravan.PawnsListForReading[0];
                    Faction arg_49_0         = faction;
                    Faction ofPlayer         = Faction.OfPlayer;
                    FactionRelationKind kind = FactionRelationKind.Hostile;
                    string reason            = "GoodwillChangedReason_AttackedCaravan".Translate();
                    arg_49_0.TrySetRelationKind(ofPlayer, kind, true, reason, new GlobalTargetInfo?(t));
                    Map map = CaravanIncidentUtility.GetOrGenerateMapForIncident(caravan, new IntVec3(100, 1, 100), WorldObjectDefOf.AttackedNonPlayerCaravan);
                    IntVec3 playerSpot;
                    IntVec3 enemySpot;
                    MultipleCaravansCellFinder.FindStartingCellsFor2Groups(map, out playerSpot, out enemySpot);
                    CaravanEnterMapUtility.Enter(caravan, map, (Pawn p) => CellFinder.RandomClosewalkCellNear(playerSpot, map, 12, null), CaravanDropInventoryMode.DoNotDrop, true);
                    List <Pawn> list = metCaravan.PawnsListForReading.ToList <Pawn>();
                    CaravanEnterMapUtility.Enter(metCaravan, map, (Pawn p) => CellFinder.RandomClosewalkCellNear(enemySpot, map, 12, null), CaravanDropInventoryMode.DoNotDrop, false);
                    LordMaker.MakeNewLord(faction, new LordJob_DefendAttackedTraderCaravan(list[0].Position), map, list);
                    Find.TickManager.Notify_GeneratedPotentiallyHostileMap();
                    CameraJumper.TryJumpAndSelect(t);
                    PawnRelationUtility.Notify_PawnsSeenByPlayer_Letter_Send(list, "LetterRelatedPawnsGroupGeneric".Translate(Faction.OfPlayer.def.pawnsPlural), LetterDefOf.NeutralEvent, true, true);
                }, "GeneratingMapForNewEncounter", false, null);
            };
            diaOption2.resolveTree = true;
            diaNode.options.Add(diaOption2);
            DiaOption diaOption3 = new DiaOption("CaravanMeeting_MoveOn".Translate());

            diaOption3.action = delegate
            {
                this.RemoveAllPawnsAndPassToWorld(metCaravan);
            };
            diaOption3.resolveTree = true;
            diaNode.options.Add(diaOption3);
            string      text2              = "CaravanMeetingTitle".Translate(caravan.Label);
            WindowStack arg_1F1_0          = Find.WindowStack;
            DiaNode     nodeRoot           = diaNode;
            Faction     faction2           = faction;
            bool        delayInteractivity = true;
            string      title              = text2;

            arg_1F1_0.Add(new Dialog_NodeTreeWithFactionInfo(nodeRoot, faction2, delayInteractivity, false, title));
            Find.Archive.Add(new ArchivedDialog(diaNode.text, text2, faction));
            return(true);
        }