Exemple #1
0
        public static bool KinseyException(ref TraitSet __instance, Trait trait)
        {
            Pawn pawn = Traverse.Create(__instance).Field("pawn").GetValue <Pawn>();
            Pawn_SexualityTracker ps = null;

            if (pawn.GetComp <CompPsychology>() != null && pawn.GetComp <CompPsychology>().isPsychologyPawn)
            {
                ps = pawn.GetComp <CompPsychology>().Sexuality;
            }
            if (ps != null && PsychologyBase.ActivateKinsey() && trait.def == TraitDefOf.Gay)
            {
                return(false);
            }
            if (ps != null && PsychologyBase.ActivateKinsey() && ps.romanticDrive < 0.5f)
            {
                if (trait.def == TraitDefOfPsychology.Codependent)
                {
                    return(false);
                }
            }
            if (ps != null && PsychologyBase.ActivateKinsey() && ps.sexDrive < 0.5f)
            {
                if (trait.def == TraitDefOfPsychology.Lecher)
                {
                    return(false);
                }
            }
            return(true);
        }
Exemple #2
0
        /// <summary>
        /// checks if the given pawn passes the restriction.
        /// </summary>
        /// <param name="pawn">The pawn.</param>
        /// <returns>
        /// if the def can be used with the given pawn
        /// </returns>
        /// <exception cref="ArgumentNullException">pawn</exception>
        protected override bool PassesRestrictionImpl(Pawn pawn)
        {
            if (pawn == null)
            {
                throw new ArgumentNullException(nameof(pawn));
            }
            TraitSet storyTraits = pawn.story?.traits;

            if (storyTraits == null)
            {
                return(false);
            }

            foreach (Entry entry in entries) //check all entries
            {
                var tInfo = storyTraits.GetTrait(entry.trait);
                if (tInfo == null)
                {
                    continue;
                }
                if (entry.traitDegree < 0)
                {
                    return(true);                       //if the entry has a traitDegree less then zero, this means any degree will pass
                }
                if (entry.traitDegree == tInfo.Degree)
                {
                    return(true);                                    //otherwise they must match
                }
            }

            return(false);
        }
Exemple #3
0
        // RimWorld.TraitSet
        public void LoseTrait(TraitSet traits, Trait trait)
        {
            if (!traits.HasTrait(trait.def))
            {
                Log.Warning(this.AbilityUser + " doesn't have trait " + trait.def);
                return;
            }

            traits.allTraits.Remove(trait);
            if (this.AbilityUser.workSettings != null)
            {
                this.AbilityUser.workSettings.EnableAndInitializeIfNotAlreadyInitialized();
            }

            // this.AbilityUser.story.Notify_TraitChanged();
            if (this.AbilityUser.skills != null)
            {
                this.AbilityUser.skills.Notify_SkillDisablesChanged();
            }

            if (!this.AbilityUser.Dead && this.AbilityUser.RaceProps.Humanlike)
            {
                this.AbilityUser.needs.mood.thoughts.situational.Notify_SituationalThoughtsDirty();
            }
        }
        /// <summary>
        ///     add the correct reversion thought at the correct stage
        /// </summary>
        /// <param name="spawned"></param>
        /// <param name="curStageIndex"></param>
        private void AddReversionThought(Pawn spawned, int curStageIndex)
        {
            TraitSet   traits = spawned.story.traits;
            ThoughtDef thoughtDef;
            var        hasPrimalWish = spawned.GetAspectTracker()?.Contains(AspectDefOf.PrimalWish) == true;

            if (hasPrimalWish)
            {
                thoughtDef = def.revertedPrimalWish ?? def.revertedThoughtBad; //substitute with the bad thought if null
            }
            else if (traits.HasTrait(PMTraitDefOf.MutationAffinity))
            {
                thoughtDef = def.revertedThoughtGood;
            }
            else if (traits.HasTrait(TraitDefOf.BodyPurist))
            {
                thoughtDef = def.revertedThoughtBad;
            }
            else
            {
                thoughtDef = Rand.Value > 0.5f ? def.revertedThoughtGood : def.revertedThoughtBad;
            }

            if (thoughtDef != null)
            {
                curStageIndex = Mathf.Min(curStageIndex, thoughtDef.stages.Count - 1); //avoid index out of bounds issues
                Thought_Memory mem = ThoughtMaker.MakeThought(thoughtDef, curStageIndex);
                spawned.TryGainMemory(mem);
            }
        }
