コード例 #1
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;
            PsychologyPawn realGenerated   = generated as PsychologyPawn;
            PsychologyPawn realOther       = other as PsychologyPawn;

            if (PsychologyBase.ActivateKinsey() && realGenerated != null && realOther != null && realGenerated.sexuality != null && realOther.sexuality != null)
            {
                float kinsey  = 3 - realGenerated.sexuality.kinseyRating;
                float kinsey2 = 3 - realOther.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;
        }
コード例 #2
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);
        }
コード例 #3
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);
 }
コード例 #4
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);
 }
コード例 #5
0
 public static void AddPsyche(ref EdB.PrepareCarefully.CustomPawn __result, EdB.PrepareCarefully.SaveRecordPawnV3 record)
 {
     if (SaveRecordPawnV3Patch.savedPawns.Keys.Contains(record))
     {
         Pawn pawn = __result.Pawn;
         if (pawn != null && pawn is PsychologyPawn)
         {
             PrepareCarefully.SaveRecordPsycheV3 psycheSave = SaveRecordPawnV3Patch.savedPawns[record];
             PsychologyPawn realPawn = pawn as PsychologyPawn;
             realPawn.psyche.upbringing = psycheSave.upbringing;
             foreach (PersonalityNode node in realPawn.psyche.PersonalityNodes)
             {
                 PersonalityNode savedNode = psycheSave.nodes.Find(n => n.def == node.def);
                 if (savedNode != null)
                 {
                     node.rawRating = savedNode.rawRating;
                 }
             }
             if (PsychologyBase.ActivateKinsey())
             {
                 realPawn.sexuality.sexDrive      = psycheSave.sexDrive;
                 realPawn.sexuality.romanticDrive = psycheSave.romanticDrive;
                 realPawn.sexuality.kinseyRating  = psycheSave.kinseyRating;
             }
         }
     }
 }
コード例 #6
0
ファイル: TraitSet.cs プロジェクト: skyarkhangel/Psychology
        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);
        }
コード例 #7
0
        public static void DrawSocialCard(Rect rect, Pawn pawn)
        {
            GUI.BeginGroup(rect);
            Text.Font = GameFont.Small;
            Rect rect2 = new Rect(0f, 20f, rect.width, rect.height - 20f);
            Rect rect3 = rect2.ContractedBy(10f);
            Rect rect4 = rect3;
            Rect rect5 = rect3;
            Rect rect7 = rect3;

            rect4.height *= 0.63f;
            rect5.y       = rect4.yMax + 17f;
            rect5.yMax    = rect3.yMax;
            GUI.color     = new Color(1f, 1f, 1f, 0.5f);
            Widgets.DrawLineHorizontal(0f, (rect4.yMax + rect5.y) / 2f, rect.width);
            GUI.color = Color.white;
            if (Prefs.DevMode)
            {
                Rect rect6 = new Rect(5f, 5f, rect.width, 22f);
                typeof(SocialCardUtility).GetMethod("DrawDebugOptions", BindingFlags.Static | BindingFlags.NonPublic).Invoke(null, new object[] { rect6, pawn });
            }
            if (PsychologyBase.ActivateKinsey() && pawn is PsychologyPawn && ((PsychologyPawn)pawn).sexuality != null)
            {
                DrawKinseyValue(rect7, pawn);
            }
            SocialCardUtility.DrawRelationsAndOpinions(rect4, pawn);
            typeof(SocialCardUtility).GetMethod("DrawInteractionsLog", BindingFlags.Static | BindingFlags.NonPublic).Invoke(null, new object[] { rect5, pawn });
            GUI.EndGroup();
        }
