// Plundered and adapted from Psychology
        public override float RandomSelectionWeight(Pawn initiator, Pawn recipient)
        {
            if (!GRPawnRelationUtility.HasInformalRelationship(initiator, recipient) && !LovePartnerRelationUtility.LovePartnerRelationExists(initiator, recipient))
            {
                return(0f);
            }
            else if (initiator.story.traits.HasTrait(TraitDefOfPsychology.Codependent))
            {
                return(0f);
            }
            float chance         = 0.02f * GradualRomanceMod.BaseBreakupChance;
            float romanticFactor = 1f;

            if (PsycheHelper.PsychologyEnabled(initiator))
            {
                chance         = 0.05f * GradualRomanceMod.BaseBreakupChance;
                romanticFactor = Mathf.InverseLerp(1.05f, 0f, PsycheHelper.Comp(initiator).Psyche.GetPersonalityRating(PersonalityNodeDefOf.Romantic));
            }
            float opinionFactor = Mathf.InverseLerp(100f, -100f, (float)initiator.relations.OpinionOf(recipient));
            float spouseFactor  = 1f;

            if (initiator.relations.DirectRelationExists(PawnRelationDefOf.Spouse, recipient))
            {
                spouseFactor = 0.4f;
            }
            return(chance * romanticFactor * opinionFactor * spouseFactor);
        }
示例#2
0
        // Plundered and adapted from Psychology
        public override float RandomSelectionWeight(Pawn initiator, Pawn recipient)
        {
            if (!RelationshipUtility.HasInformalRelationship(initiator, recipient) && !LovePartnerRelationUtility.LovePartnerRelationExists(initiator, recipient))
            {
                return(0f);
            }
            else if (initiator.story.traits.HasTrait(TraitDefOfPsychology.Codependent))
            {
                return(0f);
            }
            float chance         = 0.02f * GradualRomanceMod.BaseBreakupChance;
            float romanticFactor = 1f;

            if (PsycheHelper.PsychologyEnabled(initiator))
            {
                chance         = 0.05f * GradualRomanceMod.BaseBreakupChance;
                romanticFactor = Mathf.InverseLerp(1.05f, 0f, PsycheHelper.Comp(initiator).Psyche.GetPersonalityRating(PersonalityNodeDefOf.Romantic));
            }
            float           opinionFactor = Mathf.InverseLerp(100f, -100f, (float)initiator.relations.OpinionOf(recipient));
            float           spouseFactor  = 1f;
            PawnRelationDef relation      = RelationshipUtility.MostAdvancedRelationshipBetween(initiator, recipient);

            spouseFactor = relation.GetModExtension <RomanticRelationExtension>().baseAffairReluctance;
            float justificationFactor = 0.75f;

            if (BreakupUtility.HasReasonForBreakup(initiator, recipient))
            {
                justificationFactor = 2f;
            }
            return(chance * romanticFactor * opinionFactor * spouseFactor * justificationFactor);
        }
示例#3
0
        public static float PropensityToBeSeduced(Pawn pawn)
        {
            float propensity = 1f;

            if (pawn.story.traits.HasTrait(TraitDefOfPsychology.Lecher))
            {
                propensity *= 1.5f;
            }
            if (pawn.story.traits.HasTrait(TraitDefOfPsychology.Prude))
            {
                propensity *= 0.5f;
            }
            if (pawn.story.traits.HasTrait(TraitDefOfPsychology.Codependent))
            {
                propensity *= 0.75f;
            }
            if (pawn.story.traits.HasTrait(TraitDefOfGR.Shy))
            {
                propensity *= 2f;
            }
            if (PsycheHelper.PsychologyEnabled(pawn))
            {
                CompPsychology comp = PsycheHelper.Comp(pawn);
                propensity *= comp.Psyche.GetPersonalityRating(PersonalityNodeDefOfGR.Adventurous) + 0.5f;
                propensity *= 1.5f - comp.Psyche.GetPersonalityRating(PersonalityNodeDefOfGR.Confident);
                propensity *= 1.5f - comp.Psyche.GetPersonalityRating(PersonalityNodeDefOf.Pure);
                propensity *= comp.Sexuality.AdjustedSexDrive;
            }
            return(propensity);
        }
