Пример #1
0
        public void GainFavor(Faction faction, int amount)
        {
            if (!ModLister.RoyaltyInstalled)
            {
                Log.ErrorOnce("Royal favor is 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.", 63699999);
                return;
            }
            if (!favor.TryGetValue(faction, out int value))
            {
                value = 0;
                favor.Add(faction, 0);
            }
            value         += amount;
            favor[faction] = value;
            RoyalTitleDef currentTitle = GetCurrentTitle(faction);

            UpdateRoyalTitle(faction);
            RoyalTitleDef currentTitle2 = GetCurrentTitle(faction);

            if (currentTitle2 != currentTitle)
            {
                ApplyRewardsForTitle(faction, currentTitle, currentTitle2);
                OnPostTitleChanged(faction, currentTitle2);
            }
        }
Пример #2
0
        public static bool IsViolatingRulesOf(Def implantOrWeapon, Pawn pawn, Faction faction, int implantLevel = 0)
        {
            if (faction.def.royalImplantRules == null || faction.def.royalImplantRules.Count == 0)
            {
                return(false);
            }
            RoyalTitleDef minTitleToUse = GetMinTitleToUse(implantOrWeapon, faction, implantLevel);

            if (minTitleToUse == null)
            {
                return(false);
            }
            RoyalTitleDef currentTitle = pawn.royalty.GetCurrentTitle(faction);

            if (currentTitle == null)
            {
                return(true);
            }
            int num = faction.def.RoyalTitlesAwardableInSeniorityOrderForReading.IndexOf(currentTitle);

            if (num < 0)
            {
                return(false);
            }
            int num2 = faction.def.RoyalTitlesAwardableInSeniorityOrderForReading.IndexOf(minTitleToUse);

            return(num < num2);
        }
Пример #3
0
        public IEnumerable <string> GetUnmetThroneroomRequirements(bool includeOnGracePeriod = true, bool onlyOnGracePeriod = false)
        {
            if (pawn.ownership.AssignedThrone == null)
            {
                yield break;
            }
            RoyalTitle highestTitle = HighestTitleWithThroneRoomRequirements();

            if (highestTitle != null)
            {
                Room throneRoom = pawn.ownership.AssignedThrone.GetRoom();
                if (throneRoom != null)
                {
                    RoyalTitleDef prevTitle = highestTitle.def.GetPreviousTitle(highestTitle.faction);
                    foreach (RoomRequirement throneRoomRequirement in highestTitle.def.throneRoomRequirements)
                    {
                        if (!throneRoomRequirement.Met(throneRoom, pawn))
                        {
                            bool flag  = highestTitle.RoomRequirementGracePeriodActive(pawn);
                            bool flag2 = prevTitle != null && !prevTitle.HasSameThroneroomRequirement(throneRoomRequirement);
                            if ((!onlyOnGracePeriod || (flag2 && flag)) && (!flag || !flag2 || includeOnGracePeriod))
                            {
                                yield return(throneRoomRequirement.LabelCap(throneRoom));
                            }
                        }
                    }
                }
            }
        }
Пример #4
0
 public RoyalTitle(RoyalTitle other)
 {
     faction      = other.faction;
     def          = other.def;
     receivedTick = other.receivedTick;
     pawn         = other.pawn;
 }
Пример #5
0
 public static void FindLostAndGainedPermits(RoyalTitleDef currentTitle, RoyalTitleDef newTitle, out List <RoyalTitlePermitDef> gainedPermits, out List <RoyalTitlePermitDef> lostPermits)
 {
     gainedPermits = new List <RoyalTitlePermitDef>();
     lostPermits   = new List <RoyalTitlePermitDef>();
     if (newTitle != null && newTitle.permits != null)
     {
         foreach (RoyalTitlePermitDef permit in newTitle.permits)
         {
             if (currentTitle == null || currentTitle.permits == null || !currentTitle.permits.Contains(permit))
             {
                 gainedPermits.Add(permit);
             }
         }
     }
     if (currentTitle == null || currentTitle.permits == null)
     {
         return;
     }
     foreach (RoyalTitlePermitDef permit2 in currentTitle.permits)
     {
         if (newTitle == null || newTitle.permits == null || !newTitle.permits.Contains(permit2))
         {
             lostPermits.Add(permit2);
         }
     }
 }
