Exemplo n.º 1
0
        public void IssueDecree(bool causedByMentalBreak, string mentalBreakReason = null)
        {
            if (!ModLister.RoyaltyInstalled)
            {
                Log.ErrorOnce("Decrees are a Royalty-specific game system. If you want to use this code please check ModLister.RoyaltyInstalled before calling it. See rules on the Ludeon forum for more info.", 281653);
                return;
            }
            IIncidentTarget mapHeld = pawn.MapHeld;
            IIncidentTarget target  = mapHeld ?? Find.World;

            if (PossibleDecreeQuests.TryRandomElementByWeight((QuestScriptDef x) => NaturalRandomQuestChooser.GetNaturalDecreeSelectionWeight(x, target.StoryState), out QuestScriptDef result))
            {
                lastDecreeTicks = Find.TickManager.TicksGame;
                Slate slate = new Slate();
                slate.Set("points", StorytellerUtility.DefaultThreatPointsNow(target));
                slate.Set("asker", pawn);
                Quest quest = QuestUtility.GenerateQuestAndMakeAvailable(result, slate);
                target.StoryState.RecordDecreeFired(result);
                string str  = (!causedByMentalBreak) ? ((string)"LetterLabelRandomDecree".Translate(pawn)) : ((string)("WildDecree".Translate() + ": " + pawn.LabelShortCap));
                string text = (!causedByMentalBreak) ? ((string)"LetterRandomDecree".Translate(pawn)) : ((string)"LetterDecreeMentalBreak".Translate(pawn));
                if (mentalBreakReason != null)
                {
                    text = text + "\n\n" + mentalBreakReason;
                }
                text += "\n\n" + "LetterDecree_Quest".Translate(quest.name);
                ChoiceLetter let = LetterMaker.MakeLetter(str, text, IncidentDefOf.GiveQuest_Random.letterDef, LookTargets.Invalid, null, quest);
                Find.LetterStack.ReceiveLetter(let);
            }
        }
Exemplo n.º 2
0
        private void SendDrop()
        {
            Map map = Current.Game.CurrentMap;

            GenDate.DayOfYear(ticks, Find.WorldGrid.LongLatOf(map.Tile).x);
            List <Thing> thingList = new List <Thing>
            {
                ThingMaker.MakeThing(AvaliDefs.AvaliNexus)
            };

            Scribe_Values.Look(ref hasDropped, "hasDropped", false);
            Map            target      = map;
            List <Faction> newFactions = new List <Faction>();
            IntVec3        intVec3     = DropCellFinder.TradeDropSpot(target);

            if (map.IsPlayerHome)
            {
                hasDropped = true;
                foreach (Faction faction in Find.FactionManager.AllFactions.Where(x => x.def == AvaliDefs.AvaliFaction))
                {
                    faction.SetRelationDirect(Faction.OfPlayer, FactionRelationKind.Ally);
                    newFactions.Add(faction);
                }
                DropPodUtility.DropThingsNear(intVec3, target, (IEnumerable <Thing>)thingList);
                ChoiceLetter choiceLetter = LetterMaker.MakeLetter("IlluminateAirdrop".Translate(), "AirdropEventDesc".Translate(), AvaliMod.AvaliDefs.IlluminateAirdrop);
                Find.LetterStack.ReceiveLetter(choiceLetter, null);
            }
            else
            {
                SetupDrop();
            }
        }
Exemplo n.º 3
0
        protected override void RunInt()
        {
            Slate            slate            = QuestGen.slate;
            QuestPart_Letter questPart_Letter = new QuestPart_Letter();

            questPart_Letter.inSignal = (QuestGenUtility.HardcodedSignalWithQuestID(inSignal.GetValue(slate)) ?? slate.Get <string>("inSignal"));
            LetterDef letterDef = this.letterDef.GetValue(slate) ?? LetterDefOf.NeutralEvent;

            if (typeof(ChoiceLetter).IsAssignableFrom(letterDef.letterClass))
            {
                ChoiceLetter choiceLetter = LetterMaker.MakeLetter("error", "error", letterDef, QuestGenUtility.ToLookTargets(lookTargets, slate), relatedFaction.GetValue(slate), QuestGen.quest);
                questPart_Letter.letter = choiceLetter;
                QuestGen.AddTextRequest("root", delegate(string x)
                {
                    choiceLetter.label = x;
                }, QuestGenUtility.MergeRules(labelRules.GetValue(slate), label.GetValue(slate), "root"));
                QuestGen.AddTextRequest("root", delegate(string x)
                {
                    choiceLetter.text = x;
                }, QuestGenUtility.MergeRules(textRules.GetValue(slate), text.GetValue(slate), "root"));
            }
            else
            {
                questPart_Letter.letter                = LetterMaker.MakeLetter(letterDef);
                questPart_Letter.letter.lookTargets    = QuestGenUtility.ToLookTargets(lookTargets, slate);
                questPart_Letter.letter.relatedFaction = relatedFaction.GetValue(slate);
            }
            questPart_Letter.chosenPawnSignal               = QuestGenUtility.HardcodedSignalWithQuestID(chosenPawnSignal.GetValue(slate));
            questPart_Letter.useColonistsOnMap              = useColonistsOnMap.GetValue(slate);
            questPart_Letter.useColonistsFromCaravanArg     = useColonistsFromCaravanArg.GetValue(slate);
            questPart_Letter.signalListenMode               = (signalListenMode.GetValue(slate) ?? QuestPart.SignalListenMode.OngoingOnly);
            questPart_Letter.filterDeadPawnsFromLookTargets = filterDeadPawnsFromLookTargets.GetValue(slate);
            QuestGen.quest.AddPart(questPart_Letter);
        }