コード例 #8
0
        public static bool KinseyException(ref Pawn pawn, PawnGenerationRequest request)
        {
            PsychologyPawn newPawn = pawn as PsychologyPawn;

            if (newPawn != null)
            {
                newPawn.psyche.Initialize();
                if (PsychologyBase.ActivateKinsey())
                {
                    while (newPawn.sexuality.kinseyRating > 2 && !request.AllowGay)
                    {
                        newPawn.sexuality.GenerateSexuality();
                    }
                    if (LovePartnerRelationUtility.HasAnyLovePartnerOfTheSameGender(pawn) || LovePartnerRelationUtility.HasAnyExLovePartnerOfTheSameGender(pawn))
                    {
                        while (newPawn.sexuality.kinseyRating < 2)
                        {
                            newPawn.sexuality.GenerateSexuality();
                        }
                    }
                    else if (LovePartnerRelationUtility.HasAnyLovePartnerOfTheOppositeGender(pawn) || LovePartnerRelationUtility.HasAnyExLovePartnerOfTheOppositeGender(pawn))
                    {
                        while (newPawn.sexuality.kinseyRating > 4)
                        {
                            newPawn.sexuality.GenerateSexuality();
                        }
                    }
                    pawn = newPawn;
                }
            }
            return(true);
        }
コード例 #9
0
 public static bool KinseyException(ref Pawn __result, Pawn generatedChild, Pawn existingChild, Gender genderToGenerate, PawnGenerationRequest childRequest, bool newlyGeneratedParentsWillBeSpousesIfNotGay)
 {
     if (PsychologyBase.ActivateKinsey())
     {
         //TODO: Turn this into a transpiler instead of a prefix.
         float ageChronologicalYearsFloat  = generatedChild.ageTracker.AgeChronologicalYearsFloat;
         float ageChronologicalYearsFloat2 = existingChild.ageTracker.AgeChronologicalYearsFloat;
         float num  = (genderToGenerate != Gender.Male) ? 16f : 14f;
         float num2 = (genderToGenerate != Gender.Male) ? 45f : 50f;
         float num3 = (genderToGenerate != Gender.Male) ? 27f : 30f;
         float num4 = Mathf.Max(ageChronologicalYearsFloat, ageChronologicalYearsFloat2) + num;
         float maxChronologicalAge = num4 + (num2 - num);
         float midChronologicalAge = num4 + (num3 - num);
         var   parameters          = new object[] { num4, maxChronologicalAge, midChronologicalAge, num, generatedChild, existingChild, childRequest, null, null, null, null };
         Traverse.Create(typeof(PawnRelationWorker_Sibling)).Method("GenerateParentParams", new Type[] { typeof(float), typeof(float), typeof(float), typeof(float), typeof(Pawn), typeof(Pawn), typeof(PawnGenerationRequest), typeof(float).MakeByRefType(), typeof(float).MakeByRefType(), typeof(float).MakeByRefType(), typeof(string).MakeByRefType() }).GetValue(parameters);
         float          value    = (float)parameters[7];
         float          value2   = (float)parameters[8];
         float          value3   = (float)parameters[9];
         string         last     = (string)parameters[10];
         bool           allowGay = true;
         PsychologyPawn parent   = null;
         if (genderToGenerate == Gender.Male && existingChild.GetMother() != null)
         {
             parent = existingChild.GetMother() as PsychologyPawn;
         }
         else if (genderToGenerate == Gender.Female && existingChild.GetFather() != null)
         {
             parent = existingChild.GetFather() as PsychologyPawn;
         }
         if (parent != null)
         {
             float kinsey = 3 - parent.sexuality.kinseyRating;
             float num5   = Mathf.InverseLerp(3f, 0f, -kinsey);
             if (newlyGeneratedParentsWillBeSpousesIfNotGay && last.NullOrEmpty() && Rand.Value < num5)
             {
                 last     = ((NameTriple)parent.Name).Last;
                 allowGay = false;
             }
         }
         Faction faction = existingChild.Faction;
         if (faction == null || faction.IsPlayer)
         {
             bool tryMedievalOrBetter = faction != null && faction.def.techLevel >= TechLevel.Medieval;
             Find.FactionManager.TryGetRandomNonColonyHumanlikeFaction(out faction, tryMedievalOrBetter, true);
         }
         Gender?fixedGender            = new Gender?(genderToGenerate);
         float? fixedMelanin           = new float?(value3);
         string fixedLastName          = last;
         PawnGenerationRequest request = new PawnGenerationRequest(existingChild.kindDef, faction, PawnGenerationContext.NonPlayer, -1, true, false, true, true, false, false, 1f, false, allowGay, true, false, false, null, new float?(value), new float?(value2), fixedGender, fixedMelanin, fixedLastName);
         Pawn pawn = PawnGenerator.GeneratePawn(request);
         if (!Find.WorldPawns.Contains(pawn))
         {
             Find.WorldPawns.PassToWorld(pawn, PawnDiscardDecideMode.KeepForever);
         }
         __result = pawn;
         return(false);
     }
     return(true);
 }
