Example #1
0
        public bool TryDoRandomMoodCausedMentalBreak()
        {
            if (!CanDoRandomMentalBreaks || pawn.Downed || !pawn.Awake() || pawn.InMentalState)
            {
                return(false);
            }
            if (pawn.Faction != Faction.OfPlayer && CurrentDesiredMoodBreakIntensity != MentalBreakIntensity.Extreme)
            {
                return(false);
            }
            if (QuestUtility.AnyQuestDisablesRandomMoodCausedMentalBreaksFor(pawn))
            {
                return(false);
            }
            if (!CurrentPossibleMoodBreaks.TryRandomElementByWeight((MentalBreakDef d) => d.Worker.CommonalityFor(pawn, moodCaused: true), out MentalBreakDef result))
            {
                return(false);
            }
            Thought      thought      = RandomFinalStraw();
            TaggedString taggedString = "MentalStateReason_Mood".Translate();

            if (thought != null)
            {
                taggedString += "\n\n" + "FinalStraw".Translate(thought.LabelCap);
            }
            return(result.Worker.TryStart(pawn, taggedString, causedByMood: true));
        }
Example #2
0
        internal string DebugString()
        {
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.AppendLine(pawn.ToString());
            stringBuilder.AppendLine("   ticksUntilCanDoMentalBreak=" + ticksUntilCanDoMentalBreak);
            stringBuilder.AppendLine("   ticksBelowExtreme=" + ticksBelowExtreme + "/" + 2000);
            stringBuilder.AppendLine("   ticksBelowSerious=" + ticksBelowMajor + "/" + 2000);
            stringBuilder.AppendLine("   ticksBelowMinor=" + ticksBelowMinor + "/" + 2000);
            stringBuilder.AppendLine();
            stringBuilder.AppendLine("Current desired mood break intensity: " + CurrentDesiredMoodBreakIntensity.ToString());
            stringBuilder.AppendLine();
            stringBuilder.AppendLine("Current possible mood breaks:");
            float num = CurrentPossibleMoodBreaks.Select((MentalBreakDef d) => d.Worker.CommonalityFor(pawn, moodCaused: true)).Sum();

            foreach (MentalBreakDef currentPossibleMoodBreak in CurrentPossibleMoodBreaks)
            {
                float num2 = currentPossibleMoodBreak.Worker.CommonalityFor(pawn, moodCaused: true);
                stringBuilder.AppendLine("   " + currentPossibleMoodBreak + "     " + (num2 / num).ToStringPercent());
            }
            return(stringBuilder.ToString());
        }