Exemplo n.º 4
0
        public Letter MakeQuestLetter(Quest quest, string label = null, string description = null, LetterDef letterDef = null, LookTargets lookTarget = null)
        {
            if (letterDef == null)
            {
                letterDef = LetterDefOf.NeutralEvent;
            }

            if (string.IsNullOrEmpty(label))
            {
                label = $"{"QuestPrefix".Translate()}: {quest.CardLabel}";
            }

            if (string.IsNullOrEmpty(description))
            {
                description = quest.Description;
            }

            Letter letter;

            if (lookTarget == null && quest.Target != null)
            {
                letter = LetterMaker.MakeLetter(label, description, letterDef, quest.Target);
            }
            else if (lookTarget != null)
            {
                letter = LetterMaker.MakeLetter(label, description, letterDef, lookTarget);
            }
            else
            {
                letter = LetterMaker.MakeLetter(label, description, letterDef);
            }

            return(letter);
        }
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            var map = (Map)parms.target;

            if (!GuestUtility.GetAllGuests(map).Where(IsHappyGuest).TryMaxBy(GetScore, out var happiestGuest))
            {
                return(false);
            }

            if (happiestGuest == null)
            {
                return(false);
            }

            var title  = "LetterLabelHappyGuestJoins".Translate(happiestGuest.Named("PAWN")).CapitalizeFirst();
            var letter = (ChoiceLetter_GuestJoinRequest)LetterMaker.MakeLetter(title, "HappyGuestJoins".Translate(happiestGuest.Faction.Name, happiestGuest.Named("PAWN")).AdjustedFor(happiestGuest), def.letterDef);

            letter.title          = title;
            letter.radioMode      = true;
            letter.guest          = happiestGuest;
            letter.lookTargets    = happiestGuest;
            letter.relatedFaction = happiestGuest.Faction;
            Find.LetterStack.ReceiveLetter(letter);
            return(true);
        }
Exemplo n.º 6
0
        private void SendDrop()
        {
            GenDate.DayOfYear(ticks, Find.WorldGrid.LongLatOf(map.Tile).x);
            List <Thing> thingList = new List <Thing>();

            thingList.Add(ThingMaker.MakeThing(AvaliDefs.AvaliNexus));
            Scribe_Values.Look(ref hasDropped, "hasDropped", false);
            Map            target      = map;
            List <Faction> newFactions = new List <Faction>();
            IntVec3        intVec3     = DropCellFinder.TradeDropSpot(target);

            if (RimValiUtility.PawnOfRaceCount(Faction.OfPlayer, AvaliDefs.RimVali) >= 5 && !hasDropped)
            {
                hasDropped = true;
                for (int a = 0; a < random.Next(2, 5); a++)
                {
                    Faction faction = FactionGenerator.NewGeneratedFaction(AvaliDefs.AvaliFaction);
                    faction.Name = "IlluminateFactionName".Translate() + ": #" + a.ToString();
                    faction.SetRelationDirect(Faction.OfPlayer, FactionRelationKind.Ally);
                    newFactions.Add(faction);
                }
                DropPodUtility.DropThingsNear(intVec3, target, (IEnumerable <Thing>)thingList);
                ChoiceLetter choiceLetter = LetterMaker.MakeLetter("IlluminateAirdrop".Translate(), "AirdropEventDesc".Translate(), AvaliMod.AvaliDefs.IlluminateAirdrop, newFactions[random.Next(newFactions.Count)]);
                Find.LetterStack.ReceiveLetter(choiceLetter, null);
            }
        }