Exemple #5
0
        public VampireRecord(Pawn originPawn, int originGeneration, BloodlineDef originBloodline, float originAge, string originSireId, Faction originFaction = null)
        {
            kindDef    = originPawn.kindDef;
            nameInt    = originPawn.Name;
            gender     = originPawn.gender;
            generation = originGeneration;
            bloodline  = originBloodline;
            age        = originAge;
            sireId     = originSireId;
            recordAge  = Find.TickManager.TicksGame;
            faction    = originFaction ?? Find.FactionManager.FirstFactionOfDef(VampDefOf.ROMV_LegendaryVampires);
            if (originPawn.story == null)
            {
                Log.Warning(originPawn.Name.ToStringFull + " has no story to copy.");
                return;
            }
            childhood = originPawn.story.childhood;
            adulthood = originPawn.story.adulthood;
            melanin   = originPawn.story.melanin;
            hairColor = originPawn.story.hairColor;
            crownType = originPawn.story.crownType;
            bodyType  = originPawn.story.bodyType;
            hairDef   = originPawn.story.hairDef;
            traits    = originPawn.story.traits;

            id = generation.ToString() + "_" + bloodline.ToString() + "_" + nameInt.ToStringFull + "_" + gender.ToString();
        }
Exemple #6
0
        /// <summary>
        /// add the correct reversion thought at the correct stage
        /// </summary>
        /// <param name="spawned">The spawned.</param>
        private void AddReversionThought(Pawn spawned)
        {
            TraitSet   traits = spawned.story.traits;
            ThoughtDef thoughtDef;
            var        hasPrimalWish = spawned.GetAspectTracker()?.Contains(AspectDefOf.PrimalWish) == true;

            if (hasPrimalWish)
            {
                thoughtDef = def.revertedPrimalWish ?? def.revertedThoughtBad; //substitute with the bad thought if null
            }
            else if (traits.HasTrait(PMTraitDefOf.MutationAffinity))
            {
                thoughtDef = def.revertedThoughtGood;
            }
            else if (traits.HasTrait(TraitDefOf.BodyPurist))
            {
                thoughtDef = def.revertedThoughtBad;
            }
            else
            {
                thoughtDef = Rand.Value > 0.5f ? def.revertedThoughtGood : def.revertedThoughtBad;
            }

            if (thoughtDef != null)
            {
                //TODO fix this with special memory for animalistic pawns
                Thought_Memory mem = ThoughtMaker.MakeThought(thoughtDef, 0);
                spawned.TryGainMemory(mem);
            }
        }
        // Token: 0x06000057 RID: 87 RVA: 0x000057F8 File Offset: 0x000039F8
        public static void ChkMSImmunisation(Pawn p, out string Reason, out bool Passed)
        {
            Reason = null;
            if (!p.RaceProps.Humanlike)
            {
                Passed = false;
                Reason = "MSExotic.NotHumanLike".Translate(p?.LabelShort.CapitalizeFirst());
                return;
            }
            TraitDef Immunity = DefDatabase <TraitDef> .GetNamed("Immunity", true);

            if (p.story.traits.HasTrait(Immunity) && p != null)
            {
                Pawn_StoryTracker story = p.story;
                int?num;
                if (story == null)
                {
                    num = null;
                }
                else
                {
                    TraitSet traits = story.traits;
                    num = ((traits != null) ? new int?(traits.GetTrait(Immunity).Degree) : null);
                }
                int?num2 = num;
                int num3 = 1;
                if (num2.GetValueOrDefault() == num3 & num2 != null)
                {
                    Passed = false;
                    Reason = "MSExotic.AlreadyHasImmunity".Translate(p?.LabelShort.CapitalizeFirst());
                    return;
                }
            }
            Passed = true;
        }
