protected virtual void ApplyOutcome(float progress)
        {
            if (progress < 0.5f)
            {
                Find.LetterStack.ReceiveLetter("LetterLabelSpeechCancelled".Translate(), "LetterSpeechCancelled".Translate(organizer.Named("ORGANIZER")).CapitalizeFirst(), LetterDefOf.NegativeEvent, organizer);
                return;
            }
            ThoughtDef key  = OutcomeThoughtChances.RandomElementByWeight((KeyValuePair <ThoughtDef, float> t) => (!PositiveOutcome(t.Key)) ? t.Value : (t.Value * organizer.GetStatValue(StatDefOf.SocialImpact) * progress)).Key;
            string     text = "";

            foreach (Pawn ownedPawn in lord.ownedPawns)
            {
                if (ownedPawn == organizer || !organizer.Position.InHorDistOf(ownedPawn.Position, 18f))
                {
                    continue;
                }
                ownedPawn.needs.mood.thoughts.memories.TryGainMemory(key, organizer);
                if (key == ThoughtDefOf.InspirationalSpeech && Rand.Chance(InspirationChanceFromInspirationalSpeech))
                {
                    InspirationDef randomAvailableInspirationDef = ownedPawn.mindState.inspirationHandler.GetRandomAvailableInspirationDef();
                    if (randomAvailableInspirationDef != null && ownedPawn.mindState.inspirationHandler.TryStartInspiration_NewTemp(randomAvailableInspirationDef, "LetterSpeechInspiration".Translate(ownedPawn.Named("PAWN"), organizer.Named("SPEAKER"))))
                    {
                        text = text + "  - " + ownedPawn.NameShortColored.Resolve() + "\n";
                    }
                }
            }
            TaggedString text2 = "LetterFinishedSpeech".Translate(organizer.Named("ORGANIZER")).CapitalizeFirst() + " " + ("Letter" + key.defName).Translate();

            if (!text.NullOrEmpty())
            {
                text2 += "\n\n" + "LetterSpeechInspiredListeners".Translate() + "\n\n" + text.TrimEndNewlines();
            }
            if (progress < 1f)
            {
                text2 += "\n\n" + "LetterSpeechInterrupted".Translate(progress.ToStringPercent(), organizer.Named("ORGANIZER"));
            }
            Find.LetterStack.ReceiveLetter(key.stages[0].LabelCap, text2, PositiveOutcome(key) ? LetterDefOf.PositiveEvent : LetterDefOf.NegativeEvent, organizer);
            Ability    ability         = organizer.abilities.GetAbility(AbilityDefOf.Speech);
            RoyalTitle mostSeniorTitle = organizer.royalty.MostSeniorTitle;

            if (ability != null && mostSeniorTitle != null)
            {
                ability.StartCooldown(mostSeniorTitle.def.speechCooldown.RandomInRange);
            }
        }
示例#2
0
        public static RoyalTitle GetMaxPsylinkLevelTitle(this Pawn pawn)
        {
            if (pawn.royalty == null)
            {
                return(null);
            }
            int        num    = 0;
            RoyalTitle result = null;

            foreach (RoyalTitle item in pawn.royalty.AllTitlesInEffectForReading)
            {
                if (num < item.def.maxPsylinkLevel)
                {
                    num    = item.def.maxPsylinkLevel;
                    result = item;
                }
            }
            return(result);
        }