Exemplo n.º 7
0
        public void SendRimWarLetter(TaggedString baseLetterLabel, TaggedString baseLetterText, LetterDef baseLetterDef, IncidentParms parms, LookTargets lookTargets, params NamedArgument[] textArgs)
        {
            if (baseLetterLabel.NullOrEmpty() || baseLetterText.NullOrEmpty())
            {
                Log.Error("Sending standard incident letter with no label or text.");
            }
            TaggedString taggedString = baseLetterText.Formatted(textArgs);
            TaggedString text;

            if (parms.customLetterText.NullOrEmpty())
            {
                text = taggedString;
            }
            else
            {
                List <NamedArgument> list = new List <NamedArgument>();
                if (textArgs != null)
                {
                    list.AddRange(textArgs);
                }
                list.Add(taggedString.Named("BASETEXT"));
                text = parms.customLetterText.Formatted(list.ToArray());
            }
            TaggedString taggedString2 = baseLetterLabel.Formatted(textArgs);
            TaggedString label;

            if (parms.customLetterLabel.NullOrEmpty())
            {
                label = taggedString2;
            }
            else
            {
                List <NamedArgument> list2 = new List <NamedArgument>();
                if (textArgs != null)
                {
                    list2.AddRange(textArgs);
                }
                list2.Add(taggedString2.Named("BASELABEL"));
                label = parms.customLetterLabel.Formatted(list2.ToArray());
            }
            ChoiceLetter choiceLetter = LetterMaker.MakeLetter(label, text, parms.customLetterDef ?? baseLetterDef, lookTargets, parms.faction, parms.quest, parms.letterHyperlinkThingDefs);

            //List<HediffDef> list3 = new List<HediffDef>();
            //if (!parms.letterHyperlinkHediffDefs.NullOrEmpty())
            //{
            //    list3.AddRange(parms.letterHyperlinkHediffDefs);
            //}
            //Log.Message("5");
            //if (!def.letterHyperlinkHediffDefs.NullOrEmpty())
            //{
            //    if (list3 == null)
            //    {
            //        list3 = new List<HediffDef>();
            //    }
            //    list3.AddRange(def.letterHyperlinkHediffDefs);
            //}
            //Log.Message("6");
            //choiceLetter.hyperlinkHediffDefs = list3;
            Find.LetterStack.ReceiveLetter(choiceLetter);
        }
Exemplo n.º 8
0
        public void AddCommunicationWithLetter(Communication comm, string letterTitle, string letterText = null
                                               , LetterDef letterDef  = null, bool lookAtComms = false, int ticksUntilDisabled = -1, bool removeWhenDisabled = true
                                               , bool persistWithComm = false)
        {
            comms.Add(new CommStruct(comm, ticksUntilDisabled, removeWhenDisabled));
            comm.SetManager(this);
            GlobalTargetInfo lookTarget = default(GlobalTargetInfo);

            if (lookAtComms && this.map.listerBuildings.AllBuildingsColonistOfClass <Building_CommsConsole>().Any())
            {
                this.map.listerBuildings.AllBuildingsColonistOfClass <Building_CommsConsole>().
                Select <Building_CommsConsole, GlobalTargetInfo>(cc => new GlobalTargetInfo(cc)).TryRandomElement(out lookTarget);
            }
            letterDef = ConvertLetterDefToNotification(letterDef ?? LetterDefOf.NeutralEvent);
            NotificationLetter letter = (NotificationLetter)LetterMaker.MakeLetter(letterTitle, letterText ?? letterTitle, letterDef, lookTarget);

            letter.communication   = comm;
            letter.persistWithComm = persistWithComm;
            comm.SetNotificationLetter(letter);
            if (ticksUntilDisabled != -1)
            {
                letter.StartTimeout(ticksUntilDisabled);
            }
            Find.LetterStack.ReceiveLetter(letter);
        }
Exemplo n.º 9
0
        public static void SendLetterQuestAvailable(Quest quest)
        {
            TaggedString label = IncidentDefOf.GiveQuest_Random.letterLabel + ": " + quest.name;
            TaggedString text;

            if (quest.initiallyAccepted)
            {
                label = "LetterQuestAutomaticallyAcceptedTitle".Translate(quest.name);
                text  = "LetterQuestBecameActive".Translate(quest.name);
                int questTicksRemaining = GetQuestTicksRemaining(quest);
                if (questTicksRemaining > 0)
                {
                    text += " " + "LetterQuestActiveNowTime".Translate(questTicksRemaining.ToStringTicksToPeriod(allowSeconds: false, shortForm: false, canUseDecimals: false));
                }
            }
            else
            {
                text = "LetterQuestBecameAvailable".Translate(quest.name);
                if (quest.ticksUntilAcceptanceExpiry >= 0)
                {
                    text += "\n\n" + "LetterQuestRequiresAcceptance".Translate(quest.ticksUntilAcceptanceExpiry.ToStringTicksToPeriod(allowSeconds: false, shortForm: false, canUseDecimals: false));
                }
            }
            ChoiceLetter choiceLetter = LetterMaker.MakeLetter(label, text, (quest.root != null && quest.root.questAvailableLetterDef != null) ? quest.root.questAvailableLetterDef : IncidentDefOf.GiveQuest_Random.letterDef, LookTargets.Invalid, null, quest);

            choiceLetter.title = quest.name;
            Find.LetterStack.ReceiveLetter(choiceLetter);
        }