示例#4
0
        public static bool NewGRFormula(ref float __result, Pawn pawn)
        {
            float num = 1f;

            num /= 1f - pawn.health.hediffSet.PainTotal;
            float level = pawn.health.capacities.GetLevel(PawnCapacityDefOf.Consciousness);

            if (level < 0.5f)
            {
                num /= level * 2f;
            }
            float sexDriveFactor;

            if (PsycheHelper.PsychologyEnabled(pawn))
            {
                sexDriveFactor = PsycheHelper.Comp(pawn).Sexuality.AdjustedSexDrive;
            }
            else
            {
                sexDriveFactor = GenMath.FlatHill(0f, 0.75f, 1f, 2f, 3f, 0.2f, AgeCalculationUtility.GetMaturity(pawn));
            }

            __result = num / sexDriveFactor;

            return(false);
        }
        public override void GiveThoughts(Pawn initiator, Pawn recipient, out List <RulePackDef> yetMoreSentencePacks)
        {
            yetMoreSentencePacks = new List <RulePackDef> {
            };
            float interpretChance = 1f;

            if (PsycheHelper.PsychologyEnabled(initiator))
            {
                interpretChance *= 0.5f + PsycheHelper.Comp(initiator).Psyche.GetPersonalityRating(PersonalityNodeDefOfGR.Optimistic);
                interpretChance *= 0.5f + Mathf.Abs(1 - PsycheHelper.Comp(initiator).Psyche.GetPersonalityRating(PersonalityNodeDefOf.Empathetic));
                interpretChance  = Mathf.InverseLerp(0.50f, 2f, interpretChance);
            }
            else
            {
                interpretChance = 0.5f;
            }

            if (Rand.Value < interpretChance)
            {
                yetMoreSentencePacks.Add(RulePackDefOfGR.Sentence_InterpretFlirtPositively);
                initiator.needs.mood.thoughts.memories.TryGainMemory(ThoughtDefOfGR.RomanticTension, recipient);
            }
            else
            {
                initiator.needs.mood.thoughts.memories.TryGainMemory(ThoughtDefOfGR.RomanticDisinterest, recipient);
            }
        }
        public static bool NewSelectionWeight(InteractionWorker_Breakup __instance, ref float __result, Pawn initiator, Pawn recipient)
        {
            /* Also this one. */
            if (!LovePartnerRelationUtility.LovePartnerRelationExists(initiator, recipient))
            {
                __result = 0f;
                return(false);
            }
            else if (initiator.story.traits.HasTrait(TraitDefOfPsychology.Codependent))
            {
                __result = 0f;
                return(false);
            }
            float chance         = 0.02f;
            float romanticFactor = 1f;

            if (PsycheHelper.PsychologyEnabled(initiator))
            {
                chance         = 0.05f;
                romanticFactor = Mathf.InverseLerp(1.05f, 0f, PsycheHelper.Comp(initiator).Psyche.GetPersonalityRating(PersonalityNodeDefOf.Romantic));
            }
            float opinionFactor = Mathf.InverseLerp(100f, -100f, (float)initiator.relations.OpinionOf(recipient));
            float spouseFactor  = 1f;

            if (initiator.relations.DirectRelationExists(PawnRelationDefOf.Spouse, recipient))
            {
                spouseFactor = 0.4f;
            }
            __result = chance * romanticFactor * opinionFactor * spouseFactor;
            return(false);
        }
示例#7
0
 public static bool IsExclusivelyGynephilic(Pawn pawn)
 {
     if (PsycheHelper.PsychologyEnabled(pawn) && PsychologyBase.ActivateKinsey())
     {
         int kinsey = PsycheHelper.Comp(pawn).Sexuality.kinseyRating;
         if (pawn.gender == Gender.Female && kinsey == 6)
         {
             return(true);
         }
         if (pawn.gender == Gender.Male && kinsey == 0)
         {
             return(true);
         }
     }
     else
     {
         if (pawn.gender == Gender.Female && pawn.story.traits.HasTrait(TraitDefOf.Gay))
         {
             return(true);
         }
         if (pawn.gender == Gender.Male && pawn.story.traits.HasTrait(TraitDefOf.Gay) == false)
         {
             return(true);
         }
     }
     return(false);
 }