Exemple #8
0
        public static bool KinseyException(ref TraitSet __instance, Trait trait)
        {
            Pawn           pawn     = Traverse.Create(__instance).Field("pawn").GetValue <Pawn>();
            PsychologyPawn realPawn = pawn as PsychologyPawn;

            if (realPawn != null && PsychologyBase.ActivateKinsey() && trait.def == TraitDefOf.Gay)
            {
                return(false);
            }
            if (realPawn != null && PsychologyBase.ActivateKinsey() && realPawn.sexuality.romanticDrive < 0.5f)
            {
                if (trait.def == TraitDefOfPsychology.Codependent)
                {
                    return(false);
                }
            }
            if (realPawn != null && PsychologyBase.ActivateKinsey() && realPawn.sexuality.sexDrive < 0.5f)
            {
                if (trait.def == TraitDefOfPsychology.Lecher)
                {
                    return(false);
                }
            }
            return(true);
        }
Exemple #9
0
 public MudEntity(int id, string name = null)
 {
     Traits     = new TraitSet(id);
     Components = new ComponentSet(id);
     Name       = name ?? "-none-";
     Id         = id;
 }
Exemple #10
0
 public AiGEntity(int id, string name = null, int?parent = null)
 {
     Name       = name ?? "-none-";
     Id         = id;
     Traits     = new TraitSet(id);
     Components = new ComponentSet(id);
     Children   = new List <int>();
     Parent     = parent;
 }
Exemple #11
0
        public static void TouchColonistPersonalityDueToHope(Pawn pawn, MoodTraitChangeDirection type)
        {
            // determine if is colonist (contains trait)
            TraitSet pawnTraits = pawn.story?.traits;

            if (pawnTraits == null)
            {
                return;
            }

            // is colonist (contains traits)

            /*
             * Rules:
             * If promote, change the degree by +1, else by -1
             * If change to 0 and will have too few traits (<= 1), then idk, it be the colonists' problem
             */

            int naturalMoodTraitDegree = pawnTraits.DegreeOfTrait(TraitDefOf.NaturalMood);

            if (naturalMoodTraitDegree == 2 && type == MoodTraitChangeDirection.UPWARD)
            {
                return;
            }
            if (naturalMoodTraitDegree == -2 && type == MoodTraitChangeDirection.DOWNWARD)
            {
                return;
            }

            int targetMoodTraitDegree;

            if (type == MoodTraitChangeDirection.UPWARD)
            {
                targetMoodTraitDegree = naturalMoodTraitDegree + 1;
            }
            else
            {
                targetMoodTraitDegree = naturalMoodTraitDegree - 1;
            }

            if (targetMoodTraitDegree == 0)
            {
                pawnTraits.allTraits.RemoveAll((trait) => !trait.ScenForced && trait.def == TraitDefOf.NaturalMood);
            }
            else
            {
                // degree changes
                if (naturalMoodTraitDegree != 0)
                {
                    // need to remove then add anyway
                    pawnTraits.allTraits.RemoveAll((trait) => !trait.ScenForced && trait.def == TraitDefOf.NaturalMood);
                }
                // adding new trait
                pawnTraits.GainTrait(new Trait(TraitDefOf.NaturalMood, targetMoodTraitDegree));
            }
        }
        public static void RemoveTrait(this TraitSet traits, TraitDef traitDef)
        {
            var trait = traits.GetTrait(traitDef);

            if (trait == null)
            {
                return;
            }
            traits.allTraits.Remove(trait);
        }
 public static Trait GetTrait(this TraitSet traits, TraitDef traitDef)
 {
     foreach (var trait in traits.allTraits)
     {
         if (trait.def == traitDef)
         {
             return(trait);
         }
     }
     return(null);
 }
        // Token: 0x06000011 RID: 17 RVA: 0x00002878 File Offset: 0x00000A78
        public static void Postfix(TraitSet __instance, Trait trait, HashSet <string> TraitsForced, HashSet <string> TraitsBlocked)
        {
            string item  = string.Format("{0}_{1}", trait.def.defName, trait.Degree);
            bool   flag  = TraitsForced != null && TraitsForced.Contains(item);
            bool   flag2 = TraitsBlocked != null && TraitsBlocked.Contains(item);
            bool   flag3 = (flag || flag2) && __instance.HasTrait(trait.def);

            if (flag3)
            {
                __instance.allTraits.Remove(trait);
            }
        }
            public static bool Prefix(TraitSet __instance, Pawn ___pawn, Trait trait)
            {
                // If the trait in question is adrenaline-related and the pawn can't gain adrenaline, reject it
                Predicate <StatModifier> adrenalineStatModPredicate = (s) => s.stat == A_StatDefOf.AdrenalineProduction;

                if ((trait.def == A_TraitDefOf.AdrenalineJunkie || AffectsAdrenalineProduction(trait)) && !___pawn.CanGetAdrenaline())
                {
                    return(false);
                }

                return(true);
            }