Exemplo n.º 10
0
 public static void AddAnxiety(MentalBreaker __instance, ref bool __result)
 {
     if (__result)
     {
         Pawn pawn = Traverse.Create(__instance).Field("pawn").GetValue <Pawn>();
         int  intensity;
         int.TryParse("" + (byte)Traverse.Create(__instance).Property("CurrentDesiredMoodBreakIntensity").GetValue <MentalBreakIntensity>(), out intensity);
         Hediff hediff     = pawn.health.hediffSet.GetFirstHediffOfDef(HediffDefOfPsychology.Anxiety);
         float  PTSDChance = (0.25f - (0.075f * intensity));
         if (pawn.story.traits.HasTrait(TraitDefOfPsychology.Desensitized))
         {
             PTSDChance *= 0.75f;
         }
         if (PsycheHelper.PsychologyEnabled(pawn))
         {
             //Laid-back pawns are less likely to get anxiety from mental breaks.
             PTSDChance -= pawn.GetComp <CompPsychology>().Psyche.GetPersonalityRating(PersonalityNodeDefOf.LaidBack) / 10f;
         }
         if (hediff != null)
         {
             hediff.Severity += 0.15f - (intensity * 0.5f);
         }
         else if (Rand.Chance(PTSDChance))
         {
             Hediff newHediff = HediffMaker.MakeHediff(HediffDefOfPsychology.Anxiety, pawn, pawn.health.hediffSet.GetBrain());
             newHediff.Severity = 0.75f - (intensity * 0.25f);
             Letter newAnxiety = LetterMaker.MakeLetter("LetterLabelPTSD".Translate(), "LetterPTSD".Translate().AdjustedFor(pawn), LetterDefOf.NegativeEvent, pawn);
             Find.LetterStack.ReceiveLetter(newAnxiety);
             pawn.health.AddHediff(newHediff, null, null);
         }
     }
 }
Exemplo n.º 11
0
        public void DisarmBomb()
        {
            RemoveAfterLeave = true;

            var letter = LetterMaker.MakeLetter(Translator.Translate("SuccessDisarming"), Translator.Translate("SuccessDisarmingDesc"), LetterDefOf.PositiveEvent);

            Find.LetterStack.ReceiveLetter(letter);
        }
Exemplo n.º 12
0
 public static Letter NewLetter(IncidentParms parms, IDelayHolder delay, IncidentDef incidentDef = null)
 {
     if (incidentDef == null || parms.points > -1f)
     {
         return(LetterMaker.MakeLetter(LetterLabel.Translate(), GetLetterText(delay, parms, incidentDef), LetterDefOf.ThreatBig, new TargetInfo(parms.spawnCenter, (Map)parms.target)));
     }
     return(LetterMaker.MakeLetter(LetterLabel.Translate(), GetLetterText(delay, parms, incidentDef), LetterDefOf.NeutralEvent, new TargetInfo(parms.spawnCenter, (Map)parms.target)));
 }
Exemplo n.º 13
0
        private static void CreateLetter(Map map, string signalTag, CellRect notificationArea)
        {
            var signalAction_Letter = (SignalAction_Letter)ThingMaker.MakeThing(ThingDefOf.SignalAction_Letter);

            signalAction_Letter.signalTag = signalTag;
            signalAction_Letter.letter    = LetterMaker.MakeLetter("THU_LetterLabel_ShipPart".Translate(),
                                                                   "THU_LetterText_ShipPart".Translate(), LetterDefOf.NeutralEvent, new TargetInfo(notificationArea.CenterCell, map));
            GenSpawn.Spawn(signalAction_Letter, notificationArea.CenterCell, map);
        }
Exemplo n.º 14
0
        public static void DoMessage(Pawn pawn)
        {
            Letter letter = LetterMaker.MakeLetter("AIPawn_LetterLabel_BuildRechargeStationSoon".Translate(),
                                                   "AIPawn_LetterText_BuildRechargeStationSoon".Translate().AdjustedFor(pawn),
                                                   LetterDefOf.PositiveEvent,
                                                   pawn);

            Find.LetterStack.ReceiveLetter(letter);
        }
Exemplo n.º 15
0
        protected override void ScatterAt(IntVec3 loc, Map map, int stackCount = 1)
        {
            int      randomInRange             = GenStep_ScatterShrines.ShrinesCountX.RandomInRange;
            int      randomInRange2            = GenStep_ScatterShrines.ShrinesCountZ.RandomInRange;
            int      randomInRange3            = GenStep_ScatterShrines.ExtraHeightRange.RandomInRange;
            IntVec2  standardAncientShrineSize = SymbolResolver_AncientShrinesGroup.StandardAncientShrineSize;
            int      num  = 1;
            int      num2 = randomInRange * standardAncientShrineSize.x + (randomInRange - 1) * num;
            int      num3 = randomInRange2 * standardAncientShrineSize.z + (randomInRange2 - 1) * num;
            int      num4 = num2 + 2;
            int      num5 = num3 + 2 + randomInRange3;
            CellRect rect = new CellRect(loc.x, loc.z, num4, num5);

            rect.ClipInsideMap(map);
            if (rect.Width != num4 || rect.Height != num5)
            {
                return;
            }
            foreach (IntVec3 current in rect.Cells)
            {
                List <Thing> list = map.thingGrid.ThingsListAt(current);
                for (int i = 0; i < list.Count; i++)
                {
                    if (list[i].def == ThingDefOf.AncientCryptosleepCasket)
                    {
                        return;
                    }
                }
            }
            if (!base.CanPlaceAncientBuildingInRange(rect, map))
            {
                return;
            }
            ResolveParams resolveParams = default(ResolveParams);

            resolveParams.rect = rect;
            resolveParams.disableSinglePawn           = new bool?(true);
            resolveParams.disableHives                = new bool?(true);
            resolveParams.ancientTempleEntranceHeight = new int?(randomInRange3);
            BaseGen.globalSettings.map                = map;
            BaseGen.symbolStack.Push("ancientTemple", resolveParams);
            BaseGen.Generate();
            int    nextSignalTagID = Find.UniqueIDsManager.GetNextSignalTagID();
            string signalTag       = "ancientTempleApproached-" + nextSignalTagID;
            SignalAction_Letter signalAction_Letter = (SignalAction_Letter)ThingMaker.MakeThing(ThingDefOf.SignalAction_Letter, null);

            signalAction_Letter.signalTag = signalTag;
            signalAction_Letter.letter    = LetterMaker.MakeLetter("LetterLabelAncientShrineWarning".Translate(), "AncientShrineWarning".Translate(), LetterDefOf.NeutralEvent, new TargetInfo(rect.CenterCell, map, false));
            GenSpawn.Spawn(signalAction_Letter, rect.CenterCell, map);
            RectTrigger rectTrigger = (RectTrigger)ThingMaker.MakeThing(ThingDefOf.RectTrigger, null);

            rectTrigger.signalTag         = signalTag;
            rectTrigger.Rect              = rect.ExpandedBy(1).ClipInsideMap(map);
            rectTrigger.destroyIfUnfogged = true;
            GenSpawn.Spawn(rectTrigger, rect.CenterCell, map);
        }