Пример #6
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);
 }
Пример #7
0
 internal IEnumerable <StatDrawEntry> SpecialDisplayStats()
 {
     if (joy > 0f)
     {
         StatCategoryDef category = ((drugCategory != 0) ? StatCategoryDefOf.Drug : StatCategoryDefOf.Basics);
         yield return(new StatDrawEntry(category, "Joy".Translate(), joy.ToStringPercent("F0") + " (" + JoyKind.label + ")", "Stat_Thing_Ingestible_Joy_Desc".Translate(), 4751));
     }
     if (HumanEdible)
     {
         RoyalTitleDef royalTitleDef = MaxSatisfiedTitle();
         if (royalTitleDef != null)
         {
             yield return(new StatDrawEntry(StatCategoryDefOf.Basics, "Stat_Thing_Ingestible_MaxSatisfiedTitle".Translate(), royalTitleDef.GetLabelCapForBothGenders(), "Stat_Thing_Ingestible_MaxSatisfiedTitle_Desc".Translate(), 4752));
         }
     }
     if (outcomeDoers == null)
     {
         yield break;
     }
     for (int i = 0; i < outcomeDoers.Count; i++)
     {
         foreach (StatDrawEntry item in outcomeDoers[i].SpecialDisplayStats(parent))
         {
             yield return(item);
         }
     }
 }
Пример #8
0
 public override TaggedString GetExplanation()
 {
     return(defaultExplanation + "\n" + Targets.Select(delegate(Pawn t)
     {
         RoyalTitle royalTitle = t.royalty.HighestTitleWithBedroomRequirements();
         RoyalTitleDef royalTitleDef = (royalTitle.RoomRequirementGracePeriodActive(t) ? royalTitle.def.GetPreviousTitle(royalTitle.faction) : royalTitle.def);
         string[] array = t.royalty.GetUnmetBedroomRequirements(includeOnGracePeriod: false).ToArray();
         string[] array2 = t.royalty.GetUnmetBedroomRequirements(includeOnGracePeriod: true, onlyOnGracePeriod: true).ToArray();
         bool flag = royalTitleDef != null && array.Length != 0;
         StringBuilder stringBuilder = new StringBuilder();
         if (flag)
         {
             stringBuilder.Append(t.LabelShort + " (" + royalTitleDef.GetLabelFor(t.gender) + "):\n" + array.ToLineList("- "));
         }
         if (array2.Length != 0)
         {
             if (flag)
             {
                 stringBuilder.Append("\n\n");
             }
             stringBuilder.Append(t.LabelShort + " (" + royalTitle.def.GetLabelFor(t.gender) + ", " + "RoomRequirementGracePeriodDesc".Translate(royalTitle.RoomRequirementGracePeriodDaysLeft.ToString("0.0")) + ")" + ":\n" + array2.ToLineList("- "));
         }
         return stringBuilder.ToString();
     }).ToLineList("\n"));
 }
Пример #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("");
        }
Пример #10
0
        public RoyalImplantRule GetMaxAllowedImplantLevel(HediffDef implantDef, RoyalTitleDef title)
        {
            if (def.royalImplantRules == null || def.royalImplantRules.Count == 0)
            {
                return(null);
            }
            if (title == null)
            {
                return(null);
            }
            int myTitleIdx = def.RoyalTitlesAwardableInSeniorityOrderForReading.IndexOf(title);

            return(def.royalImplantRules.Where(delegate(RoyalImplantRule r)
            {
                if (r.implantHediff == implantDef)
                {
                    RoyalTitleDef minTitleForImplant = GetMinTitleForImplant(implantDef, r.maxLevel);
                    int num = def.RoyalTitlesAwardableInSeniorityOrderForReading.IndexOf(minTitleForImplant);
                    if (myTitleIdx != -1)
                    {
                        return myTitleIdx >= num;
                    }
                    return true;
                }
                return false;
            }).Last());
        }
        public override IEnumerable <StatDrawEntry> SpecialDisplayStats()
        {
            foreach (Faction allFaction in Find.FactionManager.AllFactions)
            {
                RoyalTitleDef minTitleToUse = ThingRequiringRoyalPermissionUtility.GetMinTitleToUse(parent.def, allFaction);
                if (minTitleToUse != null)
                {
                    yield return(new StatDrawEntry(StatCategoryDefOf.BasicsNonPawnImportant, "Stat_Thing_MinimumRoyalTitle_Name".Translate(allFaction.Named("FACTION")).Resolve(), minTitleToUse.GetLabelCapForBothGenders(), "Stat_Thing_Weapon_MinimumRoyalTitle_Desc".Translate(allFaction.Named("FACTION")).Resolve(), 2100));
                }
            }
            if (traits.NullOrEmpty())
            {
                yield break;
            }
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.AppendLine("Stat_Thing_PersonaWeaponTrait_Desc".Translate());
            stringBuilder.AppendLine();
            for (int i = 0; i < traits.Count; i++)
            {
                stringBuilder.AppendLine(traits[i].LabelCap + ": " + traits[i].description);
                if (i < traits.Count - 1)
                {
                    stringBuilder.AppendLine();
                }
            }
            yield return(new StatDrawEntry(StatCategoryDefOf.Weapon, "Stat_Thing_PersonaWeaponTrait_Label".Translate(), traits.Select((WeaponTraitDef x) => x.label).ToCommaList().CapitalizeFirst(), stringBuilder.ToString(), 5404));
        }