示例#8
0
 public static bool KinseyException(ref Pawn pawn, PawnGenerationRequest request)
 {
     if (PsycheHelper.PsychologyEnabled(pawn))
     {
         if (PsychologyBase.ActivateKinsey())
         {
             while (PsycheHelper.Comp(pawn).Sexuality.kinseyRating > 2 && !request.AllowGay)
             {
                 PsycheHelper.Comp(pawn).Sexuality.GenerateSexuality();
             }
             if (LovePartnerRelationUtility.HasAnyLovePartnerOfTheSameGender(pawn) || LovePartnerRelationUtility.HasAnyExLovePartnerOfTheSameGender(pawn))
             {
                 while (PsycheHelper.Comp(pawn).Sexuality.kinseyRating < 2)
                 {
                     PsycheHelper.Comp(pawn).Sexuality.GenerateSexuality();
                 }
             }
             else if (LovePartnerRelationUtility.HasAnyLovePartnerOfTheOppositeGender(pawn) || LovePartnerRelationUtility.HasAnyExLovePartnerOfTheOppositeGender(pawn))
             {
                 while (PsycheHelper.Comp(pawn).Sexuality.kinseyRating > 4)
                 {
                     PsycheHelper.Comp(pawn).Sexuality.GenerateSexuality();
                 }
             }
         }
     }
     return(true);
 }
 public static float PersonalityChance(Pawn pawn)
 {
     if (PsycheHelper.PsychologyEnabled(pawn))
     {
         return(1f - PsycheHelper.Comp(pawn).Psyche.GetPersonalityNodeOfDef(PersonalityNodeDefOf.Aggressive).AdjustedRating);
     }
     return(0.5f);
 }
示例#10
0
 public static bool IsAsexual(Pawn pawn)
 {
     if (PsycheHelper.PsychologyEnabled(pawn))
     {
         return(PsycheHelper.Comp(pawn).Sexuality.AdjustedSexDrive < 0.01f);
     }
     return(false);
 }
 public static bool LearnSexuality(Pawn initiator, Pawn recipient)
 {
     if (PsycheHelper.PsychologyEnabled(initiator) && PsycheHelper.PsychologyEnabled(recipient) && PsychologyBase.ActivateKinsey())
     {
         PsycheHelper.Comp(initiator).Sexuality.LearnSexuality(recipient);
     }
     return(true);
 }
示例#12
0
        public static void PsychologyFormula(ref float __result, Pawn generated, Pawn other, PawnGenerationRequest request, bool ex)
        {
            /* Throw away the existing result and substitute our own formula. */
            float sexualityFactor = 1f;

            if (PsycheHelper.PsychologyEnabled(generated) && PsycheHelper.PsychologyEnabled(other) && PsychologyBase.ActivateKinsey())
            {
                float kinsey  = 3 - PsycheHelper.Comp(generated).Sexuality.kinseyRating;
                float kinsey2 = 3 - PsycheHelper.Comp(other).Sexuality.kinseyRating;
                float h**o    = (generated.gender == other.gender) ? 1f : -1f;
                sexualityFactor *= Mathf.InverseLerp(3f, 0f, kinsey * h**o);
                sexualityFactor *= Mathf.InverseLerp(3f, 0f, kinsey2 * h**o);
            }
            else
            {
                sexualityFactor = (generated.gender != other.gender) ? 1f : 0.01f;
            }
            float existingExLoverFactor = 1f;

            if (ex)
            {
                int exLovers = 0;
                List <DirectPawnRelation> directRelations = other.relations.DirectRelations;
                for (int i = 0; i < directRelations.Count; i++)
                {
                    if (LovePartnerRelationUtility.IsExLovePartnerRelation(directRelations[i].def))
                    {
                        exLovers++;
                    }
                }
                existingExLoverFactor = Mathf.Pow(0.2f, (float)exLovers);
            }
            else if (LovePartnerRelationUtility.HasAnyLovePartner(other))
            {
                __result = 0f;
                return;
            }
            float generationChanceAgeFactor    = Traverse.Create(typeof(LovePartnerRelationUtility)).Method("GetGenerationChanceAgeFactor", new[] { typeof(Pawn) }).GetValue <float>(new object[] { generated });
            float generationChanceAgeFactor2   = Traverse.Create(typeof(LovePartnerRelationUtility)).Method("GetGenerationChanceAgeFactor", new[] { typeof(Pawn) }).GetValue <float>(new object[] { other });
            float generationChanceAgeGapFactor = Traverse.Create(typeof(LovePartnerRelationUtility)).Method("GetGenerationChanceAgeGapFactor", new[] { typeof(Pawn), typeof(Pawn), typeof(bool) }).GetValue <float>(new object[] { generated, other, ex });
            float incestFactor = 1f;

            if (generated.GetRelations(other).Any((PawnRelationDef x) => x.familyByBloodRelation))
            {
                incestFactor = 0.01f;
            }
            float melaninFactor;

            if (request.FixedMelanin.HasValue)
            {
                melaninFactor = ChildRelationUtility.GetMelaninSimilarityFactor(request.FixedMelanin.Value, other.story.melanin);
            }
            else
            {
                melaninFactor = PawnSkinColors.GetMelaninCommonalityFactor(other.story.melanin);
            }
            __result = existingExLoverFactor * sexualityFactor * generationChanceAgeFactor * generationChanceAgeFactor2 * generationChanceAgeGapFactor * incestFactor * melaninFactor;
        }
 public static void NewFormula(ref float __result, Pawn initiator, Pawn recipient)
 {
     if (PsycheHelper.PsychologyEnabled(initiator))
     {
         SimpleCurve opinionCurve = Traverse.Create(typeof(NegativeInteractionUtility)).Field("CompatibilityFactorCurve").GetValue <SimpleCurve>();
         __result /= opinionCurve.Evaluate(initiator.relations.CompatibilityWith(recipient));
         __result *= 2f * PsycheHelper.Comp(initiator).Psyche.GetPersonalityRating(PersonalityNodeDefOf.Aggressive);
     }
 }