Exemplo n.º 16
0
        public static void Make(string label, string text, LetterDef def)
        {
            var lclass = def.letterClass;

            def.letterClass = typeof(OpenUILetter);
            ChoiceLetter Letter = LetterMaker.MakeLetter(label, text, def);

            def.letterClass = lclass;
            Find.LetterStack.ReceiveLetter(Letter);
        }
        private void DoEnter(Caravan caravan, Site site)
        {
            LookTargets lookTargets    = new LookTargets(caravan.PawnsListForReading);
            bool        draftColonists = site.Faction == null || site.Faction.HostileTo(Faction.OfPlayer);
            bool        num            = !site.HasMap;
            Map         orGenerateMap  = GetOrGenerateMapUtility.GetOrGenerateMap(site.Tile, MapSize, null);

            if (num)
            {
                Find.TickManager.Notify_GeneratedPotentiallyHostileMap();
                PawnRelationUtility.Notify_PawnsSeenByPlayer_Letter_Send(orGenerateMap.mapPawns.AllPawns, "LetterRelatedPawnsSite".Translate(Faction.OfPlayer.def.pawnsPlural), LetterDefOf.NeutralEvent, informEvenIfSeenBefore: true);
                StringBuilder stringBuilder = new StringBuilder();
                stringBuilder.Append("LetterCaravanEnteredMap".Translate(caravan.Label, site).CapitalizeFirst());
                AppendThreatInfo(stringBuilder, site, orGenerateMap, out var letterDef, out var allLookTargets);
                TaggedString letterText = null;
                SettlementUtility.AffectRelationsOnAttacked_NewTmp(site, ref letterText);
                if (!letterText.NullOrEmpty())
                {
                    if (stringBuilder.Length > 0)
                    {
                        stringBuilder.AppendLine();
                    }
                    stringBuilder.AppendLineTagged(letterText);
                }
                List <HediffDef> list = null;
                foreach (SitePart part in site.parts)
                {
                    if (part.def.arrivedLetterHediffHyperlinks.NullOrEmpty())
                    {
                        continue;
                    }
                    if (list == null)
                    {
                        list = new List <HediffDef>();
                    }
                    foreach (HediffDef arrivedLetterHediffHyperlink in part.def.arrivedLetterHediffHyperlinks)
                    {
                        if (!list.Contains(arrivedLetterHediffHyperlink))
                        {
                            list.Add(arrivedLetterHediffHyperlink);
                        }
                    }
                }
                ChoiceLetter choiceLetter = LetterMaker.MakeLetter("LetterLabelCaravanEnteredMap".Translate(site), stringBuilder.ToString(), letterDef ?? LetterDefOf.NeutralEvent, allLookTargets.IsValid() ? allLookTargets : lookTargets);
                choiceLetter.hyperlinkHediffDefs = list;
                Find.LetterStack.ReceiveLetter(choiceLetter);
            }
            else
            {
                Find.LetterStack.ReceiveLetter("LetterLabelCaravanEnteredMap".Translate(site), "LetterCaravanEnteredMap".Translate(caravan.Label, site).CapitalizeFirst(), LetterDefOf.NeutralEvent, lookTargets);
            }
            CaravanEnterMapUtility.Enter(caravan, orGenerateMap, CaravanEnterMode.Edge, CaravanDropInventoryMode.DoNotDrop, draftColonists);
        }
        public void FinishBoring()
        {
            //Spawn bore hole.
            Thing boreHole = ThingMaker.MakeThing(BetharianDefOf.BetharianBoreHole);

            GenSpawn.Spawn(boreHole, Position, Map);

            //Send letter.
            Letter letter = LetterMaker.MakeLetter("BetharianBorerFinishedLabel".Translate(), "BetharianBorerFinishedText".Translate(), LetterDefOf.PositiveEvent, new TargetInfo(this));

            Find.LetterStack.ReceiveLetter(letter);
        }
