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); }
public static TaggedString CheckForViolations(Pawn pawn, HediffDef hediff, int levelOffset) { if (levelOffset < 0) { return(""); } if (pawn.Faction != Faction.OfPlayer || !hediff.HasComp(typeof(HediffComp_RoyalImplant))) { return(""); } Hediff_ImplantWithLevel hediff_ImplantWithLevel = (Hediff_ImplantWithLevel)pawn.health.hediffSet.hediffs.FirstOrDefault((Hediff h) => h.def == hediff); int num = (levelOffset != 0 && hediff_ImplantWithLevel != null) ? (hediff_ImplantWithLevel.level + levelOffset) : 0; foreach (Faction item in Find.FactionManager.AllFactionsListForReading) { if (pawn.Faction != null && !item.def.hidden && !item.HostileTo(Faction.OfPlayer) && ThingRequiringRoyalPermissionUtility.IsViolatingRulesOf(hediff, pawn, item, num)) { RoyalTitleDef minTitleForImplant = item.GetMinTitleForImplant(hediff, num); HediffCompProperties_RoyalImplant hediffCompProperties_RoyalImplant = hediff.CompProps <HediffCompProperties_RoyalImplant>(); string arg = hediff.label + ((num == 0) ? "" : (" (" + num + "x)")); TaggedString taggedString = hediffCompProperties_RoyalImplant.violationTriggerDescriptionKey.Translate(pawn.Named("PAWN")); TaggedString t = "RoyalImplantIllegalUseWarning".Translate(pawn.Named("PAWN"), arg.Named("IMPLANT"), item.Named("FACTION"), minTitleForImplant.GetLabelCapFor(pawn).Named("TITLE"), taggedString.Named("VIOLATIONTRIGGER")); if (levelOffset != 0) { return(t + ("\n\n" + "RoyalImplantUpgradeConfirmation".Translate())); } return(t + ("\n\n" + "RoyalImplantInstallConfirmation".Translate())); } } return(""); }