Exemple #1
0
 public static void AddAnxiety(MentalBreaker __instance, ref bool __result)
 {
     if (__result)
     {
         Pawn pawn = Traverse.Create(__instance).Field("pawn").GetValue <Pawn>();
         int  intensity;
         int.TryParse("" + (byte)Traverse.Create(__instance).Property("CurrentDesiredMoodBreakIntensity").GetValue <MentalBreakIntensity>(), out intensity);
         Hediff hediff     = pawn.health.hediffSet.GetFirstHediffOfDef(HediffDefOfPsychology.Anxiety);
         float  PTSDChance = (0.25f - (0.075f * intensity));
         if (pawn is PsychologyPawn)
         {
             //Laid-back pawns are less likely to get anxiety from mental breaks.
             PTSDChance -= (pawn as PsychologyPawn).psyche.GetPersonalityRating(PersonalityNodeDefOf.LaidBack) / 10f;
         }
         if (hediff != null)
         {
             hediff.Severity += 0.15f - (intensity * 0.5f);
         }
         else if (Rand.Value <= PTSDChance)
         {
             Hediff newHediff = HediffMaker.MakeHediff(HediffDefOfPsychology.Anxiety, pawn, pawn.health.hediffSet.GetBrain());
             newHediff.Severity = 0.75f - (intensity * 0.25f);
             pawn.health.AddHediff(newHediff, null, null);
         }
     }
 }
Exemple #2
0
 public static void AddAnxiety(MentalBreaker __instance, ref bool __result)
 {
     if (__result)
     {
         Pawn pawn = Traverse.Create(__instance).Field("pawn").GetValue <Pawn>();
         int  intensity;
         int.TryParse("" + (byte)Traverse.Create(__instance).Property("CurrentDesiredMoodBreakIntensity").GetValue <MentalBreakIntensity>(), out intensity);
         Hediff hediff     = pawn.health.hediffSet.GetFirstHediffOfDef(HediffDefOfPsychology.Anxiety);
         float  PTSDChance = (0.25f - (0.075f * intensity));
         if (pawn.story.traits.HasTrait(TraitDefOfPsychology.Desensitized))
         {
             PTSDChance *= 0.75f;
         }
         if (PsycheHelper.PsychologyEnabled(pawn))
         {
             //Laid-back pawns are less likely to get anxiety from mental breaks.
             PTSDChance -= pawn.GetComp <CompPsychology>().Psyche.GetPersonalityRating(PersonalityNodeDefOf.LaidBack) / 10f;
         }
         if (hediff != null)
         {
             hediff.Severity += 0.15f - (intensity * 0.5f);
         }
         else if (Rand.Chance(PTSDChance))
         {
             Hediff newHediff = HediffMaker.MakeHediff(HediffDefOfPsychology.Anxiety, pawn, pawn.health.hediffSet.GetBrain());
             newHediff.Severity = 0.75f - (intensity * 0.25f);
             Letter newAnxiety = LetterMaker.MakeLetter("LetterLabelPTSD".Translate(), "LetterPTSD".Translate().AdjustedFor(pawn), LetterDefOf.NegativeEvent, pawn);
             Find.LetterStack.ReceiveLetter(newAnxiety);
             pawn.health.AddHediff(newHediff, null, null);
         }
     }
 }