Exemplo n.º 19
0
        public void UpdateCamp()
        {
            var letter = LetterMaker.MakeLetter("YourAttackWasRepelledTitle".Translate(), "YourAttackWasRepelledDesc".Translate(), LetterDefOf.NeutralEvent);

            Find.LetterStack.ReceiveLetter(letter);

            if (Rand.Chance(0.25f))
            {
                RerollMaps();
            }

            Current.Game.DeinitAndRemoveMap(camp.Map);
        }
        private static void SendLetter(IncidentParms parms, List <Pawn> pawns)
        {
            StringBuilder str = new StringBuilder();

            foreach (var t in pawns)
            {
                str.AppendLine(t.NameShortColored);
            }

            TaggedString text         = "RF.Raiders.WarningContent".Translate(parms.faction.NameColored, pawns.Count, parms.faction.def.pawnsPlural, str);
            ChoiceLetter choiceLetter = LetterMaker.MakeLetter("RF.Raiders.WarningTitle".Translate(), text, RFDefOf.RF_CursedRaiders, pawns, parms.faction);

            Find.LetterStack.ReceiveLetter(choiceLetter);
        }
        private void Debug_Info()
        {
            StringBuilder s1 = new StringBuilder(); // Skills

            foreach (X2_ThingDef_AIRobot.RobotSkills skill in def2.robotSkills)
            {
                s1.AppendWithComma(skill.skillDef.skillLabel.ToString() + " (" + skill.level.ToString() + ")");
            }
            if (s1.ToString() == "")
            {
                s1.Append("---");
            }

            StringBuilder s2 = new StringBuilder();                       // WorkTypes

            foreach (WorkTypeDef w in DefDatabase <WorkTypeDef> .AllDefs) //  this.workSettings...WorkGiversInOrderNormal)
            {
                if (this.workSettings.GetPriority(w) == 0)
                {
                    continue;
                }

                s2.AppendWithComma(w.labelShort + " (" + this.workSettings.GetPriority(w) + ")");
            }
            if (s2.ToString() == "")
            {
                s2.Append("---");
            }

            StringBuilder s3 = new StringBuilder();            // WorkGivers

            foreach (WorkGiver w in this.GetWorkGivers(false)) //  this.workSettings...WorkGiversInOrderNormal)
            {
                s3.AppendWithComma(w.def.label);
            }
            if (s3.ToString() == "")
            {
                s3.Append("---");
            }

            Letter letter = LetterMaker.MakeLetter("Robot-Info " + this.NameShortColored,
                                                   "Robot: " + this.NameShortColored + Environment.NewLine + Environment.NewLine +
                                                   "Roboterskills: " + s1.ToString() + Environment.NewLine + Environment.NewLine +
                                                   "WorkTypes: " + s2.ToString() + Environment.NewLine + Environment.NewLine +
                                                   "WorkGivers: " + s3.ToString(),
                                                   LetterDefOf.NeutralEvent,
                                                   this);

            Find.LetterStack.ReceiveLetter(letter);
        }
Exemplo n.º 22
0
 private void SendLetter()
 {
     if (!letterSent)
     {
         letter       = (ChoiceLetter_AcceptVisitors)LetterMaker.MakeLetter(letterLabel, letterText, LetterDefOf.AcceptVisitors, null, quest);
         letter.title = letterTitle;
         letter.pawns.Add(pawn);
         letter.quest          = quest;
         letter.acceptedSignal = outSignalPawnAccepted;
         letter.lookTargets    = new LookTargets(pawn);
         Find.LetterStack.ReceiveLetter(letter);
         letterSent = true;
     }
 }
Exemplo n.º 23
0
        public static void Make(string label, string text, LetterDef def, TravelingIncidentCaravan caravan)
        {
            var lclass = def.letterClass;

            def.letterClass = typeof(SparkUILetter);
            ChoiceLetter Letter = LetterMaker.MakeLetter(label, text, def);

            def.letterClass = lclass;
            if (Letter is SparkUILetter sLetter)
            {
                sLetter.caravan = caravan;
            }
            Find.LetterStack.ReceiveLetter(Letter);
        }
Exemplo n.º 24
0
        public static ChoiceLetter MakeLetter(string labelKeyword, string textKeyword, LetterDef def, LookTargets lookTargets, Faction relatedFaction = null, Quest quest = null)
        {
            ChoiceLetter letter = LetterMaker.MakeLetter("error", "error", def, lookTargets, relatedFaction, quest);

            QuestGen.AddTextRequest(labelKeyword, delegate(string x)
            {
                letter.label = x;
            });
            QuestGen.AddTextRequest(textKeyword, delegate(string x)
            {
                letter.text = x;
            });
            return(letter);
        }