示例#14
0
 public static bool WouldConsiderFormalRelationship(Pawn pawn, Pawn other)
 {
     if (PsycheHelper.PsychologyEnabled(pawn) && PsychologyBase.ActivateKinsey())
     {
         if (other.gender == Gender.Male)
         {
             int kinsey = PsycheHelper.Comp(pawn).Sexuality.kinseyRating;
             if (pawn.gender == Gender.Female && kinsey >= 5)
             {
                 return(false);
             }
             if (pawn.gender == Gender.Male && kinsey <= 1)
             {
                 return(false);
             }
         }
         else
         {
             int kinsey = PsycheHelper.Comp(pawn).Sexuality.kinseyRating;
             if (pawn.gender == Gender.Female && kinsey <= 1)
             {
                 return(false);
             }
             if (pawn.gender == Gender.Male && kinsey >= 5)
             {
                 return(false);
             }
         }
     }
     else
     {
         if (other.gender == Gender.Male)
         {
             if (pawn.gender == Gender.Female && pawn.story.traits.HasTrait(TraitDefOf.Gay))
             {
                 return(false);
             }
             if (pawn.gender == Gender.Male && pawn.story.traits.HasTrait(TraitDefOf.Gay) == false)
             {
                 return(false);
             }
         }
         else
         {
             if (pawn.gender == Gender.Male && pawn.story.traits.HasTrait(TraitDefOf.Gay))
             {
                 return(false);
             }
             if (pawn.gender == Gender.Female && pawn.story.traits.HasTrait(TraitDefOf.Gay) == false)
             {
                 return(false);
             }
         }
     }
     return(true);
 }