Exemple #16
0
        public static void LoseTrait(this TraitSet traitSet, Trait trait)
        {
            Pawn pawn = (Pawn)typeof(TraitSet).GetField("pawn", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(traitSet);

            if (!traitSet.HasTrait(trait.def))
            {
                Log.Warning(pawn + " does not have trait " + trait.def);
                return;
            }
            traitSet.allTraits.Remove(trait);
            traitSet.ForceUpdate();
        }
Exemple #17
0
        public static void Postfix(TraitSet __instance, Trait trait, Pawn ___pawn)
        {
            bool flag = !Settings.SeparateGender || ___pawn.gender == Gender.Male;

            if (flag)
            {
                Patch_TraitSet_GainTrait_Internal.Postfix(__instance, trait, Settings.Male_TraitsForced, Settings.Male_TraitsBlocked);
            }
            else
            {
                Patch_TraitSet_GainTrait_Internal.Postfix(__instance, trait, Settings.Female_TraitsForced, Settings.Female_TraitsBlocked);
            }
        }
        // Token: 0x06000056 RID: 86 RVA: 0x0000571C File Offset: 0x0000391C
        public static void DoMSImmunisation(Pawn p, ThingDef t)
        {
            bool           Sickly   = false;
            MessageTypeDef MsgType  = MessageTypeDefOf.PositiveEvent;
            TraitDef       Immunity = DefDatabase <TraitDef> .GetNamed("Immunity", true);

            if (p.story.traits.HasTrait(Immunity) && p != null)
            {
                Pawn_StoryTracker story = p.story;
                int?num;
                if (story == null)
                {
                    num = null;
                }
                else
                {
                    TraitSet traits = story.traits;
                    num = ((traits != null) ? new int?(traits.GetTrait(Immunity).Degree) : null);
                }
                int?num2 = num;
                int num3 = -1;
                if (num2.GetValueOrDefault() == num3 & num2 != null)
                {
                    Sickly = true;
                }
            }
            if (Sickly)
            {
                Pawn_StoryTracker story2 = p.story;
                Trait             trait;
                if (story2 == null)
                {
                    trait = null;
                }
                else
                {
                    TraitSet traits2 = story2.traits;
                    trait = (traits2?.GetTrait(Immunity));
                }
                Trait ToGo = trait;
                MSTraitChanger.RemoveTrait(p, ToGo, t.label, MsgType, true);
                return;
            }
            Trait ToAdd = new Trait(Immunity, 1, false);

            MSTraitChanger.AddTrait(p, ToAdd, t.label, MsgType, true);
        }
        // Token: 0x06000058 RID: 88 RVA: 0x000058E0 File Offset: 0x00003AE0
        public static void DoMSCerebrax(Pawn p, ThingDef t)
        {
            int            degree  = 0;
            MessageTypeDef MsgType = MessageTypeDefOf.PositiveEvent;
            TraitDef       Psych   = DefDatabase <TraitDef> .GetNamed("PsychicSensitivity", true);

            if (p.story.traits.HasTrait(Psych))
            {
                degree = p.story.traits.GetTrait(Psych).Degree;
            }
            if (degree == 2)
            {
                Pawn_StoryTracker story = p.story;
                Trait             trait;
                if (story == null)
                {
                    trait = null;
                }
                else
                {
                    TraitSet traits = story.traits;
                    trait = (traits?.GetTrait(Psych));
                }
                Trait ToGo = trait;
                MSTraitChanger.RemoveTrait(p, ToGo, t.label, MsgType, true);
                Trait ToAdd = new Trait(Psych, 1, false);
                MSTraitChanger.AddTrait(p, ToAdd, t.label, MsgType, false);
                return;
            }
            if (degree == 1)
            {
                Pawn_StoryTracker story2 = p.story;
                Trait             trait2;
                if (story2 == null)
                {
                    trait2 = null;
                }
                else
                {
                    TraitSet traits2 = story2.traits;
                    trait2 = (traits2?.GetTrait(Psych));
                }
                Trait ToGo2 = trait2;
                MSTraitChanger.RemoveTrait(p, ToGo2, t.label, MsgType, true);
            }
        }
Exemple #20
0
        private float FactorInRecipientTraits(Pawn recipient, float initialValue)
        {
            // Factor recipient traits
            TraitSet recipientTraits = recipient.story.traits;

            foreach (Pair <string, float> traitFactor in recipientTraitFactors)
            {
                if (recipientTraits.allTraits.Any(trait => trait.def.defName == traitFactor.First))
                {
                    initialValue *= traitFactor.Second;

                    Logger.AddToMessage("    recipient - {0}: {1}", traitFactor.First, traitFactor.Second);
                }
            }

            return(initialValue);
        }
Exemple #21
0
        private float FactorInInitiatorTraits(Pawn initiator, float initialValue)
        {
            // Factor initiator traits
            TraitSet initiatorTraits = initiator.story.traits;

            foreach (Pair <string, float> traitFactor in initiatorTraitFactors)
            {
                if (initiatorTraits.allTraits.Any(trait => trait.def.defName == traitFactor.First))
                {
                    initialValue *= traitFactor.Second;

                    Logger.AddToMessage("    initiator - {0}: {1}", traitFactor.First, traitFactor.Second);
                }
            }

            return(initialValue);
        }
Exemple #22
0
 public virtual void Initialize()
 {
     ResourceTable = new List <Resource>();
     Root          = new ResourceSet <Resource>("Root", null);
     modifierInfos = new ModifierInfos();
     modifierInfos.Load(modifiersFile);
     Attributes         = new Database.Attributes(Root);
     BuildingAttributes = new BuildingAttributes(Root);
     CritterAttributes  = new CritterAttributes(Root);
     effects            = new ResourceSet <Effect>("Effects", Root);
     traits             = new TraitSet();
     traitGroups        = new TraitGroupSet();
     FertilityModifiers = new FertilityModifiers();
     Amounts            = new Database.Amounts();
     Amounts.Load();
     AttributeConverters = new Database.AttributeConverters();
     LoadEffects();
     LoadFertilityModifiers();
 }
        private static void TransferTraits([NotNull] IEnumerable <Pawn> originalPawns, [NotNull] Pawn mergedPawn)
        {
            TraitSet mTraits = mergedPawn.story?.traits;

            if (mTraits == null)
            {
                return;
            }

            var traits = new List <TraitDef>();

            foreach (Pawn originalPawn in originalPawns)
            {
                List <Trait> pTraits = originalPawn.story?.traits?.allTraits;
                if (pTraits == null)
                {
                    continue;
                }
                foreach (Trait pTrait in pTraits)
                {
                    if (traits.Contains(pTrait.def) || !FormerHumanUtilities.MutationTraits.Contains(pTrait.def))
                    {
                        continue;
                    }
                    traits.Add(pTrait.def);
                }
            }

            //check for split mind
            if (traits.Contains(PMTraitDefOf.MutationAffinity) && traits.Contains(TraitDefOf.BodyPurist))
            {
                traits.Remove(PMTraitDefOf.MutationAffinity);
                traits.Remove(TraitDefOf.BodyPurist);

                AspectTracker at = mergedPawn.GetAspectTracker();
                at?.Add(AspectDefOf.SplitMind);
            }

            foreach (TraitDef traitDef in traits)
            {
                mTraits.GainTrait(new Trait(traitDef, 0, true));
            }
        }
Exemple #24
0
        public static void ForceUpdate(this TraitSet traitSet)
        {
            Pawn pawn = (Pawn)typeof(TraitSet).GetField("pawn", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(traitSet);

            if (pawn.workSettings != null)
            {
                pawn.workSettings.Notify_GainedTrait();
            }
            //pawn.story.Notify_TraitChanged();
            typeof(Pawn_StoryTracker).GetMethod("Notify_TraitChanged", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(pawn.story, null);

            if (pawn.skills != null)
            {
                pawn.skills.Notify_SkillDisablesChanged();
            }
            if (!pawn.Dead && pawn.RaceProps.Humanlike)
            {
                pawn.needs.mood.thoughts.situational.Notify_SituationalThoughtsDirty();
            }
        }
        /// <summary>
        /// Checks if the pawn has any traits that block the given aspect
        /// </summary>
        /// <param name="traitSet">The trait set.</param>
        /// <param name="testAspect">The test aspect.</param>
        /// <returns>if given trait set is valid for the given aspect</returns>
        protected bool CheckPawnTraits([NotNull] TraitSet traitSet, [NotNull] AspectDef testAspect)
        {
            foreach (TraitDef traitDef in testAspect.requiredTraits.MakeSafe())
            {
                if (!traitSet.HasTrait(traitDef))
                {
                    return(false);
                }
            }

            foreach (var traitDef in testAspect.conflictingTraits.MakeSafe())
            {
                if (traitSet.HasTrait(traitDef))
                {
                    return(false);
                }
            }

            return(true);
        }
Exemple #26
0
        void RemoveAllOutlooks()
        {
            var asTracker = Pawn.GetAspectTracker();

            if (asTracker == null)
            {
                return;
            }

            if (asTracker.Contains(AspectDefOf.PrimalWish))
            {
                asTracker.Remove(AspectDefOf.PrimalWish);
            }

            var story = Pawn.story;

            TraitSet storyTraits = story?.traits;

            storyTraits?.allTraits?.RemoveAll(t => t.def == TraitDefOf.BodyPurist || t.def == PMTraitDefOf.MutationAffinity);
        }
        // Token: 0x06000059 RID: 89 RVA: 0x000059B0 File Offset: 0x00003BB0
        public static void ChkMSCerebrax(Pawn p, out string Reason, out bool Passed)
        {
            Reason = null;
            if (!p.RaceProps.Humanlike)
            {
                Passed = false;
                Reason = "MSExotic.NotHumanLike".Translate(p?.LabelShort.CapitalizeFirst());
                return;
            }
            TraitDef Psych = DefDatabase <TraitDef> .GetNamed("PsychicSensitivity", true);

            if (p.story.traits.HasTrait(Psych))
            {
                if (p != null)
                {
                    Pawn_StoryTracker story = p.story;
                    int?num;
                    if (story == null)
                    {
                        num = null;
                    }
                    else
                    {
                        TraitSet traits = story.traits;
                        num = ((traits != null) ? new int?(traits.GetTrait(Psych).Degree) : null);
                    }
                    int?num2 = num;
                    int num3 = 0;
                    if (num2.GetValueOrDefault() <= num3 & num2 != null)
                    {
                        Passed = false;
                        Reason = "MSExotic.HasNoPsychSensitivity".Translate(p?.LabelShort.CapitalizeFirst());
                        return;
                    }
                }
                Passed = true;
                return;
            }
            Passed = false;
            Reason = "MSExotic.HasNoPsychSensitivity".Translate(p?.LabelShort.CapitalizeFirst());
        }
        // Must be a Prefix because we need to not do anything if the trait is already present
        public static bool Prefix(TraitSet __instance, Trait trait)
        {
            if (__instance.HasTrait(trait.def))
            {
                return(true);
            }
            var collection = trait.def.GetModExtension <GMT_Trait_ModExtension>()?.appliedHediffs ?? null;

            if (collection != null)
            {
                foreach (HediffDef def in collection)
                {
                    if (fieldinfo_pawn == null)
                    {
                        fieldinfo_pawn = typeof(TraitSet).GetField("pawn", BindingFlags.Instance | BindingFlags.NonPublic);
                    }
                    (fieldinfo_pawn.GetValue(__instance) as Pawn).health.AddHediff(def);
                }
            }
            return(true);
        }
        private float FactorInFightingBackTraits(Pawn pawn, float initialValue)
        {
            TraitSet traits = pawn.story.traits;

            Logger.StartMessage(this, "{0} base fightback chance = {1}", pawn, initialValue);

            foreach (Pair <string, float> traitFactor in fightBackTraitFactors)
            {
                if (traits.allTraits.Any(trait => trait.def.defName == traitFactor.First))
                {
                    initialValue *= traitFactor.Second;

                    Logger.AddToMessage("{0} *= {1}", traitFactor.First, traitFactor.Second);
                }
            }

            Logger.AddToMessage("Final fightback chance = {0}", initialValue);
            Logger.DisplayMessage();

            return(initialValue);
        }
        private void UpdateUI()
        {
            int p = _human.wishManager.lifetimeSatisfactionPoints;

            this.Text.text = p.ToString();
            bool enoughForMajor = false;
            bool enoughForMinor = false;

            if (p != 0)
            {
                //If we already have it but it's a "negative" trait and we have enough points to remove it or
                //   we don't have it and it's a positive trait with a value higher than 1
                enoughForMajor = _human.traitSet.traits.Any(x => p >= TraitSet.GetTraitCost(x) && TraitSet.GetTraitPoints(x) > 0) ||
                                 TraitSet.changableTraits.Any(x => !_human.traitSet.HasTrait(x) && TraitSet.TraitAllowed(x, _human.traitSet.traits) && p >= TraitSet.GetTraitCost(x) && TraitSet.GetTraitPoints(x) < -1);

                //If we don't already have it and it's a positive trait
                if (!enoughForMajor)
                {
                    enoughForMinor = TraitSet.changableTraits.Any(x => !_human.traitSet.HasTrait(x) && TraitSet.TraitAllowed(x, _human.traitSet.traits) && p >= TraitSet.GetTraitCost(x) && TraitSet.GetTraitPoints(x) < 0);
                }
            }

            if (enoughForMajor)
            {
                this.Image.color = new Color(0.302f, 0.784f, 0.392f); //green
            }
            else if (enoughForMinor)
            {
                this.Image.color = new Color(0.800f, 0.800f, 0f); //yellow
            }
            else
            {
                this.Image.color = new Color(0.783f, 0.303f, 0.303f); //red
            }
            this.Tooltip.Init(Localization.GetText("witchy_UIImprovements_satisfactionTooltip_Title"),
                              String.Format(Localization.GetText("witchy_UIImprovements_satisfactionTooltip_Desc"), _human.firstName, p));
        }