Exemple #3
0
        public static void BreakPawn(Pawn pawn)
        {
            MentalBreaker mB = pawn.mindState.breaker;

            //pawn.story.traits.allTraits



            pawn.mindState.broken.StartBrokenState(DefDatabase <BrokenStateDef> .GetNamed("Manhunter", true));



            //if (pawn.mindState.broken.CurState == null)
            //{
            //    if (pawn.story != null)
            //    {
            //        List<Trait> allTraits = pawn.story.traits.allTraits;
            //        for (int i = 0; i < allTraits.Count; i++)
            //        {
            //            TraitDegreeData currentData = allTraits[i].CurrentData;
            //            if (currentData.randomBreakState != null)
            //            {
            //                float mtb = currentData.randomBreakMtbDaysMoodCurve.Evaluate(CurMood(pawn));
            //                if (Rand.MTBEventOccurs(mtb, 30000f, 150f) && currentData.randomBreakState.Worker.StateCanOccur(pawn))
            //                {
            //                    pawn.mindState.broken.StartBrokenState(currentData.randomBreakState);
            //                }
            //            }
            //        }
            //    }
            //}
        }
        internal static IEnumerable <MentalBreakDef> CurrentPossibleMoodBreaks(this MentalBreaker _this)
        {
            var _currentPossibleMoodBreaks = typeof(MentalBreaker).GetProperty("CurrentPossibleMoodBreaks", BindingFlags.Instance | BindingFlags.NonPublic);

            if (_currentPossibleMoodBreaks == null)
            {
                Log.ErrorOnce("Unable to reflect MentalBreaker.CurrentPossibleMoodBreaks!", 0x12348765);
            }
            return((IEnumerable <MentalBreakDef>)_currentPossibleMoodBreaks.GetValue(_this, null));
        }
        internal static MentalBreakIntensity CurrentDesiredMoodBreakIntensity(this MentalBreaker _this)
        {
            var _currentDesiredMoodBreakIntensity = typeof(MentalBreaker).GetProperty("CurrentDesiredMoodBreakIntensity", BindingFlags.Instance | BindingFlags.NonPublic);

            if (_currentDesiredMoodBreakIntensity == null)
            {
                Log.ErrorOnce("Unable to reflect MentalBreaker.CurrentDesiredMoodBreakIntensity!", 0x12348765);
            }
            return((MentalBreakIntensity)_currentDesiredMoodBreakIntensity.GetValue(_this, null));
        }
        internal static bool CanDoRandomMentalBreaks(this MentalBreaker _this)
        {
            var _canDoRandomMentalBreaks = typeof(MentalBreaker).GetProperty("CanDoRandomMentalBreaks", BindingFlags.Instance | BindingFlags.NonPublic);

            if (_canDoRandomMentalBreaks == null)
            {
                Log.ErrorOnce("Unable to reflect MentalBreaker.CanDoRandomMentalBreaks!", 0x12348765);
            }
            return((bool)_canDoRandomMentalBreaks.GetValue(_this, null));
        }
        // Verse.MentalBreaker
        public static void CurrentPossibleMoodBreaksPostFix(MentalBreaker __instance, ref IEnumerable <MentalBreakDef> __result)
        {
            //Declare variables for the process
            var pawn = (Pawn)AccessTools.Field(typeof(MentalBreaker), "pawn").GetValue(__instance);

            //IsWearingStraitJacket
            if (pawn?.apparel?.WornApparel?.FirstOrDefault(x => x.def == StraitjacketDefOf.ROM_Straitjacket) != null)
            {
                var    thought = (Thought)AccessTools.Method(typeof(MentalBreaker), "RandomFinalStraw").Invoke(__instance, new object[] { });
                string reason  = thought?.LabelCap ?? "";

                //Reset the mind state because we probably tried to start something before this process started.
                //pawn.mindState.mentalStateHandler.Reset();

                MentalBreakDef mentalBreakDef = null;
                if (!(__result?.TryRandomElementByWeight((MentalBreakDef d) => d.Worker.CommonalityFor(pawn), out mentalBreakDef) ?? false))
                {
                    return;
                }

                if (Rand.Range(0, 100) < 95) //95% of the time
                {
                    Cthulhu.Utility.DebugReport("StraitJacket :: Mental Break Triggered");
                    var stateDef = mentalBreakDef?.mentalState ?? ((Rand.Value > 0.5f) ? DefDatabase <MentalStateDef> .GetNamed("Berserk") : DefDatabase <MentalStateDef> .GetNamed("Wander_Psychotic"));

                    /*string label = "MentalBreakAvertedLetterLabel".Translate() + ": " + stateDef.beginLetterLabel;
                     * string text = string.Format(stateDef.beginLetter, pawn.Label).AdjustedFor(pawn).CapitalizeFirst();
                     * if (reason != null)
                     * {
                     *  text = text + "\n\n" + "StraitjacketBenefit".Translate(new object[]
                     *  {
                     *  pawn.gender.GetPossessive(),
                     *  pawn.gender.GetObjective(),
                     *  pawn.gender.GetObjective() + "self"
                     *  });
                     * }
                     * Find.LetterStack.ReceiveLetter(label, text, stateDef.beginLetterDef, pawn, null);*/
                    Log.Message(pawn.Label + " was going to break, and the straitjacket averted it. Hiding the message.");
                    __result = new List <MentalBreakDef>();
                    return;
                }
                //StripStraitJacket
                if (pawn?.apparel?.WornApparel?.FirstOrDefault(x => x.def == StraitjacketDefOf.ROM_Straitjacket) is Apparel clothing)
                {
                    if (pawn?.apparel?.TryDrop(clothing, out Apparel droppedClothing, pawn.Position, true) != null)
                    {
                        Messages.Message("StraitjacketEscape".Translate(pawn.LabelCap), MessageTypeDefOf.ThreatBig);// MessageSound.SeriousAlert);
                        pawn.mindState.mentalStateHandler.TryStartMentalState(mentalBreakDef.mentalState, reason, false, true, null);
                        __result = new List <MentalBreakDef>();
                    }
                }
            }
        }
 internal static Pawn GetPawn(this MentalBreaker _this)
 {
     if (_MentalBreaker._pawn == null)
     {
         _MentalBreaker._pawn = typeof(MentalBreaker).GetField("pawn", BindingFlags.Instance | BindingFlags.NonPublic);
         if (_MentalBreaker._pawn == null)
         {
             Log.ErrorOnce("Unable to reflect MentalBreaker.pawn!", 215432421);
         }
     }
     return((Pawn)_MentalBreaker._pawn.GetValue(_this));
 }
 internal static Thought GetRandomMentalBreakReason(this MentalBreaker _this)
 {
     if (_MentalBreaker._randomMentalBreakReason == null)
     {
         _MentalBreaker._randomMentalBreakReason = typeof(MentalBreaker).GetField("RandomMentalBreakReason", BindingFlags.Instance | BindingFlags.NonPublic);
         if (_MentalBreaker._randomMentalBreakReason == null)
         {
             Log.ErrorOnce("Unable to reflect MentalBreaker.RandomMentalBreakReason!", 215432421);
         }
     }
     return((Thought)_MentalBreaker._randomMentalBreakReason.GetValue(_this));
 }
        internal static IEnumerable <MentalBreakDef> GetCurrentPossibleMoodBreaks(this MentalBreaker _this)
        {
            //if (_MentalBreaker._pawn == null)
            //{
            var result = typeof(MentalBreaker).GetProperty("CurrentPossibleMoodBreaks", BindingFlags.Instance | BindingFlags.NonPublic);

            //    if (_MentalBreaker._pawn == null)
            //    {
            //        Log.ErrorOnce("Unable to reflect MentalBreaker.pawn!", 215432421);
            //    }
            //}
            return((IEnumerable <MentalBreakDef>)result.GetValue(_this, null));
        }
        internal static bool GetCanDoRandomMentalBreaks(this MentalBreaker _this)
        {
            //if (_MentalBreaker._pawn == null)
            //{
            var result = typeof(MentalBreaker).GetProperty("CanDoRandomMentalBreaks", BindingFlags.Instance | BindingFlags.NonPublic);

            //    if (_MentalBreaker._pawn == null)
            //    {
            //        Log.ErrorOnce("Unable to reflect MentalBreaker.pawn!", 215432421);
            //    }
            //}
            return((bool)result.GetValue(_this, null));
        }
        internal static MentalBreakIntensity GetCurrentDesiredMoodBreakIntensity(this MentalBreaker _this)
        {
            //if (_MentalBreaker._pawn == null)
            //{
            var result = typeof(MentalBreaker).GetProperty("CurrentDesiredMoodBreakIntensity", BindingFlags.Instance | BindingFlags.NonPublic);

            //    if (_MentalBreaker._pawn == null)
            //    {
            //        Log.ErrorOnce("Unable to reflect MentalBreaker.pawn!", 215432421);
            //    }
            //}
            return((MentalBreakIntensity)result.GetValue(_this, null));
        }
 internal static bool IsWearingStraitJacket(this MentalBreaker _this)
 {
     if (_this.GetPawn().apparel != null)
     {
         foreach (Apparel clothing in _this.GetPawn().apparel.WornApparel)
         {
             if (clothing.def.defName == "Straitjacket")
             {
                 return(true);
             }
         }
     }
     return(false);
 }
        internal static void StripStraitJacket(this MentalBreaker _this)
        {
            Pawn pawn = _this.GetPawn();

            if (pawn.apparel != null)
            {
                Apparel        droppedClothing = null;
                List <Apparel> clothingList    = new List <Apparel>(pawn.apparel.WornApparel);
                foreach (Apparel clothing in clothingList)
                {
                    if (clothing.def.defName == "Straitjacket")
                    {
                        pawn.apparel.TryDrop(clothing, out droppedClothing, pawn.Position, true);
                    }
                }
            }
        }
