Esempio n. 1
0
 public void EndInspiration(InspirationDef inspirationDef)
 {
     if (curState != null && curState.def == inspirationDef)
     {
         EndInspiration(curState);
     }
 }
 public void EndInspiration(InspirationDef inspirationDef)
 {
     if (this.curState != null && this.curState.def == inspirationDef)
     {
         this.EndInspiration(this.curState);
     }
 }
        public override void Apply(LocalTargetInfo target, LocalTargetInfo dest)
        {
            Pawn pawn = target.Pawn;

            if (pawn != null)
            {
                InspirationDef randomAvailableInspirationDef = pawn.mindState.inspirationHandler.GetRandomAvailableInspirationDef();
                if (randomAvailableInspirationDef != null)
                {
                    base.Apply(target, dest);
                    pawn.mindState.inspirationHandler.TryStartInspiration_NewTemp(randomAvailableInspirationDef, "LetterPsychicInspiration".Translate(pawn.Named("PAWN"), parent.pawn.Named("CASTER")));
                }
            }
        }
Esempio n. 4
0
 private void CheckStartRandomInspiration()
 {
     if (!this.Inspired)
     {
         float startInspirationMTBDays = this.StartInspirationMTBDays;
         if (!(startInspirationMTBDays < 0.0) && Rand.MTBEventOccurs(startInspirationMTBDays, 60000f, 100f))
         {
             InspirationDef randomAvailableInspirationDef = this.GetRandomAvailableInspirationDef();
             if (randomAvailableInspirationDef != null)
             {
                 this.TryStartInspiration(randomAvailableInspirationDef);
             }
         }
     }
 }
 public bool TryStartInspiration(InspirationDef def)
 {
     if (this.Inspired)
     {
         return(false);
     }
     if (!def.Worker.InspirationCanOccur(this.pawn))
     {
         return(false);
     }
     this.curState      = (Inspiration)Activator.CreateInstance(def.inspirationClass);
     this.curState.def  = def;
     this.curState.pawn = this.pawn;
     this.curState.PostStart();
     return(true);
 }
Esempio n. 6
0
 public bool TryStartInspiration_NewTemp(InspirationDef def, string reason = null)
 {
     if (Inspired)
     {
         return(false);
     }
     if (!def.Worker.InspirationCanOccur(pawn))
     {
         return(false);
     }
     curState        = (Inspiration)Activator.CreateInstance(def.inspirationClass);
     curState.def    = def;
     curState.pawn   = pawn;
     curState.reason = reason;
     curState.PostStart();
     return(true);
 }
Esempio n. 7
0
        private void CheckStartRandomInspiration()
        {
            if (Inspired)
            {
                return;
            }
            float startInspirationMTBDays = StartInspirationMTBDays;

            if (!(startInspirationMTBDays < 0f) && Rand.MTBEventOccurs(startInspirationMTBDays, 60000f, 100f))
            {
                InspirationDef randomAvailableInspirationDef = GetRandomAvailableInspirationDef();
                if (randomAvailableInspirationDef != null)
                {
                    TryStartInspiration_NewTemp(randomAvailableInspirationDef, "LetterInspirationBeginThanksToHighMoodPart".Translate());
                }
            }
        }
        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);
            }
        }
        public bool TryStartInspiration(InspirationDef def)
        {
            bool result;

            if (this.Inspired)
            {
                result = false;
            }
            else if (!def.Worker.InspirationCanOccur(this.pawn))
            {
                result = false;
            }
            else
            {
                this.curState      = (Inspiration)Activator.CreateInstance(def.inspirationClass);
                this.curState.def  = def;
                this.curState.pawn = this.pawn;
                this.curState.PostStart();
                result = true;
            }
            return(result);
        }
 private float <GetRandomAvailableInspirationDef> m__1(InspirationDef x)
 {
     return(x.Worker.CommonalityFor(this.pawn));
 }
 private bool <GetRandomAvailableInspirationDef> m__0(InspirationDef x)
 {
     return(x.Worker.InspirationCanOccur(this.pawn));
 }
Esempio n. 12
0
 public bool TryStartInspiration(InspirationDef def)
 {
     return(TryStartInspiration_NewTemp(def));
 }