コード例 #10
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);
 }
コード例 #11
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);
 }
コード例 #12
0
 public static bool LearnSexuality(Pawn initiator, Pawn recipient)
 {
     if (PsychologyBase.ActivateKinsey())
     {
         PsychologyPawn realInitiator = initiator as PsychologyPawn;
         PsychologyPawn realRecipient = recipient as PsychologyPawn;
         if (realInitiator != null && realRecipient != null)
         {
             realInitiator.sexuality.LearnSexuality(realRecipient);
         }
     }
     return(true);
 }
コード例 #13
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;
         }
     }
 }
コード例 #14
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);
 }
コード例 #15
0
        public static void CancelJob(ref Job __result, Pawn pawn)
        {
            Pawn           partnerInMyBed = LovePartnerRelationUtility.GetPartnerInMyBed(pawn);
            PsychologyPawn realPawn       = pawn as PsychologyPawn;
            PsychologyPawn realPartner    = partnerInMyBed as PsychologyPawn;

            if (realPawn != null && realPartner != null && PsychologyBase.ActivateKinsey() && realPawn.sexuality != null && realPartner.sexuality != null)
            {
                float random = Rand.ValueSeeded((pawn.GetHashCode() ^ (GenLocalDate.DayOfYear(pawn) + GenLocalDate.Year(pawn) + (int)(GenLocalDate.DayPercent(pawn) * 2) * 60) * 391));
                if (random > realPawn.sexuality.AdjustedSexDrive && random > realPartner.sexuality.AdjustedSexDrive)
                {
                    __result = null;
                }
            }
        }
コード例 #16
0
 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;
         }
     }
 }
コード例 #17
0
        public SaveRecordPsycheV3(Pawn pawn)
        {
            PsychologyPawn realPawn = pawn as PsychologyPawn;

            if (realPawn != null)
            {
                nodes      = realPawn.psyche.PersonalityNodes;
                upbringing = realPawn.psyche.upbringing;
                if (PsychologyBase.ActivateKinsey())
                {
                    sexDrive      = realPawn.sexuality.sexDrive;
                    romanticDrive = realPawn.sexuality.romanticDrive;
                    kinseyRating  = realPawn.sexuality.kinseyRating;
                }
            }
        }
コード例 #18
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);
        }
コード例 #19
0
 public static bool PsychologyException(InteractionWorker_MarriageProposal __instance, ref float __result, Pawn initiator, Pawn recipient)
 {
     if (recipient.GetComp <CompPsychology>() != null && recipient.GetComp <CompPsychology>().isPsychologyPawn)
     {
         float num = 1.2f;
         num *= Mathf.InverseLerp(0f, 0.75f, recipient.GetComp <CompPsychology>().Psyche.GetPersonalityRating(PersonalityNodeDefOf.Romantic));
         if (PsychologyBase.ActivateKinsey())
         {
             num *= recipient.GetComp <CompPsychology>().Sexuality.AdjustedRomanticDrive;
         }
         num     *= Mathf.Clamp01(GenMath.LerpDouble(-20f, 60f, 0f, 1f, (float)recipient.relations.OpinionOf(initiator)));
         __result = Mathf.Clamp01(num);
         return(false);
         /* If the recipient is a PsychologyPawn, the mod takes over AcceptanceChance for them and the normal method will be ignored. */
     }
     return(true);
 }