Пример #12
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);
        }
Пример #13
0
        public IEnumerable <string> GetUnmetBedroomRequirements(bool includeOnGracePeriod = true, bool onlyOnGracePeriod = false)
        {
            RoyalTitle royalTitle = HighestTitleWithBedroomRequirements();

            if (royalTitle != null)
            {
                bool          gracePeriodActive = royalTitle.RoomRequirementGracePeriodActive(pawn);
                RoyalTitleDef prevTitle         = royalTitle.def.GetPreviousTitle(royalTitle.faction);
                if (HasPersonalBedroom())
                {
                    Room bedroom = pawn.ownership.OwnedRoom;
                    foreach (RoomRequirement bedroomRequirement in royalTitle.def.GetBedroomRequirements(pawn))
                    {
                        if (!bedroomRequirement.Met(bedroom))
                        {
                            bool flag = prevTitle != null && !prevTitle.HasSameBedroomRequirement(bedroomRequirement);
                            if ((!onlyOnGracePeriod || (flag && gracePeriodActive)) && (!gracePeriodActive || !flag || includeOnGracePeriod))
                            {
                                yield return(bedroomRequirement.LabelCap(bedroom));
                            }
                        }
                    }
                }
            }
        }
Пример #14
0
        public void SetTitle(Faction faction, RoyalTitleDef title, bool grantRewards, bool rewardsOnlyForNewestTitle = false, bool sendLetter = true)
        {
            if (!ModLister.RoyaltyInstalled)
            {
                Log.ErrorOnce("Royal favor is 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.", 7445532);
                return;
            }
            RoyalTitleDef currentTitle = GetCurrentTitle(faction);

            OnPreTitleChanged(faction, currentTitle, title, sendLetter);
            if (grantRewards)
            {
                ApplyRewardsForTitle(faction, currentTitle, title, rewardsOnlyForNewestTitle);
            }
            int index = FindFactionTitleIndex(faction, createIfNotExisting: true);

            if (title != null)
            {
                titles[index].def          = title;
                titles[index].receivedTick = GenTicks.TicksGame;
            }
            else
            {
                titles.RemoveAt(index);
            }
            SetFavor(faction, 0);
            OnPostTitleChanged(faction, title);
        }
Пример #15
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]);
         }
     }
 }
Пример #16
0
        private void UpdateRoyalTitle(Faction faction)
        {
            RoyalTitleDef currentTitle = GetCurrentTitle(faction);

            if (currentTitle != null && !currentTitle.Awardable)
            {
                return;
            }
            RoyalTitleDef nextTitle = currentTitle.GetNextTitle(faction);

            if (nextTitle == null)
            {
                return;
            }
            int num = GetFavor(faction);

            if (num >= nextTitle.favorCost)
            {
                OnPreTitleChanged(faction, currentTitle, nextTitle);
                SetFavor(faction, num - nextTitle.favorCost);
                int index = FindFactionTitleIndex(faction, createIfNotExisting: true);
                titles[index].def = nextTitle;
                CleanupThoughts(currentTitle);
                CleanupThoughts(nextTitle);
                if (nextTitle.awardThought != null && pawn.needs != null && pawn.needs.mood != null)
                {
                    Thought_MemoryRoyalTitle thought_MemoryRoyalTitle = (Thought_MemoryRoyalTitle)ThoughtMaker.MakeThought(nextTitle.awardThought);
                    thought_MemoryRoyalTitle.titleDef = nextTitle;
                    pawn.needs.mood.thoughts.memories.TryGainMemory(thought_MemoryRoyalTitle);
                }
                UpdateRoyalTitle(faction);
            }
        }