Exemplo n.º 25
0
        protected virtual void SendCrashSiteLetter(WorldObject shotDownBy, MapParent crashSite, TaggedString baseLetterLabel, TaggedString baseLetterText, LetterDef letterDef, LookTargets lookTargets, params NamedArgument[] textArgs)
        {
            if (baseLetterLabel.NullOrEmpty() || baseLetterText.NullOrEmpty())
            {
                Log.Error("Sending standard incident letter with no label or text.");
            }
            ChoiceLetter     choiceLetter = LetterMaker.MakeLetter(baseLetterLabel.Formatted(textArgs), baseLetterText.Formatted(textArgs), letterDef, lookTargets, shotDownBy?.Faction);
            List <HediffDef> list3        = new List <HediffDef>();

            if (!def.letterHyperlinkHediffDefs.NullOrEmpty())
            {
                list3.AddRange(def.letterHyperlinkHediffDefs);
            }
            choiceLetter.hyperlinkHediffDefs = list3;
            Find.LetterStack.ReceiveLetter(choiceLetter, null);
        }
Exemplo n.º 26
0
        public override bool ShouldRemoveMapNow(out bool alsoRemoveWorldObject)
        {
            if (!base.Map.mapPawns.AnyPawnBlockingMapRemoval)
            {
                if (Weapon != null && !Weapon.WeaponDeactivated)
                {
                    var letter = LetterMaker.MakeLetter("YourAttackWasRepelledTitle".Translate(), "YourAttackWasRepelledDesc".Translate(), LetterDefOf.NeutralEvent);
                    Find.LetterStack.ReceiveLetter(letter);
                }

                alsoRemoveWorldObject = false;
                return(true);
            }

            alsoRemoveWorldObject = false;
            return(false);
        }
Exemplo n.º 27
0
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            var map = (Map)parms.target;

            if (!RandomNearbyHostileWorldObject(map.Tile, out worldObject, out faction))
            {
                return(false);
            }

            var extorsionDemand = Math.Max(Rand.Range(150, 300), (int)parms.points) *
                                  NearbyHostileEncampments(map.Tile).Count();

            var representative = faction.leader ?? (worldObject is Settlement baese
                ? baese.previouslyGeneratedInhabitants.FirstOrDefault()
                : null);

            var choiceLetterExtortionDemand = (ChoiceLetter_ExtortionDemand)LetterMaker.MakeLetter(def.letterLabel,
                                                                                                   "MFI_ExtortionDemand".Translate(
                                                                                                       representative?.LabelShort ?? "MFI_Representative".Translate(),
                                                                                                       faction.def.leaderTitle,
                                                                                                       faction.Name,
                                                                                                       worldObject.def.label,
                                                                                                       worldObject.Label,
                                                                                                       extorsionDemand
                                                                                                       ).AdjustedFor(faction.leader ??
                                                                                                                     Find.WorldPawns.AllPawnsAlive.Where(x => x.Faction == faction).RandomElement()),
                                                                                                   def.letterDef);

            choiceLetterExtortionDemand.title =
                "MFI_ExtortionDemandTitle".Translate(map.info.parent.Label).CapitalizeFirst();

            if (worldObject is Site)
            {
                choiceLetterExtortionDemand.outpost = true;
            }

            choiceLetterExtortionDemand.radioMode = true;
            choiceLetterExtortionDemand.faction   = faction;
            choiceLetterExtortionDemand.map       = map;
            choiceLetterExtortionDemand.fee       = extorsionDemand;
            choiceLetterExtortionDemand.StartTimeout(TimeoutTicks);
            Find.LetterStack.ReceiveLetter(choiceLetterExtortionDemand);
            Find.World.GetComponent <WorldComponent_OutpostGrower>().Registerletter(choiceLetterExtortionDemand);
            return(true);
        }