コード例 #20
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);
        }
コード例 #21
0
 public static void CreatePsychologyComponents(Pawn pawn)
 {
     if (pawn.RaceProps.Humanlike)
     {
         PsychologyPawn realPawn = pawn as PsychologyPawn;
         if (PsychologyBase.ActivateKinsey())
         {
             if (realPawn != null)
             {
                 realPawn.sexuality = new Pawn_SexualityTracker(realPawn);
             }
         }
         if (realPawn != null)
         {
             realPawn.psyche = new Pawn_PsycheTracker(realPawn);
         }
     }
 }
コード例 #22
0
 public static void KinseyFactor(ref float __result, Pawn father, Pawn mother, Pawn child)
 {
     /* Kinsey-enabled pawns shouldn't have the Gay trait, so we can just apply the sexuality modifier here. */
     if (father != null && child != null && child.GetFather() == null)
     {
         PsychologyPawn realFather = father as PsychologyPawn;
         if (PsychologyBase.ActivateKinsey() && realFather != null)
         {
             __result *= Mathf.InverseLerp(6f, 0f, realFather.sexuality.kinseyRating);
         }
     }
     if (mother != null && child != null && child.GetMother() == null)
     {
         PsychologyPawn realMother = mother as PsychologyPawn;
         if (PsychologyBase.ActivateKinsey() && realMother != null)
         {
             __result *= Mathf.InverseLerp(6f, 0f, realMother.sexuality.kinseyRating);
         }
     }
 }
        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);
        }
コード例 #24
0
ファイル: PanelBackstory.cs プロジェクト: XNoNameX/Psychology
        public static void AddPsycheEditButton(EdB.PrepareCarefully.PanelBackstory __instance, EdB.PrepareCarefully.State state)
        {
            Rect           panelRect = __instance.PanelRect;
            PsychologyPawn pawn      = state.CurrentPawn.Pawn as PsychologyPawn;

            if (pawn != null)
            {
                if (pawn.psyche == null || pawn.psyche.PersonalityNodes == null)
                {
                    pawn.psyche = new Pawn_PsycheTracker(pawn);
                    pawn.psyche.Initialize();
                    foreach (PersonalityNode node in pawn.psyche.PersonalityNodes)
                    {
                        if (node.rawRating < 0)
                        {
                            node.Initialize();
                        }
                    }
                }
                if (pawn.sexuality == null && PsychologyBase.ActivateKinsey())
                {
                    pawn.sexuality = new Pawn_SexualityTracker(pawn);
                    pawn.sexuality.GenerateSexuality();
                }
                Rect rect = new Rect(panelRect.width - 60f, 9f, 22f, 22f);
                if (rect.Contains(Event.current.mousePosition))
                {
                    GUI.color = new Color(0.97647f, 0.97647f, 0.97647f);
                }
                else
                {
                    GUI.color = new Color(0.623529f, 0.623529f, 0.623529f);
                }
                GUI.DrawTexture(rect, ContentFinder <Texture2D> .Get("Buttons/ButtonPsyche", true));
                if (Widgets.ButtonInvisible(rect, false))
                {
                    SoundDefOf.TickLow.PlayOneShotOnCamera(null);
                    Find.WindowStack.Add(new Dialog_EditPsyche(pawn));
                }
            }
        }