Пример #17
0
 public void AssignHeirIfNone(RoyalTitleDef t, Faction faction)
 {
     if (!heirs.ContainsKey(faction) && t.Awardable && pawn.FactionOrExtraHomeFaction != Faction.Empire)
     {
         SetHeir(t.GetInheritanceWorker(faction).FindHeir(faction, pawn, t), faction);
     }
 }
Пример #18
0
        public void ReduceTitle(Faction faction)
        {
            RoyalTitleDef currentTitle = GetCurrentTitle(faction);

            if (currentTitle != null && currentTitle.Awardable)
            {
                RoyalTitleDef previousTitle = currentTitle.GetPreviousTitle(faction);
                OnPreTitleChanged(faction, currentTitle, previousTitle);
                CleanupThoughts(currentTitle);
                CleanupThoughts(previousTitle);
                if (currentTitle.awardThought != null && pawn.needs.mood != null)
                {
                    Thought_MemoryRoyalTitle thought_MemoryRoyalTitle = (Thought_MemoryRoyalTitle)ThoughtMaker.MakeThought(currentTitle.lostThought);
                    thought_MemoryRoyalTitle.titleDef = currentTitle;
                    pawn.needs.mood.thoughts.memories.TryGainMemory(thought_MemoryRoyalTitle);
                }
                int index = FindFactionTitleIndex(faction);
                if (previousTitle == null)
                {
                    titles.RemoveAt(index);
                }
                else
                {
                    titles[index].def = previousTitle;
                }
                SetFavor(faction, 0);
                OnPostTitleChanged(faction, previousTitle);
            }
        }
        public bool AvailableForPawn(Pawn pawn, Faction faction)
        {
            if (pawn.royalty == null)
            {
                return(false);
            }
            if (pawn.royalty.HasPermit(this, faction))
            {
                return(false);
            }
            if (prerequisite != null && !pawn.royalty.HasPermit(prerequisite, faction))
            {
                return(false);
            }
            if (pawn.royalty.GetPermitPoints(faction) < permitPointCost)
            {
                return(false);
            }
            RoyalTitleDef currentTitle = pawn.royalty.GetCurrentTitle(faction);

            if (currentTitle == null && minTitle == null)
            {
                return(true);
            }
            if (currentTitle == null && minTitle != null)
            {
                return(false);
            }
            return(currentTitle.seniority >= minTitle.seniority);
        }
Пример #20
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 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 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")));
        }
Пример #23
0
 public override IEnumerable <StatDrawEntry> SpecialDisplayStats()
 {
     foreach (Faction allFaction in Find.FactionManager.AllFactions)
     {
         RoyalTitleDef minTitleToUse = ThingRequiringRoyalPermissionUtility.GetMinTitleToUse(parent.def, allFaction);
         if (minTitleToUse != null)
         {
             yield return(new StatDrawEntry(StatCategoryDefOf.BasicsNonPawnImportant, "Stat_Thing_MinimumRoyalTitle_Name".Translate(allFaction.Named("FACTION")).Resolve(), minTitleToUse.GetLabelCapForBothGenders(), "Stat_Thing_Weapon_MinimumRoyalTitle_Desc".Translate(allFaction.Named("FACTION")).Resolve(), 2100));
         }
     }
 }
Пример #24
0
 public bool HasTitle(RoyalTitleDef title)
 {
     foreach (RoyalTitle title2 in titles)
     {
         if (title2.def == title)
         {
             return(true);
         }
     }
     return(false);
 }
