public override string PostProcessLabel(Pawn p, string label)
        {
            RoyalTitleDef royalTitleDef = Validate(p);

            if (royalTitleDef == null)
            {
                return(string.Empty);
            }
            return(label.Formatted(royalTitleDef.GetLabelCapFor(p).Named("TITLE"), p.Named("PAWN")));
        }
        public override string PostProcessDescription(Pawn p, string description)
        {
            QualityCategory minQuality;
            RoyalTitleDef   royalTitleDef = Validate(p, out minQuality);

            if (royalTitleDef == null)
            {
                return(string.Empty);
            }
            return(description.Formatted(royalTitleDef.GetLabelCapFor(p).Named("TITLE"), minQuality.GetLabel().Named("QUALITY"), p.Named("PAWN")));
        }
        public void FinishCeremony(Pawn pawn)
        {
            lord.ReceiveMemo("CeremonyFinished");
            RoyalTitleDef currentTitle             = target.royalty.GetCurrentTitle(bestower.Faction);
            RoyalTitleDef titleAwardedWhenUpdating = target.royalty.GetTitleAwardedWhenUpdating(bestower.Faction, target.royalty.GetFavor(bestower.Faction));

            Pawn_RoyaltyTracker.MakeLetterTextForTitleChange(target, bestower.Faction, currentTitle, titleAwardedWhenUpdating, out var headline, out var body);
            if (pawn.royalty != null)
            {
                pawn.royalty.TryUpdateTitle_NewTemp(bestower.Faction, sendLetter: false, titleAwardedWhenUpdating);
            }
            Hediff_Psylink     mainPsylinkSource  = target.GetMainPsylinkSource();
            List <AbilityDef>  abilitiesPreUpdate = ((mainPsylinkSource == null) ? new List <AbilityDef>() : pawn.abilities.abilities.Select((Ability a) => a.def).ToList());
            ThingOwner <Thing> innerContainer     = bestower.inventory.innerContainer;

            for (int i = pawn.GetPsylinkLevel(); i < pawn.GetMaxPsylinkLevelByTitle(); i++)
            {
                for (int num = innerContainer.Count - 1; num >= 0; num--)
                {
                    if (innerContainer[num].def == ThingDefOf.PsychicAmplifier)
                    {
                        Thing thing = innerContainer[num];
                        innerContainer.RemoveAt(num);
                        thing.Destroy();
                        break;
                    }
                }
                pawn.ChangePsylinkLevel(1, sendLetter: false);
            }
            mainPsylinkSource = target.GetMainPsylinkSource();
            List <AbilityDef> newAbilities = ((mainPsylinkSource == null) ? new List <AbilityDef>() : (from a in pawn.abilities.abilities
                                                                                                       select a.def into def
                                                                                                       where !abilitiesPreUpdate.Contains(def)
                                                                                                       select def).ToList());
            string str = headline;

            str = str + "\n\n" + Hediff_Psylink.MakeLetterTextNewPsylinkLevel(target, pawn.GetPsylinkLevel(), newAbilities);
            str = str + "\n\n" + body;
            Find.LetterStack.ReceiveLetter("LetterLabelGainedRoyalTitle".Translate(titleAwardedWhenUpdating.GetLabelCapFor(pawn).Named("TITLE"), pawn.Named("PAWN")), str, LetterDefOf.PositiveEvent, pawn, bestower.Faction);
        }