Exemplo n.º 28
0
        private bool ConsoleMode(IncidentParms parms)
        {
            Map map = (Map)parms.target;

            //  PawnKindDef spaceRefugee = PawnKindDefOf.SpaceRefugee;
            //  Pawn pawn = PawnGenerator.GeneratePawn(spaceRefugee);

            Pawn offerPawn = PawnGenerator.GeneratePawn(PawnKindDefOf.Colonist);

            int timeOut = 2 * 60000;

            Settlement settlement = Find.WorldObjects.Settlements.Where(s => s.Faction == parms.faction).RandomElement();
            string     text       = "PawnInfo".Translate().Formatted(offerPawn.Named("PAWN")).AdjustedFor(offerPawn);
            string     dialogDesc = string.Format(def.letterText, settlement.Name, parms.faction.Name, offerPawn.Name.ToStringFull, text, "TimerInfo".Translate(timeOut.TicksToDays().ToString("f2")));

            EmailMessage message = QuestsManager.Communications.PlayerBox.FormMessageFrom(parms.faction,
                                                                                          dialogDesc, def.letterLabel);

            message.Answers = new List <EmailMessageOption>();
            EmailOption_PawnOfferYes emailOption_PawnOfferYes = new EmailOption_PawnOfferYes(offerPawn);

            Letter letter = LetterMaker.MakeLetter("CommunicationDialog_PocahontasTitle".Translate(), "CommunicationDialog_Pocahontas".Translate(parms.faction.Name), LetterDefOf.NegativeEvent);

            TimeComp timeComp = new TimeComp(message.Subject, Faction.OfPlayer, timeOut);

            timeComp.id        = QuestsManager.Communications.UniqueIdManager.GetNextComponentID();
            timeComp.Action    = new CommOption_ChangeGoodWill(-20);
            timeComp.EndLetter = letter;
            timeComp.Speaker   = map.mapPawns.FreeColonists.RandomElement();
            timeComp.Defendant = parms.faction.leader;

            EmailOption_ChangeGoodWill emailOption_ChangeGoodWill = new EmailOption_ChangeGoodWill(-20);
            EmailOption_DeclineDialog  emailOption_DeclineDialog  = new EmailOption_DeclineDialog(emailOption_ChangeGoodWill);

            message.Answers.Add(emailOption_PawnOfferYes);
            message.Answers.Add(emailOption_DeclineDialog);

            QuestsManager.Communications.PlayerBox.SendMessage(message);

            QuestsManager.Communications.RegisterComponent(timeComp);

            return(true);
        }
        public override void Interacted(Pawn initiator, Pawn recipient, List <RulePackDef> extraSentencePacks, out string letterText, out string letterLabel, out LetterDef letterDef)
        {
            letterText  = null;
            letterLabel = null;
            letterDef   = null;
            //Choose a time that works with their schedule, based on their personality
            Dictionary <int, float> possibleHours = new Dictionary <int, float>();

            for (int i = 0; i < GenDate.HoursPerDay; i++)
            {
                possibleHours.Add(i, 0f);
            }
            foreach (PersonalityNodeDef d in DefDatabase <PersonalityNodeDef> .AllDefsListForReading)
            {
                if (d.preferredDateHours != null)
                {
                    foreach (int h in d.preferredDateHours)
                    {
                        possibleHours[h] += (Mathf.Pow(Mathf.Abs(0.5f - PsycheHelper.Comp(initiator).Psyche.GetPersonalityRating(d)), 2) / (1.3f - PsycheHelper.Comp(initiator).Psyche.GetPersonalityRating(PersonalityNodeDefOf.Aggressive)) + Mathf.Pow(Mathf.Abs(0.5f - PsycheHelper.Comp(recipient).Psyche.GetPersonalityRating(d)), 2) / (1.3f - PsycheHelper.Comp(recipient).Psyche.GetPersonalityRating(PersonalityNodeDefOf.Aggressive)) / 2f);
                    }
                }
            }
            int hour = possibleHours.Keys.RandomElementByWeight(h => possibleHours[h] * RendezvousUtility.TimeAssignmentFactor(initiator, h) * RendezvousUtility.TimeAssignmentFactor(recipient, h));
            //More Spontaneous couples will plan their dates sooner; possibly even immediately!
            int day = Find.TickManager.TicksAbs + Mathf.RoundToInt(GenDate.TicksPerDay * 5 * (((1f - PsycheHelper.Comp(initiator).Psyche.GetPersonalityRating(PersonalityNodeDefOf.Spontaneous)) + (1f - PsycheHelper.Comp(recipient).Psyche.GetPersonalityRating(PersonalityNodeDefOf.Spontaneous))) / 2f));
            Hediff_PlannedDate plannedDate = HediffMaker.MakeHediff(HediffDefOfPsychology.PlannedDate, initiator) as Hediff_PlannedDate;

            plannedDate.partner = recipient;
            plannedDate.day     = day;
            plannedDate.hour    = hour;
            initiator.health.AddHediff(plannedDate);
            PsycheHelper.Comp(initiator).Psyche.lastDateTick = day;
            PsycheHelper.Comp(recipient).Psyche.lastDateTick = day;
            if (PsychologyBase.SendDateLetters())
            {
                int    hourDiscrepancy = GenDate.HourOfDay(day, Find.WorldGrid.LongLatOf(initiator.Map.Tile).x) - hour;
                int    accurateTime    = day + (Math.Abs(hourDiscrepancy) * GenDate.TicksPerHour);
                String dateTime        = GenDate.QuadrumDateStringAt(accurateTime, Find.WorldGrid.LongLatOf(initiator.Map.Tile).x);
                Letter dateLetter      = LetterMaker.MakeLetter("LetterLabelDatePlanned".Translate(), "LetterDatePlanned".Translate(initiator, recipient, dateTime, hour), LetterDefOf.PositiveEvent);
                Find.LetterStack.ReceiveLetter(dateLetter);
            }
        }
Exemplo n.º 30
0
        public static void Postfix(ResearchManager __instance, bool __state)
        {
            if (!__state && BlindResearch.CanSeeProgress(__instance.currentProj?.ProgressPercent ?? 0))
            {
                RemoveLetter();

                int msg = msgNum++;
                if (msgNum == msgCount)
                {
                    msgNum = 0;
                }
                string letter = "TD.ResearchKnown".Translate(__instance.currentProj.LabelCap);
                string text   = $"TD.ResearchKnownMsg{msg}".Translate(__instance.currentProj.LabelCap) +
                                "\n\n" + "TD.ResearchKnownDesc".Translate() +
                                "\n\n" + __instance.currentProj.LabelCap + ": " + __instance.currentProj.description;

                lastLetter = LetterMaker.MakeLetter(letter, text, LetterDefOf.NeutralEvent);
                Find.LetterStack.ReceiveLetter(lastLetter);
            }
        }