コード例 #25
0
 internal static void _CreateInitialComponents(Pawn pawn)
 {
     pawn.ageTracker   = new Pawn_AgeTracker(pawn);
     pawn.health       = new Pawn_HealthTracker(pawn);
     pawn.records      = new Pawn_RecordsTracker(pawn);
     pawn.inventory    = new Pawn_InventoryTracker(pawn);
     pawn.meleeVerbs   = new Pawn_MeleeVerbs(pawn);
     pawn.verbTracker  = new VerbTracker(pawn);
     pawn.carryTracker = new Pawn_CarryTracker(pawn);
     pawn.needs        = new Pawn_NeedsTracker(pawn);
     pawn.mindState    = new Pawn_MindState(pawn);
     if (pawn.RaceProps.ToolUser)
     {
         pawn.equipment = new Pawn_EquipmentTracker(pawn);
         pawn.apparel   = new Pawn_ApparelTracker(pawn);
     }
     if (pawn.RaceProps.Humanlike)
     {
         pawn.ownership    = new Pawn_Ownership(pawn);
         pawn.skills       = new Pawn_SkillTracker(pawn);
         pawn.story        = new Pawn_StoryTracker(pawn);
         pawn.guest        = new Pawn_GuestTracker(pawn);
         pawn.guilt        = new Pawn_GuiltTracker();
         pawn.workSettings = new Pawn_WorkSettings(pawn);
         if (PsychologyBase.ActivateKinsey())
         {
             PsychologyPawn realPawn = pawn as PsychologyPawn;
             if (realPawn != null)
             {
                 realPawn.sexuality = new Pawn_SexualityTracker(realPawn);
             }
         }
     }
     if (pawn.RaceProps.IsFlesh)
     {
         pawn.relations = new Pawn_RelationsTracker(pawn);
     }
     PawnComponentsUtility.AddAndRemoveDynamicComponents(pawn, false);
 }
コード例 #26
0
 public void ExposeData()
 {
     if (Scribe.mode == LoadSaveMode.Saving || Scribe.loader.curXmlParent["personality"] != null)
     {
         Scribe_Collections.Look(ref nodes, "personality", LookMode.Deep, null);
     }
     Scribe_Values.Look(ref upbringing, "upbringing");
     if (PsychologyBase.ActivateKinsey())
     {
         if (Scribe.mode == LoadSaveMode.Saving || Scribe.loader.curXmlParent["sexDrive"] != null)
         {
             Scribe_Values.Look(ref sexDrive, "sexDrive");
         }
         if (Scribe.mode == LoadSaveMode.Saving || Scribe.loader.curXmlParent["romanticDrive"] != null)
         {
             Scribe_Values.Look(ref romanticDrive, "romanticDrive");
         }
         if (Scribe.mode == LoadSaveMode.Saving || Scribe.loader.curXmlParent["kinseyRating"] != null)
         {
             Scribe_Values.Look(ref kinseyRating, "kinseyRating");
         }
     }
 }