示例#15
0
 public static bool IsWeaklyBisexual(Pawn pawn)
 {
     if (PsycheHelper.PsychologyEnabled(pawn) && PsychologyBase.ActivateKinsey())
     {
         int kinsey = PsycheHelper.Comp(pawn).Sexuality.kinseyRating;
         if (kinsey == 1 || kinsey == 5)
         {
             return(true);
         }
     }
     return(false);
 }
        public override float RandomSelectionWeight(Pawn initiator, Pawn recipient)
        {
            //Don't hit on people in mental breaks... unless you're really freaky.
            if (recipient.InMentalState && PsycheHelper.PsychologyEnabled(initiator) && PsycheHelper.Comp(initiator).Psyche.GetPersonalityRating(PersonalityNodeDefOf.Experimental) < 0.8f)
            {
                return(0f);
            }
            //Pawns will only ask their girlfriend/boyfriend to move in
            if (!initiator.relations.DirectRelationExists(PawnRelationDefOfGR.Lovefriend, recipient))
            {
                return(0f);
            }
            if (!AttractionUtility.WouldConsiderFormalRelationship(initiator, recipient))
            {
                return(0f);
            }
            if (!AttractionUtility.QuickCheck(initiator, recipient))
            {
                return(0f);
            }
            EmptyReasons();
            float attractiveness = AttractionUtility.CalculateAttraction(initiator, recipient, false, true, out veryLowInitiatorReasons, out lowInitiatorReasons, out highInitiatorReasons, out veryHighInitiatorReasons, out AttractionFactorDef reasonForInstantFailure);

            if (attractiveness == 0f)
            {
                return(0f);
            }

            float romanceChance = GradualRomanceMod.BaseRomanceChance;

            if (!PsycheHelper.PsychologyEnabled(initiator))
            {
                //Vanilla: Straight women are 15% as likely to romance anyone.
                romanceChance *= (!initiator.story.traits.HasTrait(TraitDefOf.Gay)) ? ((initiator.gender != Gender.Female) ? romanceChance : romanceChance * 0.15f) : romanceChance;
            }
            else
            {
                //Psychology: A pawn's likelihood to ask to move in.
                float personalityFactor = Mathf.Pow(12f, (1f - PsycheHelper.Comp(initiator).Psyche.GetPersonalityRating(PersonalityNodeDefOf.Romantic)));
                romanceChance *= personalityFactor * 0.02f;
            }
            //If their potential partner wouldn't consider a relationship with them, they're less likely to try and hit on them. But it doesn't put them off that much.
            if (AttractionUtility.WouldConsiderFormalRelationship(recipient, initiator))
            {
                romanceChance *= 0.2f;
            }

            lastInitiator = initiator;
            lastRecipient = recipient;

            return(romanceChance * attractiveness);
        }
        public static void AddBrokeUpOpinion(Pawn lover, Pawn ex)
        {
            ThoughtDef brokeUpDef = new ThoughtDef();

            brokeUpDef.defName      = "BrokeUpWithMe" + lover.LabelShort + Find.TickManager.TicksGame;
            brokeUpDef.durationDays = 40f;
            brokeUpDef.thoughtClass = typeof(Thought_MemorySocialDynamic);
            ThoughtStage brokeUpStage = new ThoughtStage();

            brokeUpStage.label             = "broke up with me";
            brokeUpStage.baseOpinionOffset = Mathf.RoundToInt(-50f * PsycheHelper.Comp(lover).Psyche.GetPersonalityRating(PersonalityNodeDefOf.Romantic) * Mathf.InverseLerp(5f, 100f, lover.relations.OpinionOf(ex)));
            brokeUpDef.stages.Add(brokeUpStage);
            lover.needs.mood.thoughts.memories.TryGainMemory(brokeUpDef, ex);
        }
示例#18
0
        public static void CancelJob(ref Job __result, Pawn pawn)
        {
            Pawn partner = LovePartnerRelationUtility.GetPartnerInMyBed(pawn);

            if (PsycheHelper.PsychologyEnabled(pawn) && PsycheHelper.PsychologyEnabled(partner) && PsychologyBase.ActivateKinsey())
            {
                float random  = Rand.ValueSeeded((pawn.GetHashCode() ^ (GenLocalDate.DayOfYear(pawn) + GenLocalDate.Year(pawn) + (int)(GenLocalDate.DayPercent(pawn) * 2) * 60) * 391));
                float random2 = Rand.ValueSeeded((pawn.GetHashCode() ^ (GenLocalDate.DayOfYear(partner) + GenLocalDate.Year(partner) + (int)(GenLocalDate.DayPercent(partner) * 2) * 60) * 391));
                if (random > PsycheHelper.Comp(pawn).Sexuality.AdjustedSexDrive&& random2 > PsycheHelper.Comp(partner).Sexuality.AdjustedSexDrive)
                {
                    __result = null;
                }
            }
        }
示例#19
0
 public SaveRecordPsycheV4(Pawn pawn)
 {
     if (PsycheHelper.PsychologyEnabled(pawn))
     {
         nodes      = PsycheHelper.Comp(pawn).Psyche.PersonalityNodes;
         upbringing = PsycheHelper.Comp(pawn).Psyche.upbringing;
         if (PsychologyBase.ActivateKinsey())
         {
             sexDrive      = PsycheHelper.Comp(pawn).Sexuality.sexDrive;
             romanticDrive = PsycheHelper.Comp(pawn).Sexuality.romanticDrive;
             kinseyRating  = PsycheHelper.Comp(pawn).Sexuality.kinseyRating;
         }
     }
 }
示例#20
0
 public override bool Check(Pawn observer, Pawn assessed)
 {
     if (assessed.gender != Gender.Female)
     {
         return(false);
     }
     if (PsychologyBase.ActivateKinsey() && PsycheHelper.PsychologyEnabled(observer))
     {
         if (PsycheHelper.Comp(observer).Sexuality.kinseyRating == 3)
         {
             return(false);
         }
     }
     return(true);
 }