Exemple #15
0
        private BreakLevelModel UpdateCache(Pawn pawn)
        {
            MentalBreaker breaker = pawn.mindState?.mentalBreaker;

            _cacheUsed = false;

            try
            {
                if (breaker is null)
                {
                    _backingField.MoodLevel      = MoodLevel.Undefined;
                    _backingField.CurInstanLevel =
                        _backingField.Minor      = _backingField.Major = _backingField.Extreme = 0;
                    return(_backingField);
                }
                else
                {
                    _backingField.Minor   = breaker.BreakThresholdMinor;
                    _backingField.Major   = breaker.BreakThresholdMajor;
                    _backingField.Extreme = breaker.BreakThresholdExtreme;
                    //_backingField.CurInstanLevel = CurInstantLevelThreadSafe();
                    //_curMoodLock.EnterWriteLock();
                    _backingField.CurInstanLevel = _backingField.Pawn.needs?.mood?.CurInstantLevel ?? 0;
                    //_curMoodLock.ExitWriteLock();
                    _backingField.MoodLevel        = this.GetMoodLevel(pawn);
                    _backingField.UpdateBarTexture = true;
                    return(_backingField);
                }
            }
            catch
            {
                HasUpdateException = true;
                if (_curMoodLock.IsWriteLockHeld)
                {
                    _curMoodLock.ExitWriteLock();
                }

                throw;
            }
        }
        internal static bool _TryDoRandomMoodCausedMentalBreak(this MentalBreaker _this)
        {
            if (!_this.CanDoRandomMentalBreaks() || _this.GetPawn().Downed || !_this.GetPawn().Awake())
            {
                return(false);
            }
            if (_this.GetPawn().Faction != Faction.OfPlayer && _this.CurrentDesiredMoodBreakIntensity() != MentalBreakIntensity.Extreme)
            {
                return(false);
            }
            MentalBreakDef mentalBreakDef;

            if (!_this.CurrentPossibleMoodBreaks().TryRandomElementByWeight((MentalBreakDef d) => d.Worker.CommonalityFor(_this.GetPawn()), out mentalBreakDef))
            {
                return(false);
            }

            int    intensity = (int)_this.CurrentDesiredMoodBreakIntensity();
            Hediff hediff    = _this.GetPawn().health.hediffSet.GetFirstHediffOfDef(HediffDefOfPsychology.Anxiety);

            if (hediff != null)
            {
                hediff.Severity += 0.15f - (intensity * 0.5f);
            }
            else if (Rand.Value <= (0.6f - (0.25f * intensity)))
            {
                hediff          = HediffMaker.MakeHediff(HediffDefOfPsychology.Anxiety, _this.GetPawn(), null);
                hediff.Severity = 0.75f - (intensity * 0.25f);
                _this.GetPawn().health.AddHediff(hediff, null, null);
            }

            var     RandomMentalBreakReason = typeof(MentalBreaker).GetMethod("RandomMentalBreakReason", BindingFlags.Instance | BindingFlags.NonPublic);
            Thought thought = (Thought)RandomMentalBreakReason.Invoke(_this, null);
            string  reason  = (thought == null) ? null : thought.LabelCap;

            _this.GetPawn().mindState.mentalStateHandler.TryStartMentalState(mentalBreakDef.mentalState, reason, false, true, null);
            return(true);
        }