Beispiel #4
0
        public override string GetInspectString()
        {
            string        inspectString = base.GetInspectString();
            Room          room          = this.GetRoom();
            Pawn          p             = (CompAssignableToPawn.AssignedPawnsForReading.Count == 1) ? CompAssignableToPawn.AssignedPawnsForReading[0] : null;
            RoyalTitleDef titleStature  = TitleStature;

            inspectString += "\n" + "ThroneTitleStature".Translate((titleStature == null) ? "None".Translate() : (titleStature.GetLabelCapFor(p) + " " + "ThroneRoomImpressivenessInfo".Translate(titleStature.MinThroneRoomImpressiveness.ToString())));
            string text = RoomRoleWorker_ThroneRoom.Validate(room);

            if (text != null)
            {
                return(inspectString + "\n" + text);
            }
            tmpTitles.Clear();
            tmpTitles.AddRange(AllTitlesForThroneStature);
            int num  = tmpTitles.IndexOf(titleStature);
            int num2 = num - 1;
            int num3 = num + 1;

            if (num2 >= 0)
            {
                inspectString += "\n" + "ThronePrevTitleStature".Translate(tmpTitles[num2].GetLabelCapFor(p)) + " " + "ThroneRoomImpressivenessInfo".Translate(tmpTitles[num2].MinThroneRoomImpressiveness.ToString());
            }
            if (num3 < tmpTitles.Count)
            {
                inspectString += "\n" + "ThroneNextTitleStature".Translate(tmpTitles[num3].GetLabelCapFor(p)) + " " + "ThroneRoomImpressivenessInfo".Translate(tmpTitles[num3].MinThroneRoomImpressiveness.ToString());
            }
            return(inspectString);
        }
        public override string PostProcessDescription(Pawn p, string description)
        {
            RoyalTitleDef royalTitleDef = Validate(p);

            if (royalTitleDef == null)
            {
                return(string.Empty);
            }
            return(description.Formatted(GetFirstRequiredApparelPerGroup(p).ToLineList("- "), royalTitleDef.GetLabelCapFor(p).Named("TITLE"), p.Named("PAWN")));
        }
        public List <Thing> ApplyRewardsForTitle(Faction faction, RoyalTitleDef currentTitle, RoyalTitleDef newTitle, bool onlyForNewestTitle = false)
        {
            List <Thing>      list  = new List <Thing>();
            List <ThingCount> list2 = new List <ThingCount>();

            if (newTitle != null && newTitle.Awardable && pawn.IsColonist && NewHighestTitle(faction, newTitle))
            {
                int num  = ((currentTitle != null) ? faction.def.RoyalTitlesAwardableInSeniorityOrderForReading.IndexOf(currentTitle) : 0) + 1;
                int num2 = faction.def.RoyalTitlesAwardableInSeniorityOrderForReading.IndexOf(newTitle);
                if (onlyForNewestTitle)
                {
                    num = num2;
                }
                IntVec3 result  = IntVec3.Invalid;
                Map     mapHeld = pawn.MapHeld;
                if (mapHeld != null)
                {
                    if (mapHeld.IsPlayerHome)
                    {
                        result = DropCellFinder.TradeDropSpot(mapHeld);
                    }
                    else if (!DropCellFinder.TryFindDropSpotNear(pawn.Position, mapHeld, out result, allowFogged: false, canRoofPunch: false))
                    {
                        result = DropCellFinder.RandomDropSpot(mapHeld);
                    }
                }
                for (int i = num; i <= num2; i++)
                {
                    RoyalTitleDef royalTitleDef = faction.def.RoyalTitlesAwardableInSeniorityOrderForReading[i];
                    if (royalTitleDef.rewards == null)
                    {
                        continue;
                    }
                    List <Thing> list3 = royalTitleDef.rewards.Select(delegate(ThingDefCountClass r)
                    {
                        Thing thing      = ThingMaker.MakeThing(r.thingDef);
                        thing.stackCount = r.count;
                        return(thing);
                    }).ToList();
                    for (int j = 0; j < list3.Count; j++)
                    {
                        if (list3[j].def == ThingDefOf.PsychicAmplifier)
                        {
                            Find.History.Notify_PsylinkAvailable();
                            break;
                        }
                    }
                    if (pawn.Spawned)
                    {
                        DropPodUtility.DropThingsNear(result, mapHeld, list3, 110, canInstaDropDuringInit: false, leaveSlag: false, canRoofPunch: false, forbid: false);
                    }
                    else
                    {
                        foreach (Thing item in list3)
                        {
                            pawn.inventory.TryAddItemNotForSale(item);
                        }
                    }
                    for (int k = 0; k < list3.Count; k++)
                    {
                        list2.Add(new ThingCount(list3[k], list3[k].stackCount));
                    }
                    list.AddRange(list3);
                }
                if (list.Count > 0)
                {
                    TaggedString text = "LetterRewardsForNewTitle".Translate(pawn.Named("PAWN"), faction.Named("FACTION"), newTitle.GetLabelCapFor(pawn).Named("TITLE")) + "\n\n" + GenLabel.ThingsLabel(list2, "  - ", ignoreStackLimit: true) + "\n\n" + (pawn.Spawned ? "LetterRewardsForNewTitleDeliveryBase" : "LetterRewardsForNewTitleDeliveryDirect").Translate(pawn.Named("PAWN"));
                    Find.LetterStack.ReceiveLetter("LetterLabelRewardsForNewTitle".Translate(), text, LetterDefOf.PositiveEvent, list);
                }
            }
            return(list);
        }
 private void OnPreTitleChanged(Faction faction, RoyalTitleDef currentTitle, RoyalTitleDef newTitle, bool sendLetter = true)
 {
     AssignHeirIfNone(newTitle, faction);
     if (pawn.IsColonist && sendLetter)
     {
         TaggedString taggedString  = null;
         TaggedString taggedString2 = null;
         if (currentTitle == null || faction.def.RoyalTitlesAwardableInSeniorityOrderForReading.IndexOf(currentTitle) < faction.def.RoyalTitlesAwardableInSeniorityOrderForReading.IndexOf(newTitle))
         {
             taggedString  = "LetterGainedRoyalTitle".Translate(pawn.Named("PAWN"), faction.Named("FACTION"), newTitle.GetLabelCapFor(pawn).Named("TITLE"));
             taggedString2 = "LetterLabelGainedRoyalTitle".Translate(pawn.Named("PAWN"), newTitle.GetLabelCapFor(pawn).Named("TITLE"));
         }
         else
         {
             taggedString  = "LetterLostRoyalTitle".Translate(pawn.Named("PAWN"), faction.Named("FACTION"), currentTitle.GetLabelCapFor(pawn).Named("TITLE"));
             taggedString2 = "LetterLabelLostRoyalTitle".Translate(pawn.Named("PAWN"), currentTitle.GetLabelCapFor(pawn).Named("TITLE"));
         }
         string text = RoyalTitleUtility.BuildDifferenceExplanationText(currentTitle, newTitle, faction, pawn);
         if (text.Length > 0)
         {
             taggedString += "\n\n" + text;
         }
         taggedString = taggedString.Resolve().TrimEndNewlines();
         Find.LetterStack.ReceiveLetter(taggedString2, taggedString, LetterDefOf.PositiveEvent, pawn);
     }
     if (currentTitle != null)
     {
         for (int i = 0; i < currentTitle.grantedAbilities.Count; i++)
         {
             pawn.abilities.RemoveAbility(currentTitle.grantedAbilities[i]);
         }
     }
 }