示例#21
0
        public static void TryAddCheaterThought(Pawn pawn, Pawn cheater, Pawn cheaterLover)
        {
            {
                if (pawn.Dead)
                {
                    return;
                }
                if (RelationshipUtility.IsPolygamist(pawn))
                {
                    pawn.needs.mood.thoughts.memories.TryGainMemory(ThoughtDefOfGR.CheatedOnMePolygamist, cheater);
                }
                else
                {
                    float toleranceChance = 0.4f;
                    //people who are codependent are more tolerant of cheating, even though they are less likely to cheat
                    if (pawn.story.traits.HasTrait(TraitDefOfPsychology.Codependent))
                    {
                        toleranceChance *= 2f;
                    }
                    //moralistic characters are less tolerant of cheating.
                    if (PsycheHelper.PsychologyEnabled(pawn))
                    {
                        toleranceChance *= (1.5f - PsycheHelper.Comp(pawn).Psyche.GetPersonalityRating(PersonalityNodeDefOfGR.Moralistic));
                    }
                    //they are more likely to tolerate cheating if they like the person who the cheater is cheating with.
                    toleranceChance *= Mathf.Min(0f, Mathf.InverseLerp(-80f, 30f, pawn.relations.OpinionOf(cheaterLover)));
                    toleranceChance  = Mathf.Clamp01(toleranceChance);

                    if (Rand.Value < toleranceChance)
                    {
                        pawn.needs.mood.thoughts.memories.TryGainMemory(ThoughtDefOfGR.CheatedOnMeTolerated, cheater);
                    }
                    else
                    {
                        if (pawn.relations.OpinionOf(cheaterLover) >= 30f)
                        {
                            pawn.needs.mood.thoughts.memories.TryGainMemory(ThoughtDefOfGR.CheatedOnMeHighOpinion, cheater);
                        }
                        else
                        {
                            pawn.needs.mood.thoughts.memories.TryGainMemory(ThoughtDefOf.CheatedOnMe, cheater);
                        }
                    }
                    pawn.needs.mood.thoughts.memories.TryGainMemory(ThoughtDefOfGR.LoversLover, cheaterLover);
                    //cheaterLover.needs.mood.thoughts.memories.TryGainMemory(ThoughtDefOfGR.LoversLover, pawn);
                }
            }
        }
 internal static void _RandomSelectionWeight(InteractionWorker_MarriageProposal __instance, ref float __result, Pawn initiator, Pawn recipient)
 {
     if (PsycheHelper.PsychologyEnabled(initiator))
     {
         if (initiator.gender == Gender.Female)
         {
             /* Undo the effect of this in the postfixed method. */
             __result /= 0.2f;
         }
         __result *= 0.1f + PsycheHelper.Comp(initiator).Psyche.GetPersonalityRating(PersonalityNodeDefOf.Aggressive) + PsycheHelper.Comp(initiator).Psyche.GetPersonalityRating(PersonalityNodeDefOf.Romantic);
         if (PsychologyBase.ActivateKinsey())
         {
             __result *= PsycheHelper.Comp(initiator).Sexuality.AdjustedRomanticDrive;
         }
     }
 }
示例#23
0
        protected override ThoughtState CurrentStateInternal(Pawn pawn)
        {
            if (PsycheHelper.PsychologyEnabled(pawn) && PsychologyBase.ActivateKinsey())
            {
                if (PsycheHelper.Comp(pawn).Sexuality.kinseyRating >= 2)
                {
                    return(ThoughtState.ActiveAtStage(0));
                }

                return(false);
            }
            if (pawn.story.traits.HasTrait(TraitDefOf.Gay))
            {
                return(ThoughtState.ActiveAtStage(0));
            }
            return(false);
        }