Exemple #17
0
        //// to fix insect meat food priority
        //public static void ThoughtsFromIngesting_Postfix(Pawn ingester, ref List<FoodUtility.ThoughtFromIngesting> __result)
        //{
        //    if (ingester.kindDef.race.defName != "Ant_AntiniumRace")
        //    {
        //        return;
        //    }

        //    // AteInsectMeatAsIngredient
        //    if (__result.Contains(AteInsectMeatAsIngredient))
        //    {
        //        __result.Remove(ThoughtDefOf.AteInsectMeatAsIngredient);
        //        var ateInsectIngredient = DefDatabase<ThoughtDef>.GetNamed("Ant_AteInsectMeatAsIngredient");
        //        __result.Add(ateInsectIngredient);
        //    }

        //    // AteInsectMeatDirect
        //    else if (__result.Contains(ThoughtDefOf.AteInsectMeatDirect))
        //    {
        //        __result.Remove(ThoughtDefOf.AteInsectMeatDirect);
        //        var ateInsectDirect = DefDatabase<ThoughtDef>.GetNamed("Ant_AteInsectMeatDirect");
        //        __result.Add(ateInsectDirect);
        //    }
        //}


        public static void MentalBreak_Abberation_Postfix(MentalBreaker __instance, ref bool __result)
        {
            // Log.Message("aberration method fired");
            int.TryParse(
                "" + (byte)Traverse.Create(__instance).Property("CurrentDesiredMoodBreakIntensity")
                .GetValue <MentalBreakIntensity>(), out var intensity);
            // Log.Message("Mental break had an intensity of " + intensity);
            var pawn = Traverse.Create(__instance).Field("pawn").GetValue <Pawn>();

            if (pawn.kindDef.race.defName != "Ant_AntiniumRace" || !__result || intensity < 2)
            {
                return;
            }

            // Log.Message("it might be an aberration?");
            if (!Rand.Chance((intensity * .06f) - .1f))
            {
                return;
            }

            pawn.health.AddHediff(AntDefOf.Ant_Aberration);
            Find.LetterStack.ReceiveLetter("LetterLabelAberration".Translate(pawn),
                                           "LetterAberration".Translate(pawn), LetterDefOf.NegativeEvent);
        }
        // Verse.MentalBreaker

        /*
         *  PreFix
         *
         *  By calling this code first, we can check if the pawn involved is wearing a straitjacket.
         *  If the colonist is wearing a straitjacket, do not trigger a standard mental break.
         *  Instead, declare te mental break averted.
         *
         */
        public static bool TryDoRandomMoodCausedMentalBreakPreFix(MentalBreaker __instance)
        {
            //Declare variables for the process
            var pawn = (Pawn)AccessTools.Field(typeof(MentalBreaker), "pawn").GetValue(__instance);

            //IsWearingStraitJacket
            bool isWearingStraitJacket = false;

            if (pawn.apparel != null)
            {
                foreach (Apparel clothing in pawn.apparel.WornApparel)
                {
                    if (clothing.def == StraitjacketDefOf.ROM_Straitjacket)
                    {
                        isWearingStraitJacket = true;
                    }
                }
            }
            if (!isWearingStraitJacket)
            {
                return(true);
            }

            Thought thought = (Thought)AccessTools.Method(typeof(MentalBreaker), "RandomMentalBreakReason").Invoke(__instance, new object[] { });
            IEnumerable <MentalBreakDef> mentalBreaksList = (IEnumerable <MentalBreakDef>)AccessTools.Property(typeof(MentalBreaker), "CurrentPossibleMoodBreaks").GetValue(__instance, null);
            string reason = (thought == null) ? null : thought.LabelCap;

            //Reset the mind state because we probably tried to start something before this process started.
            pawn.mindState.mentalStateHandler.Reset();


            MentalBreakDef mentalBreakDef;

            if (!(mentalBreaksList.TryRandomElementByWeight((MentalBreakDef d) => d.Worker.CommonalityFor(pawn), out mentalBreakDef)))
            {
                return(false);
            }

            if (Rand.Range(0, 100) < 95) //95% of the time
            {
                Cthulhu.Utility.DebugReport("StraitJacket :: Mental Break Triggered");
                MentalStateDef stateDef = mentalBreakDef.mentalState;
                string         label    = "MentalBreakAvertedLetterLabel".Translate() + ": " + stateDef.beginLetterLabel;
                string         text     = string.Format(stateDef.beginLetter, pawn.Label).AdjustedFor(pawn).CapitalizeFirst();
                if (reason != null)
                {
                    text = text + "\n\n" + "StraitjacketBenefit".Translate(new object[]
                    {
                        pawn.gender.GetPossessive(),
                        pawn.gender.GetObjective(),
                        pawn.gender.GetObjective() + "self"
                    });
                }
                Find.LetterStack.ReceiveLetter(label, text, stateDef.beginLetterDef, pawn, null);
                return(false);
            }
            //StripStraitJacket
            if (pawn.apparel != null)
            {
                Apparel        droppedClothing = null;
                List <Apparel> clothingList    = new List <Apparel>(pawn.apparel.WornApparel);
                foreach (Apparel clothing in clothingList)
                {
                    if (clothing.def == StraitjacketDefOf.ROM_Straitjacket)
                    {
                        pawn.apparel.TryDrop(clothing, out droppedClothing, pawn.Position, true);
                    }
                }
            }
            Messages.Message("StraitjacketEscape".Translate(pawn.LabelCap), MessageTypeDefOf.ThreatBig);// MessageSound.SeriousAlert);

            pawn.mindState.mentalStateHandler.TryStartMentalState(mentalBreakDef.mentalState, reason, false, true, null);
            return(false);
        }
        internal static bool TryDoRandomMoodCausedMentalBreak(this MentalBreaker _this)
        {
            if (!_this.GetCanDoRandomMentalBreaks() || _this.GetPawn().Downed || !_this.GetPawn().Awake())
            {
                return(false);
            }

            if (_this.GetPawn().Faction != Faction.OfPlayer && _this.GetCurrentDesiredMoodBreakIntensity() != MentalBreakIntensity.Extreme)
            {
                return(false);
            }

            MentalBreakDef mentalBreakDef;

            if (!_this.GetCurrentPossibleMoodBreaks().TryRandomElementByWeight((MentalBreakDef d) => d.Worker.CommonalityFor(_this.GetPawn()), out mentalBreakDef))
            {
                Log.Message(_this.GetCurrentDesiredMoodBreakIntensity().ToString());
                foreach (MentalBreakDef def in _this.GetCurrentPossibleMoodBreaks())
                {
                    Log.Message(def.ToString());
                }
                return(false);
            }

            MethodInfo method = typeof(MentalBreaker).GetMethod("RandomMentalBreakReason", BindingFlags.Instance | BindingFlags.NonPublic);

            Thought thought = null;

            if (method != null)
            {
                thought = (Thought)method.Invoke(_this, new object[] { });
            }

            //if (temp != null) thought = (Thought)temp.GetValue(_this);



            string reason = (thought == null) ? null : thought.LabelCap;


            if (_this.IsWearingStraitJacket())
            {
                if (Rand.Range(0, 100) < 95) //95% of the time
                {
                    Cthulhu.Utility.DebugReport("StraitJacket :: Mental Break Triggered");
                    MentalStateDef stateDef = mentalBreakDef.mentalState;
                    string         label    = "MentalBreakAvertedLetterLabel".Translate() + ": " + stateDef.beginLetterLabel;
                    string         text     = string.Format(stateDef.beginLetter, _this.GetPawn().Label).AdjustedFor(_this.GetPawn()).CapitalizeFirst();
                    if (reason != null)
                    {
                        text = text + "\n\n" + "MentalBreakReason".Translate(new object[]
                        {
                            reason
                        });
                        text = text + "\n\n" + "StraitjacketBenefit".Translate(new object[]
                        {
                            _this.GetPawn().gender.GetPossessive(),
                            _this.GetPawn().gender.GetObjective(),
                            _this.GetPawn().gender.GetObjective() + "self"
                        });
                    }
                    Find.LetterStack.ReceiveLetter(label, text, stateDef.beginLetterType, _this.GetPawn(), null);
                    return(false);
                }
                _this.StripStraitJacket();
                Messages.Message(_this.GetPawn().LabelCap + " has escaped out of their straitjacket!", MessageSound.SeriousAlert);
            }
            _this.GetPawn().mindState.mentalStateHandler.TryStartMentalState(mentalBreakDef.mentalState, reason, false, true, null);
            return(true);
        }