Beispiel #8
0
 public string GetTooltip(Pawn pawn = null)
 {
     if (cachedTooltip == null)
     {
         cachedTooltip = base.LabelCap + ((level > 0) ? ((string)("\n" + "Level".Translate() + " ") + level) : "") + "\n\n" + description;
         string text = StatSummary.ToLineList();
         if (!text.NullOrEmpty())
         {
             cachedTooltip = cachedTooltip + "\n\n" + text;
         }
     }
     if (pawn != null && ModsConfig.RoyaltyActive && abilityClass == typeof(Psycast) && level > 0)
     {
         Faction first = Faction.GetMinTitleForImplantAllFactions(HediffDefOf.PsychicAmplifier).First;
         if (first != null)
         {
             RoyalTitleDef minTitleForImplant = first.GetMinTitleForImplant(HediffDefOf.PsychicAmplifier, level);
             RoyalTitleDef currentTitle       = pawn.royalty.GetCurrentTitle(first);
             if (minTitleForImplant != null && (currentTitle == null || currentTitle.seniority < minTitleForImplant.seniority) && DetectionChance > 0f)
             {
                 return(cachedTooltip + "\n\n" + ColoredText.Colorize("PsycastIsIllegal".Translate(pawn.Named("PAWN"), minTitleForImplant.GetLabelCapFor(pawn).Named("TITLE")), ColoredText.WarningColor));
             }
         }
     }
     return(cachedTooltip);
 }