示例#24
0
        public static bool IsWeaklyGynephilic(Pawn pawn)
        {
            if (PsycheHelper.PsychologyEnabled(pawn) && PsychologyBase.ActivateKinsey())
            {
                int kinsey = PsycheHelper.Comp(pawn).Sexuality.kinseyRating;
                if (pawn.gender == Gender.Female && kinsey == 1)
                {
                    return(true);
                }
                if (pawn.gender == Gender.Male && kinsey == 5)
                {
                    return(true);
                }
            }

            return(false);
        }
        public static void NewSuccessChance(ref float __result, Pawn initiator, Pawn recipient)
        {
            /* Throw out the result and replace it with our own formula. */
            float successChance = 0.6f;

            if (PsycheHelper.PsychologyEnabled(recipient))
            {
                //The recipient is less likely to accept the more romantic they are, which means they will need to like the person more.
                successChance = 0.25f + (1f - PsycheHelper.Comp(recipient).Psyche.GetPersonalityRating(PersonalityNodeDefOf.Romantic));
            }
            successChance *= recipient.relations.SecondaryRomanceChanceFactor(initiator);
            successChance *= 2f * Mathf.InverseLerp(-5f, 100f, (float)recipient.relations.OpinionOf(initiator));
            float existingLovePartnerFactor = 1f;

            if (!recipient.story.traits.HasTrait(TraitDefOfPsychology.Polygamous))
            {
                Pawn pawn = null;
                if (recipient.relations.GetFirstDirectRelationPawn(PawnRelationDefOf.Lover, (Pawn x) => !x.Dead) != null)
                {
                    pawn = recipient.relations.GetFirstDirectRelationPawn(PawnRelationDefOf.Lover, null);
                    existingLovePartnerFactor = (recipient.story.traits.HasTrait(TraitDefOfPsychology.Codependent)) ? 0f : 0.6f;
                }
                else if (recipient.relations.GetFirstDirectRelationPawn(PawnRelationDefOf.Fiance, (Pawn x) => !x.Dead) != null)
                {
                    pawn = recipient.relations.GetFirstDirectRelationPawn(PawnRelationDefOf.Fiance, null);
                    existingLovePartnerFactor = (recipient.story.traits.HasTrait(TraitDefOfPsychology.Codependent)) ? 0f : 0.1f;
                }
                else if (recipient.GetSpouse() != null && !recipient.GetSpouse().Dead)
                {
                    pawn = recipient.GetSpouse();
                    existingLovePartnerFactor = (recipient.story.traits.HasTrait(TraitDefOfPsychology.Codependent)) ? 0f : 0.3f;
                }
                if (pawn != null)
                {
                    existingLovePartnerFactor *= Mathf.InverseLerp(100f, 0f, (float)recipient.relations.OpinionOf(pawn));
                    existingLovePartnerFactor *= Mathf.Clamp01(1f - recipient.relations.SecondaryRomanceChanceFactor(pawn));
                }
            }
            if (recipient.story.traits.HasTrait(TraitDefOfPsychology.Lecher))
            {
                existingLovePartnerFactor = 1.916f;
            }
            successChance *= existingLovePartnerFactor;
            __result       = Mathf.Clamp01(successChance);
        }
        protected override ThoughtState CurrentSocialStateInternal(Pawn pawn, Pawn other)
        {
            if (!other.RaceProps.Humanlike || !RelationsUtility.PawnsKnowEachOther(pawn, other))
            {
                return(false);
            }

            if (PsycheHelper.PsychologyEnabled(other) && PsychologyBase.ActivateKinsey())
            {
                if (PsycheHelper.Comp(other).Sexuality.kinseyRating >= 2)
                {
                    return(ThoughtState.ActiveAtStage(0));
                }
            }
            else if (other.story.traits.HasTrait(TraitDefOf.Gay))
            {
                return(ThoughtState.ActiveAtStage(0));
            }
            return(false);
        }