Exemple #20
0
        private static void DrawNewMoodRect(Rect moodRect, Need_Mood mood, MentalBreaker mb)
        {
            if (mood != null && mb != null)
            {
                if (mood.CurLevelPercentage > mb.BreakThresholdMinor)
                {
                    if (ColBarSettings.MoodBarPos == Position.Alignment.Left || ColBarSettings.MoodBarPos == Position.Alignment.Right)
                    {
                        GUI.DrawTexture(moodRect.BottomPart(mood.CurLevelPercentage), ColonistBarTextures.MoodTex);
                    }
                    else
                    {
                        GUI.DrawTexture(moodRect.LeftPart(mood.CurLevelPercentage), ColonistBarTextures.MoodTex);
                    }
                }
                else if (mood.CurLevelPercentage > mb.BreakThresholdMajor)
                {
                    if (ColBarSettings.MoodBarPos == Position.Alignment.Left || ColBarSettings.MoodBarPos == Position.Alignment.Right)
                    {
                        GUI.DrawTexture(moodRect.BottomPart(mood.CurLevelPercentage), ColonistBarTextures.MoodMinorCrossedTex);
                    }
                    else
                    {
                        GUI.DrawTexture(moodRect.LeftPart(mood.CurLevelPercentage), ColonistBarTextures.MoodMinorCrossedTex);
                    }
                }
                else if (mood.CurLevelPercentage > mb.BreakThresholdExtreme)
                {
                    if (ColBarSettings.MoodBarPos == Position.Alignment.Left || ColBarSettings.MoodBarPos == Position.Alignment.Right)
                    {
                        GUI.DrawTexture(moodRect.BottomPart(mood.CurLevelPercentage), ColonistBarTextures.MoodMajorCrossedTex);
                    }
                    else
                    {
                        GUI.DrawTexture(moodRect.LeftPart(mood.CurLevelPercentage), ColonistBarTextures.MoodMajorCrossedTex);
                    }
                }
                else
                {
                    GUI.DrawTexture(moodRect, ColonistBarTextures.MoodExtremeCrossedBGTex);
                    if (ColBarSettings.MoodBarPos == Position.Alignment.Left || ColBarSettings.MoodBarPos == Position.Alignment.Right)
                    {
                        GUI.DrawTexture(moodRect.BottomPart(mood.CurLevelPercentage), ColonistBarTextures.MoodExtremeCrossedTex);
                    }
                    else
                    {
                        GUI.DrawTexture(moodRect.LeftPart(mood.CurLevelPercentage), ColonistBarTextures.MoodExtremeCrossedTex);
                    }
                }

                DrawMentalThreshold(moodRect, mb.BreakThresholdExtreme, mood.CurLevelPercentage);
                DrawMentalThreshold(moodRect, mb.BreakThresholdMajor, mood.CurLevelPercentage);
                DrawMentalThreshold(moodRect, mb.BreakThresholdMinor, mood.CurLevelPercentage);

                switch (ColBarSettings.MoodBarPos)
                {
                case Position.Alignment.Left:
                case Position.Alignment.Right:
                    GUI.DrawTexture(
                        new Rect(moodRect.x, moodRect.yMax - moodRect.height * mood.CurInstantLevelPercentage, moodRect.width,
                                 1), ColonistBarTextures.MoodTargetTex);
                    GUI.DrawTexture(
                        new Rect(moodRect.xMax + 1, moodRect.yMax - moodRect.height * mood.CurInstantLevelPercentage - 1, 2, 3),
                        ColonistBarTextures.MoodTargetTex);
                    break;

                case Position.Alignment.Top:
                    GUI.DrawTexture(
                        new Rect(moodRect.x + moodRect.width * mood.CurInstantLevelPercentage, moodRect.y, 1, moodRect.height),
                        ColonistBarTextures.MoodTargetTex);
                    GUI.DrawTexture(
                        new Rect(moodRect.x + moodRect.width * mood.CurInstantLevelPercentage - 1, moodRect.yMin - 1, 3, 2),
                        ColonistBarTextures.MoodTargetTex);
                    break;

                case Position.Alignment.Bottom:
                    GUI.DrawTexture(
                        new Rect(moodRect.x + moodRect.width * mood.CurInstantLevelPercentage, moodRect.y, 1, moodRect.height),
                        ColonistBarTextures.MoodTargetTex);
                    GUI.DrawTexture(
                        new Rect(moodRect.x + moodRect.width * mood.CurInstantLevelPercentage - 1, moodRect.yMax + 1, 3, 2),
                        ColonistBarTextures.MoodTargetTex);
                    break;
                }
            }
        }