Beispiel #9
0
        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("");
        }
Beispiel #10
0
        private static DiaOption RequestRoyalHeirChangeOption(Map map, Faction faction, Pawn factionRepresentative, Pawn negotiator)
        {
            RoyalTitleDef currentTitle = negotiator.royalty.GetCurrentTitle(faction);
            Pawn          heir         = negotiator.royalty.GetHeir(faction);
            DiaOption     diaOption    = new DiaOption((heir != null) ? "RequestChangeRoyalHeir".Translate(negotiator.Named("HOLDER"), currentTitle.GetLabelCapFor(negotiator).Named("TITLE"), heir.Named("HEIR")) : "RequestSetRoyalHeir".Translate(negotiator.Named("HOLDER"), currentTitle.GetLabelCapFor(negotiator).Named("TITLE")));
            bool          num          = Find.QuestManager.QuestsListForReading.Any((Quest q) => q.root == QuestScriptDefOf.ChangeRoyalHeir && q.State == QuestState.Ongoing && q.PartsListForReading.Any(delegate(QuestPart p)
            {
                QuestPart_ChangeHeir questPart_ChangeHeir = p as QuestPart_ChangeHeir;
                return(questPart_ChangeHeir != null && !questPart_ChangeHeir.done && questPart_ChangeHeir.holder == negotiator);
            }));

            diaOption.link = RoyalHeirChangeCandidates(faction, factionRepresentative, negotiator);
            if (num)
            {
                diaOption.Disable("RequestChangeRoyalHeirAlreadyInProgress".Translate(negotiator.Named("PAWN")));
            }
            return(diaOption);
        }
Beispiel #11
0
 public void Notify_RoyalThingUseViolation(Def implantOrWeapon, Pawn pawn, string violationSourceName, float detectionChance, int violationSourceLevel = 0)
 {
     if (!this.HostileTo(OfPlayer))
     {
         RoyalTitleDef minTitleToUse = ThingRequiringRoyalPermissionUtility.GetMinTitleToUse(implantOrWeapon, this, violationSourceLevel);
         string        arg           = (minTitleToUse == null) ? ((string)"None".Translate()) : minTitleToUse.GetLabelCapFor(pawn);
         TryAffectGoodwillWith(pawn.Faction, -4, canSendMessage: true, canSendHostilityLetter: true, "GoodwillChangedReason_UsedForbiddenThing".Translate(pawn.Named("PAWN"), violationSourceName.Named("CULPRIT")), pawn);
         Find.LetterStack.ReceiveLetter("LetterLawViolationDetectedLabel".Translate(pawn.Named("PAWN")).CapitalizeFirst(), "LetterLawViolationDetectedForbiddenThingUse".Translate(arg.Named("TITLE"), pawn.Named("PAWN"), violationSourceName.Named("CULPRIT"), this.Named("FACTION"), 4.ToString().Named("GOODWILL"), detectionChance.ToStringPercent().Named("CHANCE")), LetterDefOf.NegativeEvent, pawn);
     }
 }
        public override string GetInspectString()
        {
            string        inspectString = base.GetInspectString();
            Room          room          = this.GetRoom();
            Pawn          p             = ((CompAssignableToPawn.AssignedPawnsForReading.Count == 1) ? CompAssignableToPawn.AssignedPawnsForReading[0] : null);
            RoyalTitleDef titleStature  = TitleStature;

            inspectString += "\n" + "ThroneMaxSatisfiedTitle".Translate() + ": " + ((titleStature == null) ? "None".Translate() : ((TaggedString)titleStature.GetLabelCapFor(p)));
            string text = RoomRoleWorker_ThroneRoom.Validate(room);

            if (text != null)
            {
                return(inspectString + "\n" + text);
            }
            return(inspectString);
        }