예제 #1
0
 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]);
         }
     }
 }
예제 #2
0
        public static string GetTitleProgressionInfo(Faction faction, Pawn pawn = null)
        {
            TaggedString taggedString = "RoyalTitleTooltipTitlesEarnable".Translate(faction.Named("FACTION")) + ":";
            int          num          = 0;

            foreach (RoyalTitleDef item in faction.def.RoyalTitlesAwardableInSeniorityOrderForReading)
            {
                num          += item.favorCost;
                taggedString += "\n  - " + ((pawn != null) ? item.GetLabelCapFor(pawn) : item.GetLabelCapForBothGenders()) + ": " + "RoyalTitleTooltipRoyalFavorAmount".Translate(item.favorCost, faction.def.royalFavorLabel) + " (" + "RoyalTitleTooltipRoyalFavorTotal".Translate(num.ToString()) + ")";
            }
            taggedString += "\n\n" + "RoyalTitleTooltipTitlesNonEarnable".Translate(faction.Named("FACTION")) + ":";
            foreach (RoyalTitleDef item2 in faction.def.RoyalTitlesAllInSeniorityOrderForReading.Where((RoyalTitleDef tit) => !tit.Awardable))
            {
                taggedString += "\n  - " + item2.GetLabelCapForBothGenders();
            }
            return(taggedString.Resolve());
        }
예제 #3
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);
        }