コード例 #27
0
        public static void PsychologyException(ref float __result, 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)
            {
                __result = 0f;
                return;
            }
            //Pawns won't hit on their spouses.
            if (LovePartnerRelationUtility.LovePartnerRelationExists(initiator, recipient))
            {
                __result = 0f;
                return;
            }
            //Codependents won't romance anyone if they are in a relationship
            if (LovePartnerRelationUtility.HasAnyLovePartner(initiator) && initiator.story.traits.HasTrait(TraitDefOfPsychology.Codependent))
            {
                __result = 0f;
                return;
            }
            //Only lechers will romance someone that has less than +5 opinion of them
            if (recipient.relations.OpinionOf(initiator) < 5 && !initiator.story.traits.HasTrait(TraitDefOfPsychology.Lecher))
            {
                __result = 0f;
                return;
            }
            float attractiveness = initiator.relations.SecondaryRomanceChanceFactor(recipient);
            int   opinion        = initiator.relations.OpinionOf(recipient);
            float romanceChance  = 1.15f;

            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 romance is based on how Aggressive and Romantic they are.
                float personalityFactor = Mathf.Pow(20f, PsycheHelper.Comp(initiator).Psyche.GetPersonalityRating(PersonalityNodeDefOf.Aggressive)) * Mathf.Pow(12f, (1f - PsycheHelper.Comp(initiator).Psyche.GetPersonalityRating(PersonalityNodeDefOf.Romantic)));
                romanceChance = personalityFactor * 0.02f;
            }
            //A pawn with +50 or more opinion of their lover will not hit on other pawns unless they are lecherous or polygamous (and their lover is also polygamous).
            float existingLovePartnerFactor = 1f;
            Pawn  pawn = LovePartnerRelationUtility.ExistingMostLikedLovePartner(initiator, false);

            if (pawn != null && !initiator.story.traits.HasTrait(TraitDefOfPsychology.Lecher) && (!initiator.story.traits.HasTrait(TraitDefOfPsychology.Polygamous) && !pawn.story.traits.HasTrait(TraitDefOfPsychology.Polygamous)))
            {
                float value = (float)initiator.relations.OpinionOf(pawn);
                existingLovePartnerFactor = Mathf.InverseLerp(50f, -50f, value);
            }
            float attractivenessFactor = Mathf.InverseLerp(0.25f, 1f, attractiveness);
            float opinionFactor        = Mathf.InverseLerp(-5f, 100f, (float)opinion) * 2f;
            //People who have hit on someone in the past and been rejected because of their sexuality will rarely attempt to hit on them again.
            float knownSexualityFactor = (PsycheHelper.PsychologyEnabled(initiator) && PsychologyBase.ActivateKinsey() && PsycheHelper.Comp(initiator).Sexuality.IncompatibleSexualityKnown(recipient) && !initiator.story.traits.HasTrait(TraitDefOfPsychology.Lecher)) ? 0.05f : (PsycheHelper.PsychologyEnabled(initiator) ? (initiator.gender == recipient.gender ? (initiator.story.traits.HasTrait(TraitDefOf.Gay) && recipient.story.traits.HasTrait(TraitDefOf.Gay) ? 1f : 0.15f) : (!initiator.story.traits.HasTrait(TraitDefOf.Gay) && !recipient.story.traits.HasTrait(TraitDefOf.Gay) ? 1f : 0.15f)) : 1f);
            //Only lechers will try to romance someone in a stable relationship.
            float recipientLovePartnerFactor = 1f;
            Pawn  pawn2 = LovePartnerRelationUtility.ExistingMostLikedLovePartner(recipient, false);

            if (pawn2 != null && !initiator.story.traits.HasTrait(TraitDefOfPsychology.Lecher))
            {
                int value = recipient.relations.OpinionOf(pawn2);
                recipientLovePartnerFactor = Mathf.InverseLerp(5f, -100f, (float)value);
            }
            __result = romanceChance * existingLovePartnerFactor * attractivenessFactor * opinionFactor * knownSexualityFactor * recipientLovePartnerFactor;
            return;
        }
コード例 #28
0
 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);
 }
コード例 #29
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;
                }
            }
        }
コード例 #30
0
 public static void KinseyFactor(ref float __result, Pawn father, Pawn mother, Pawn child)
 {
     /* Kinsey-enabled pawns shouldn't have the Gay trait, so we can just apply the sexuality modifier here. */
     if (father != null && child != null && child.GetFather() == null)
     {
         if (father.GetComp <CompPsychology>() != null && father.GetComp <CompPsychology>().isPsychologyPawn&& PsychologyBase.ActivateKinsey())
         {
             __result *= Mathf.InverseLerp(6f, 0f, father.GetComp <CompPsychology>().Sexuality.kinseyRating);
         }
     }
     if (mother != null && child != null && child.GetMother() == null)
     {
         if (mother.GetComp <CompPsychology>() != null && mother.GetComp <CompPsychology>().isPsychologyPawn&& PsychologyBase.ActivateKinsey())
         {
             __result *= Mathf.InverseLerp(6f, 0f, mother.GetComp <CompPsychology>().Sexuality.kinseyRating);
         }
     }
 }