Пример #25
0
 private void UpdateHighestTitleAchieved(Faction faction, RoyalTitleDef title)
 {
     if (!highestTitles.ContainsKey(faction))
     {
         highestTitles.Add(faction, title);
     }
     else if (NewHighestTitle(faction, title))
     {
         highestTitles[faction] = title;
     }
 }
        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")));
        }
Пример #27
0
 public static Pair <Faction, RoyalTitleDef> GetMinTitleForImplantAllFactions(HediffDef implantDef)
 {
     foreach (Faction item in Find.FactionManager.AllFactionsListForReading)
     {
         RoyalTitleDef minTitleForImplant = item.GetMinTitleForImplant(implantDef);
         if (minTitleForImplant != null)
         {
             return(new Pair <Faction, RoyalTitleDef>(item, minTitleForImplant));
         }
     }
     return(default(Pair <Faction, RoyalTitleDef>));
 }
Пример #28
0
        public static void DoTable_IngestibleMaxSatisfiedTitle()
        {
            List <TableDataGetter <ThingDef> > list = new List <TableDataGetter <ThingDef> >();

            list.Add(new TableDataGetter <ThingDef>("name", (ThingDef f) => f.LabelCap));
            list.Add(new TableDataGetter <ThingDef>("max satisfied title", delegate(ThingDef t)
            {
                RoyalTitleDef royalTitleDef = t.ingestible.MaxSatisfiedTitle();
                return((royalTitleDef == null) ? "-" : ((string)royalTitleDef.LabelCap));
            }));
            DebugTables.MakeTablesDialog(DefDatabase <ThingDef> .AllDefsListForReading.Where((ThingDef t) => t.ingestible != null && !t.IsCorpse && t.ingestible.HumanEdible), list.ToArray());
        }
Пример #29
0
 public static void DrawStatsReport(Rect rect, RoyalTitleDef title, Faction faction)
 {
     if (cachedDrawEntries.NullOrEmpty())
     {
         cachedDrawEntries.AddRange(title.SpecialDisplayStats(StatRequest.For(title, faction)));
         cachedDrawEntries.AddRange(from r in StatsToDraw(title, faction)
                                    where r.ShouldDisplay
                                    select r);
         FinalizeCachedDrawEntries(cachedDrawEntries);
     }
     DrawStatsWorker(rect, null, null);
 }
Пример #30
0
 protected override Job TryGiveJob(Pawn pawn)
 {
     if (!pawn.guest.PrisonerIsSecure || pawn.apparel == null)
     {
         return(null);
     }
     if (ThoughtUtility.CanGetThought_NewTemp(pawn, ThoughtDefOf.ClothedNudist, checkIfNullified: true) && pawn.AmbientTemperature >= pawn.SafeTemperatureRange().min)
     {
         return(null);
     }
     if (pawn.royalty != null && pawn.royalty.AllTitlesInEffectForReading.Count > 0)
     {
         RoyalTitleDef def = pawn.royalty.MostSeniorTitle.def;
         if (def != null && def.requiredApparel != null)
         {
             for (int i = 0; i < def.requiredApparel.Count; i++)
             {
                 if (!def.requiredApparel[i].IsMet(pawn))
                 {
                     Apparel apparel = FindGarmentSatisfyingTitleRequirement(pawn, def.requiredApparel[i]);
                     if (apparel != null)
                     {
                         Job job = JobMaker.MakeJob(JobDefOf.Wear, apparel);
                         job.ignoreForbidden = true;
                         return(job);
                     }
                 }
             }
         }
     }
     if (!pawn.apparel.BodyPartGroupIsCovered(BodyPartGroupDefOf.Legs))
     {
         Apparel apparel2 = FindGarmentCoveringPart(pawn, BodyPartGroupDefOf.Legs);
         if (apparel2 != null)
         {
             Job job2 = JobMaker.MakeJob(JobDefOf.Wear, apparel2);
             job2.ignoreForbidden = true;
             return(job2);
         }
     }
     if (!pawn.apparel.BodyPartGroupIsCovered(BodyPartGroupDefOf.Torso))
     {
         Apparel apparel3 = FindGarmentCoveringPart(pawn, BodyPartGroupDefOf.Torso);
         if (apparel3 != null)
         {
             Job job3 = JobMaker.MakeJob(JobDefOf.Wear, apparel3);
             job3.ignoreForbidden = true;
             return(job3);
         }
     }
     return(null);
 }