示例#27
0
        public static void PlanFuneral(Building_Grave __instance, Pawn worker)
        {
            Pawn planner;

            (from c in worker.Map.mapPawns.FreeColonistsSpawned
             where c.relations.OpinionOf(__instance.Corpse.InnerPawn) >= 20
             select c).TryRandomElementByWeight((c) => Mathf.Max(0f, c.relations.OpinionOf(__instance.Corpse.InnerPawn) - (PsycheHelper.PsychologyEnabled(c) ? 100f * (1f - PsycheHelper.Comp(c).Psyche.GetPersonalityRating(PersonalityNodeDefOf.Nostalgic)) : 0f)), out planner);
            if (planner != null && PsycheHelper.PsychologyEnabled(__instance.Corpse.InnerPawn) && !PsycheHelper.Comp(__instance.Corpse.InnerPawn).AlreadyBuried)
            {
                Func <int, float> timeAssignmentFactor = delegate(int h)
                {
                    if (planner.timetable.GetAssignment(h) == TimeAssignmentDefOf.Joy)
                    {
                        return(1.25f);
                    }
                    if (planner.timetable.GetAssignment(h) == TimeAssignmentDefOf.Anything)
                    {
                        return(0.9f);
                    }
                    return(0f);
                };
                int hour = -1;
                if (Enumerable.Range(0, GenDate.HoursPerDay).TryRandomElementByWeight(h => timeAssignmentFactor(h), out hour))
                {
                    int date       = Find.TickManager.TicksGame + Mathf.RoundToInt(GenDate.TicksPerDay * (2f + (PsycheHelper.PsychologyEnabled(planner) ? 3f - (5f * PsycheHelper.Comp(planner).Psyche.GetPersonalityRating(PersonalityNodeDefOf.Spontaneous)) : 0f)));
                    int currentDay = GenDate.DayOfYear(GenDate.TickGameToAbs(date), Find.WorldGrid.LongLatOf(planner.Map.Tile).x);
                    if (currentDay <= GenLocalDate.DayOfYear(planner.Map) && GenDate.HourOfDay(GenDate.TickGameToAbs(date), Find.WorldGrid.LongLatOf(planner.Map.Tile).x) > hour)
                    {
                        date += GenDate.TicksPerDay * (currentDay - GenLocalDate.DayOfYear(planner.Map));
                    }
                    Hediff_Funeral planFuneral = HediffMaker.MakeHediff(HediffDefOfPsychology.PlannedFuneral, planner) as Hediff_Funeral;
                    planFuneral.date  = date;
                    planFuneral.hour  = hour;
                    planFuneral.day   = GenDate.DayOfYear(GenDate.TickGameToAbs(date), Find.WorldGrid.LongLatOf(planner.Map.Tile).x);
                    planFuneral.grave = __instance;
                    planFuneral.spot  = __instance.Position;
                    planner.health.AddHediff(planFuneral);
                    PsycheHelper.Comp(__instance.Corpse.InnerPawn).AlreadyBuried = true;
                }
            }
        }
示例#28
0
 public static void AddPsyche(ref EdB.PrepareCarefully.CustomPawn __result, EdB.PrepareCarefully.SaveRecordPawnV4 record)
 {
     if (SaveRecordPawnV4Patch.savedPawns.Keys.Contains(record))
     {
         Pawn pawn = __result.Pawn;
         if (pawn != null && PsycheHelper.PsychologyEnabled(pawn))
         {
             PrepareCarefully.SaveRecordPsycheV4 psycheSave = SaveRecordPawnV4Patch.savedPawns[record];
             PsycheHelper.Comp(pawn).Psyche.upbringing = psycheSave.upbringing;
             foreach (PersonalityNode node in PsycheHelper.Comp(pawn).Psyche.PersonalityNodes)
             {
                 PersonalityNode savedNode = psycheSave.NodeDict[node.def];
                 if (savedNode != null)
                 {
                     node.rawRating = savedNode.rawRating;
                 }
             }
             PsycheHelper.Comp(pawn).Sexuality.sexDrive      = psycheSave.sexDrive;
             PsycheHelper.Comp(pawn).Sexuality.romanticDrive = psycheSave.romanticDrive;
             PsycheHelper.Comp(pawn).Sexuality.kinseyRating  = psycheSave.kinseyRating;
         }
     }
 }
示例#29
0
        public static bool ShouldImplicitlyEndInformalRelationship(Pawn pawn, Pawn other, PawnRelationDef relation)
        {
            if (CanDecay(pawn, other, relation))
            {
                return(true);
            }
            if (RelationshipUtility.IsPolygamist(pawn))
            {
                return(false);
            }

            float chance = Mathf.InverseLerp(80, -20, AttractionUtility.GetRelationshipUnmodifiedOpinion(pawn, other));

            chance *= (relation.GetModExtension <RomanticRelationExtension>().relationshipLevel / (relation.GetModExtension <RomanticRelationExtension>().relationshipLevel + 1));
            if (PsycheHelper.PsychologyEnabled(pawn))
            {
                chance *= Mathf.Lerp(0f, 2f, PsycheHelper.Comp(pawn).Psyche.GetPersonalityRating(PersonalityNodeDefOfGR.Moralistic));
            }
            if (Rand.Value < chance)
            {
                return(true);
            }
            return(false);
        }
示例#30
0
 public override float Calculate(Pawn observer, Pawn assessed)
 {
     return(PsycheHelper.Comp(observer).Sexuality.AdjustedSexDrive);
 }