Esempio n. 1
0
        public static float LovinMtbSinglePawnFactor(Pawn pawn)
        {
            float num = 1f;

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

            if (efficiency < 0.5f)
            {
                num /= efficiency * 2f;
            }

            if (!pawn.RaceProps.Humanlike)
            {
                return(num * 4f);
            }
            if (RimWorld.LovePartnerRelationUtility.ExistingLovePartner(pawn) != null)
            {
                num *= 2f;                 //This is a factor which makes pawns with love partners less likely to do fappin/random raping/rapingCP/beastiality/necro.
            }
            else if (pawn.gender == Gender.Male)
            {
                num /= 1.25f;                 //This accounts for single men
            }
            return(num / GenMath.FlatHill(0.0001f, 8f, 13f, 28f, 50f, 0.15f, pawn.ageTracker.AgeBiologicalYearsFloat));
        }
Esempio n. 2
0
        public override float CalculateCapacityLevel(HediffSet diffSet, List <PawnCapacityUtility.CapacityImpactor> impactors = null)
        {
            //return 1.0f;
            //--Log.Message("[RJW]PawnCapacityWorker_Fertility::CalculateCapacityLevel is called0");
            //return 1f;
            Pawn p = diffSet.pawn;

            if (p == null)
            {
                return(0f);
            }
            if (xxx.is_animal(p))
            {
                return(1f);
            }
            else if (xxx.is_human(p))
            {
                if (p.ageTracker.AgeBiologicalYears > 50 || p.ageTracker.AgeBiologicalYears < 14)
                {
                    return(0f);
                }
                float result = PawnCapacityUtility.CalculateTagEfficiency(diffSet, "RJW_FertilitySource", 1f, impactors); //This should be a value ranged in [0,1]. It seems always to be 1.
                //--Log.Message("[RJW]PawnCapacityWorker_Fertility::CalculateCapacityLevel is called1 - result is "+ result);
                result *= GenMath.FlatHill(14f, 20f, 30f, 50f, p.ageTracker.AgeBiologicalYearsFloat);                     //This adds an aging factor to Fertility
                //--Log.Message("[RJW]PawnCapacityWorker_Fertility::CalculateCapacityLevel is called2 - result is " + result);
                return(result);
            }
            else
            {
                return(0f);
            }
        }
Esempio n. 3
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);
        }
        // RimWorld.LovePartnerRelationUtility
        private static float LovinMtbSinglePawnFactor(Pawn pawn)
        {
            try
            {
                float num  = 1f;
                var   num2 = pawn?.health?.hediffSet?.PainTotal ?? -1f;
                if (num2 > -1f)
                {
                    num /= 1f - num2;
                    if (pawn?.health?.capacities?.GetLevel(PawnCapacityDefOf.Consciousness) != null)
                    {
                        float level = pawn.health.capacities.GetLevel(PawnCapacityDefOf.Consciousness);
                        if (level < 0.5f)
                        {
                            num /= level * 2f;
                        }
                    }

                    return(num / GenMath.FlatHill(0f, 14f, 16f, 25f, 80f, 0.2f,
                                                  pawn.ageTracker.AgeBiologicalYearsFloat));
                }
            }
            catch (Exception e)
            {
                return(-1f);
            }

            return(-1f);
        }
		private static float LovinMtbSinglePawnFactor(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;
			}
			return num / GenMath.FlatHill(0f, 14f, 16f, 25f, 80f, 0.2f, pawn.ageTracker.AgeBiologicalYearsFloat);
		}
        public static void SecondaryLovinChanceFactor(Pawn_RelationsTracker __instance, Pawn otherPawn,
                                                      ref float __result)
        {
            var pawn = __instance.GetPawn();

            if (pawn.def != otherPawn.def || pawn == otherPawn)
            {
                __result = 0f;
                return;
            }

            var ageBiologicalYearsFloat  = pawn.ageTracker.AgeBiologicalYearsFloat;
            var ageBiologicalYearsFloat2 = otherPawn.ageTracker.AgeBiologicalYearsFloat;

            if (ageBiologicalYearsFloat2 < 16f)
            {
                __result = 0f;
                return;
            }

            var min   = Mathf.Max(16f, ageBiologicalYearsFloat - 30f);
            var lower = Mathf.Max(20f, ageBiologicalYearsFloat, ageBiologicalYearsFloat - 10f);
            var num   = GenMath.FlatHill(0.15f, min, lower, ageBiologicalYearsFloat + 7f, ageBiologicalYearsFloat + 30f,
                                         0.15f, ageBiologicalYearsFloat2);
            var num2 = 1f;

            num2 *= Mathf.Lerp(0.2f, 1f, otherPawn.health.capacities.GetLevel(PawnCapacityDefOf.Talking));
            num2 *= Mathf.Lerp(0.2f, 1f, otherPawn.health.capacities.GetLevel(PawnCapacityDefOf.Manipulation));
            num2 *= Mathf.Lerp(0.2f, 1f, otherPawn.health.capacities.GetLevel(PawnCapacityDefOf.Moving));
            var num3 = 0;

            if (otherPawn.RaceProps.Humanlike)
            {
                num3 = otherPawn.story.traits.DegreeOfTrait(TraitDefOf.Beauty);
            }

            var num4 = 1f;

            if (num3 < 0)
            {
                num4 = 0.3f;
            }
            else if (num3 > 0)
            {
                num4 = 2.3f;
            }

            var num5 = Mathf.InverseLerp(15f, 18f, ageBiologicalYearsFloat);
            var num6 = Mathf.InverseLerp(15f, 18f, ageBiologicalYearsFloat2);

            __result = num * num2 * num5 * num6 * num4;
        }
        internal static float _AttractionTo(this Pawn_RelationsTracker _this, Pawn otherPawn)
        {
            var pawn = _this.GetPawn();

            if (!PawnsAreValidMatches(pawn, otherPawn))
            {
                return(0f);
            }
            float num  = 1f;
            float num2 = 1f;
            float ageBiologicalYearsFloat  = pawn.ageTracker.AgeBiologicalYearsFloat;
            float ageBiologicalYearsFloat2 = otherPawn.ageTracker.AgeBiologicalYearsFloat;

            if (pawn.gender == Gender.Male)
            {
                if (
                    (pawn.RaceProps.Humanlike) &&
                    (pawn.story.traits.HasTrait(TraitDefOf.Gay))
                    )
                {
                    if (otherPawn.gender == Gender.Female)
                    {
                        return(0f);
                    }
                }
                else if (
                    (otherPawn.gender == Gender.Male) &&
                    (!pawn.story.traits.HasTrait(TraitDefOfPsychology.Bisexual))
                    )
                {
                    return(0f);
                }
                num2 = GenMath.FlatHill(16f, 20f, ageBiologicalYearsFloat, ageBiologicalYearsFloat + 15f, ageBiologicalYearsFloat2);
            }
            else if (pawn.gender == Gender.Female)
            {
                if (
                    (pawn.RaceProps.Humanlike) &&
                    (pawn.story.traits.HasTrait(TraitDefOf.Gay))
                    )
                {
                    if (otherPawn.gender == Gender.Male)
                    {
                        return(0f);
                    }
                }
                else if (
                    (otherPawn.gender == Gender.Female) &&
                    (!pawn.story.traits.HasTrait(TraitDefOfPsychology.Bisexual))
                    )
                {
                    num = 0.15f;
                }
                if (ageBiologicalYearsFloat2 < ageBiologicalYearsFloat - 10f)
                {
                    return(0f);
                }
                if (ageBiologicalYearsFloat2 < ageBiologicalYearsFloat - 3f)
                {
                    num2 = Mathf.InverseLerp(ageBiologicalYearsFloat - 10f, ageBiologicalYearsFloat - 3f, ageBiologicalYearsFloat2) * 0.2f;
                }
                else
                {
                    num2 = GenMath.FlatHill(0.2f, ageBiologicalYearsFloat - 3f, ageBiologicalYearsFloat, ageBiologicalYearsFloat + 10f, ageBiologicalYearsFloat + 40f, 0.1f, ageBiologicalYearsFloat2);
                }
            }
            float num3 = 1f;

            num3 *= Mathf.Lerp(0.2f, 1f, otherPawn.health.capacities.GetEfficiency(PawnCapacityDefOf.Talking));
            num3 *= Mathf.Lerp(0.2f, 1f, otherPawn.health.capacities.GetEfficiency(PawnCapacityDefOf.Manipulation));
            num3 *= Mathf.Lerp(0.2f, 1f, otherPawn.health.capacities.GetEfficiency(PawnCapacityDefOf.Moving));
            float num4 = 1f;

            foreach (PawnRelationDef current in pawn.GetRelations(otherPawn))
            {
                num4 *= current.attractionFactor;
            }
            int num5 = 0;

            if (otherPawn.RaceProps.Humanlike)
            {
                num5 = otherPawn.story.traits.DegreeOfTrait(TraitDefOf.Beauty);
            }
            float num6 = 1f;

            if (num5 < 0)
            {
                num6 = 0.3f;
            }
            else if (num5 > 0)
            {
                num6 = 2.3f;
            }
            float num7 = Mathf.InverseLerp(15f, 18f, ageBiologicalYearsFloat);
            float num8 = Mathf.InverseLerp(15f, 18f, ageBiologicalYearsFloat2);

            return(num * num2 * num3 * num4 * num7 * num8 * num6);
        }
 public float SecondaryLovinChanceFactor(Pawn otherPawn)
 {
     if (this.pawn.def == otherPawn.def && this.pawn != otherPawn)
     {
         if (!(Rand.ValueSeeded(this.pawn.thingIDNumber ^ 3273711) < 0.014999999664723873))
         {
             if (this.pawn.RaceProps.Humanlike && this.pawn.story.traits.HasTrait(TraitDefOf.Gay))
             {
                 if (otherPawn.gender != this.pawn.gender)
                 {
                     return(0f);
                 }
             }
             else if (otherPawn.gender == this.pawn.gender)
             {
                 return(0f);
             }
         }
         float ageBiologicalYearsFloat  = this.pawn.ageTracker.AgeBiologicalYearsFloat;
         float ageBiologicalYearsFloat2 = otherPawn.ageTracker.AgeBiologicalYearsFloat;
         float num = 1f;
         if (this.pawn.gender == Gender.Male)
         {
             if (ageBiologicalYearsFloat2 < 16.0)
             {
                 return(0f);
             }
             float min   = Mathf.Max(16f, (float)(ageBiologicalYearsFloat - 30.0));
             float lower = Mathf.Max(20f, (float)(ageBiologicalYearsFloat - 10.0));
             num = GenMath.FlatHill(0.15f, min, lower, ageBiologicalYearsFloat, (float)(ageBiologicalYearsFloat + 10.0), 0.15f, ageBiologicalYearsFloat2);
         }
         else if (this.pawn.gender == Gender.Female)
         {
             if (ageBiologicalYearsFloat2 < 16.0)
             {
                 return(0f);
             }
             if (ageBiologicalYearsFloat2 < ageBiologicalYearsFloat - 10.0)
             {
                 return(0.15f);
             }
             num = (float)((!(ageBiologicalYearsFloat2 < ageBiologicalYearsFloat - 3.0)) ? GenMath.FlatHill(0.3f, (float)(ageBiologicalYearsFloat - 3.0), ageBiologicalYearsFloat, (float)(ageBiologicalYearsFloat + 10.0), (float)(ageBiologicalYearsFloat + 30.0), 0.15f, ageBiologicalYearsFloat2) : (Mathf.InverseLerp((float)(ageBiologicalYearsFloat - 10.0), (float)(ageBiologicalYearsFloat - 3.0), ageBiologicalYearsFloat2) * 0.30000001192092896));
         }
         float num2 = 1f;
         num2 *= Mathf.Lerp(0.2f, 1f, otherPawn.health.capacities.GetLevel(PawnCapacityDefOf.Talking));
         num2 *= Mathf.Lerp(0.2f, 1f, otherPawn.health.capacities.GetLevel(PawnCapacityDefOf.Manipulation));
         num2 *= Mathf.Lerp(0.2f, 1f, otherPawn.health.capacities.GetLevel(PawnCapacityDefOf.Moving));
         int num3 = 0;
         if (otherPawn.RaceProps.Humanlike)
         {
             num3 = otherPawn.story.traits.DegreeOfTrait(TraitDefOf.Beauty);
         }
         float num4 = 1f;
         if (num3 < 0)
         {
             num4 = 0.3f;
         }
         else if (num3 > 0)
         {
             num4 = 2.3f;
         }
         float num5 = Mathf.InverseLerp(15f, 18f, ageBiologicalYearsFloat);
         float num6 = Mathf.InverseLerp(15f, 18f, ageBiologicalYearsFloat2);
         return(num * num2 * num5 * num6 * num4);
     }
     return(0f);
 }
Esempio n. 9
0
 public static void SecondaryLovinChanceFactor_Postfix(ref float __result, Pawn ___pawn, Pawn otherPawn, Pawn_RelationsTracker __instance)
 {
     if (!SyrIndividuality.RomanceDisabled)
     {
         CompIndividuality comp         = ___pawn.TryGetComp <CompIndividuality>();
         float             genderFactor = 1f;
         if (___pawn == otherPawn)
         {
             __result = 0f;
         }
         if (comp != null && ___pawn.gender != otherPawn.gender)
         {
             if (comp.sexuality == CompIndividuality.Sexuality.Straight)
             {
                 genderFactor = 1.0f;
             }
             else if (comp.sexuality == CompIndividuality.Sexuality.Bisexual)
             {
                 genderFactor = 0.75f;
             }
             else if (comp.sexuality == CompIndividuality.Sexuality.Gay)
             {
                 genderFactor = 0.1f;
             }
             else if (comp.sexuality == CompIndividuality.Sexuality.Asexual)
             {
                 genderFactor = 0f;
             }
         }
         else if (comp != null && ___pawn.gender == otherPawn.gender)
         {
             if (comp.sexuality == CompIndividuality.Sexuality.Gay)
             {
                 genderFactor = 1.0f;
             }
             else if (comp.sexuality == CompIndividuality.Sexuality.Bisexual)
             {
                 genderFactor = 0.75f;
             }
             else if (comp.sexuality == CompIndividuality.Sexuality.Straight)
             {
                 genderFactor = 0.1f;
             }
             else if (comp.sexuality == CompIndividuality.Sexuality.Asexual)
             {
                 genderFactor = 0f;
             }
         }
         float agePawn      = ___pawn.ageTracker.AgeBiologicalYearsFloat;
         float ageOtherPawn = otherPawn.ageTracker.AgeBiologicalYearsFloat;
         float ageFactor    = 1f;
         if (___pawn.gender == Gender.Male)
         {
             float min   = agePawn - 30f;
             float lower = agePawn - 10f;
             float upper = agePawn + 5f;
             float max   = agePawn + 15f;
             ageFactor = GenMath.FlatHill(0.2f, min, lower, upper, max, 0.2f, ageOtherPawn);
         }
         else if (___pawn.gender == Gender.Female)
         {
             float min2   = agePawn - 20f;
             float lower2 = agePawn - 10f;
             float upper2 = agePawn + 10f;
             float max2   = agePawn + 30f;
             ageFactor = GenMath.FlatHill(0.2f, min2, lower2, upper2, max2, 0.2f, ageOtherPawn);
         }
         float healthFactor = 1f;
         healthFactor *= Mathf.Lerp(0.2f, 1f, otherPawn.health.capacities.GetLevel(PawnCapacityDefOf.Talking));
         float beauty = 0;
         if (otherPawn.RaceProps.Humanlike)
         {
             beauty = otherPawn.GetStatValue(StatDefOf.PawnBeauty, true);
         }
         float beautyFactor = 1f;
         beautyFactor = beautyCurve.Evaluate(beauty);
         float youthFactorPawn      = Mathf.InverseLerp(16f, 18f, agePawn);
         float youthFactorOtherPawn = Mathf.InverseLerp(16f, 18f, ageOtherPawn);
         __result = genderFactor * ageFactor * healthFactor * beautyFactor * youthFactorPawn * youthFactorOtherPawn;
     }
 }
        public float SecondaryLovinChanceFactor(Pawn otherPawn)
        {
            if (pawn.def != otherPawn.def || pawn == otherPawn)
            {
                return(0f);
            }
            if (pawn.story != null && pawn.story.traits != null)
            {
                if (pawn.story.traits.HasTrait(TraitDefOf.Asexual))
                {
                    return(0f);
                }
                if (!pawn.story.traits.HasTrait(TraitDefOf.Bisexual))
                {
                    if (pawn.story.traits.HasTrait(TraitDefOf.Gay))
                    {
                        if (otherPawn.gender != pawn.gender)
                        {
                            return(0f);
                        }
                    }
                    else if (otherPawn.gender == pawn.gender)
                    {
                        return(0f);
                    }
                }
            }
            float ageBiologicalYearsFloat  = pawn.ageTracker.AgeBiologicalYearsFloat;
            float ageBiologicalYearsFloat2 = otherPawn.ageTracker.AgeBiologicalYearsFloat;

            if (ageBiologicalYearsFloat < 16f || ageBiologicalYearsFloat2 < 16f)
            {
                return(0f);
            }
            float num = 1f;

            if (pawn.gender == Gender.Male)
            {
                float min   = ageBiologicalYearsFloat - 30f;
                float lower = ageBiologicalYearsFloat - 10f;
                float upper = ageBiologicalYearsFloat + 3f;
                float max   = ageBiologicalYearsFloat + 10f;
                num = GenMath.FlatHill(0.2f, min, lower, upper, max, 0.2f, ageBiologicalYearsFloat2);
            }
            else if (pawn.gender == Gender.Female)
            {
                float min2   = ageBiologicalYearsFloat - 10f;
                float lower2 = ageBiologicalYearsFloat - 3f;
                float upper2 = ageBiologicalYearsFloat + 10f;
                float max2   = ageBiologicalYearsFloat + 30f;
                num = GenMath.FlatHill(0.2f, min2, lower2, upper2, max2, 0.2f, ageBiologicalYearsFloat2);
            }
            float num2 = Mathf.InverseLerp(16f, 18f, ageBiologicalYearsFloat);
            float num3 = Mathf.InverseLerp(16f, 18f, ageBiologicalYearsFloat2);
            float num4 = 0f;

            if (otherPawn.RaceProps.Humanlike)
            {
                num4 = otherPawn.GetStatValue(StatDefOf.PawnBeauty);
            }
            float num5 = 1f;

            if (num4 < 0f)
            {
                num5 = 0.3f;
            }
            else if (num4 > 0f)
            {
                num5 = 2.3f;
            }
            return(num * num2 * num3 * num5);
        }
        public override float CalculateCapacityLevel(HediffSet diffSet, List <PawnCapacityUtility.CapacityImpactor> impactors = null)
        {
            Pawn pawn = diffSet.pawn;

            if (!Genital_Helper.has_penis(pawn) && !Genital_Helper.has_vagina(pawn))
            {
                return(0);
            }

            if (Genital_Helper.has_ovipositorF(pawn) || Genital_Helper.has_ovipositorM(pawn))
            {
                return(0);
            }

            //Log.Message("[RJW]PawnCapacityWorker_Fertility::CalculateCapacityLevel is called for: " + xxx.get_pawnname(pawn));
            RaceProperties race = diffSet.pawn.RaceProps;

            if (!pawn.RaceHasFertility())
            {
                //Log.Message(" Fertility_filter, no fertility for : " + pawn.kindDef.defName);
                return(0f);
            }

            //androids only fertile with archotech parts
            if (AndroidsCompatibility.IsAndroid(pawn) && !(AndroidsCompatibility.AndroidPenisFertility(pawn) || AndroidsCompatibility.AndroidVaginaFertility(pawn)))
            {
                //Log.Message(" Android has no archotech genitals set fertility to 0 for: " + pawn.kindDef.defName);
                return(0f);
            }

            //archotech always fertile mode
            if (pawn.health.hediffSet.HasHediff(HediffDef.Named("FertilityEnhancer")))
            {
                //Log.Message(" has archotech FertilityEnhancer set fertility to 100%");
                return(1f);
            }

            float startAge      = 0f;                                                                        //raise fertility
            float startMaxAge   = 0f;                                                                        //max fertility
            float endAge        = race.lifeExpectancy * (RJWPregnancySettings.fertility_endage_male * 0.7f); // Age when males start to lose potency.
            float zeroFertility = race.lifeExpectancy * RJWPregnancySettings.fertility_endage_male;          // Age when fertility hits 0%.

            if (xxx.is_female(pawn))
            {
                if (xxx.is_animal(pawn))
                {
                    endAge        = race.lifeExpectancy * (RJWPregnancySettings.fertility_endage_female_animal * 0.6f);
                    zeroFertility = race.lifeExpectancy * RJWPregnancySettings.fertility_endage_female_animal;
                }
                else
                {
                    endAge        = race.lifeExpectancy * (RJWPregnancySettings.fertility_endage_female_humanlike * 0.6f);            // Age when fertility begins to drop.
                    zeroFertility = race.lifeExpectancy * RJWPregnancySettings.fertility_endage_female_humanlike;                     // Age when fertility hits 0%.
                }
            }

            foreach (LifeStageAge lifestage in race.lifeStageAges)
            {
                if (lifestage.def.reproductive)
                {
                    //presumably teen stage
                    if (startAge == 0f && startMaxAge == 0f)
                    {
                        startAge    = lifestage.minAge;
                        startMaxAge = (Mathf.Max(startAge + (startAge + endAge) * 0.08f, startAge));
                    }
                    //presumably adult stage
                    else
                    {
                        if (startMaxAge > lifestage.minAge)
                        {
                            startMaxAge = lifestage.minAge;
                        }
                    }
                }
            }
            //Log.Message(" Fertility ages for " + pawn.Name + " are: " + startAge + ", " + startMaxAge + ", " + endAge + ", " + endMaxAge);

            float result = PawnCapacityUtility.CalculateTagEfficiency(diffSet, BodyPartTagDefOf.RJW_FertilitySource, 1f, FloatRange.ZeroToOne, impactors);

            result *= GenMath.FlatHill(startAge, startMaxAge, endAge, zeroFertility, pawn.ageTracker.AgeBiologicalYearsFloat);

            //Log.Message("[RJW]PawnCapacityWorker_Fertility::CalculateCapacityLevel result is: " + result);
            return(result);
        }
Esempio n. 12
0
        internal static float _SecondaryRomanceChanceFactor(this Pawn_RelationsTracker t, Pawn otherPawn)
        {
            Pawn pawn = t.GetPawn();

            if (pawn.def != otherPawn.def || pawn == otherPawn)
            {
                return(0f);
            }
            Rand.PushSeed();
            Rand.Seed = pawn.HashOffset();
            bool flag = Rand.Value < 0.015f;

            Rand.PopSeed();
            float          num  = 1f;
            float          num2 = 1f;
            float          num9 = 1f;
            float          ageBiologicalYearsFloat  = pawn.ageTracker.AgeBiologicalYearsFloat;
            float          ageBiologicalYearsFloat2 = otherPawn.ageTracker.AgeBiologicalYearsFloat;
            PsychologyPawn realPawn = pawn as PsychologyPawn;

            if (PsychologyBase.ActivateKinsey() && realPawn != null)
            {
                flag = true;
                float kinsey = 3 - realPawn.sexuality.kinseyRating;
                float h**o   = (pawn.gender == otherPawn.gender) ? 1f : -1f;
                num9 = Mathf.InverseLerp(3f, 0f, kinsey * h**o);
            }
            if (pawn.gender == Gender.Male)
            {
                if (!flag)
                {
                    if (pawn.RaceProps.Humanlike && pawn.story.traits.HasTrait(TraitDefOf.Gay))
                    {
                        if (otherPawn.gender == Gender.Female)
                        {
                            return(0f);
                        }
                    }
                    else if (otherPawn.gender == Gender.Male)
                    {
                        return(0f);
                    }
                }
                num2 = GenMath.FlatHill(0f, 16f, 20f, ageBiologicalYearsFloat, ageBiologicalYearsFloat + 15f, 0.07f, ageBiologicalYearsFloat2);
                if (pawn.RaceProps.Humanlike && pawn.story.traits.HasTrait(TraitDefOfPsychology.OpenMinded))
                {
                    num2 = 1f;
                }
            }
            else if (pawn.gender == Gender.Female)
            {
                if (!flag)
                {
                    if (pawn.RaceProps.Humanlike && pawn.story.traits.HasTrait(TraitDefOf.Gay))
                    {
                        if (otherPawn.gender == Gender.Male)
                        {
                            return(0f);
                        }
                    }
                    else if (otherPawn.gender == Gender.Female)
                    {
                        num = 0f;
                    }
                }
                if ((ageBiologicalYearsFloat2 < ageBiologicalYearsFloat - 10f) && (pawn.story.traits.HasTrait(TraitDefOfPsychology.OpenMinded)))
                {
                    return(0f);
                }
                if (ageBiologicalYearsFloat2 < ageBiologicalYearsFloat - 3f)
                {
                    num2 = Mathf.InverseLerp(ageBiologicalYearsFloat - 10f, ageBiologicalYearsFloat - 3f, ageBiologicalYearsFloat2) * 0.2f;
                }
                else
                {
                    num2 = GenMath.FlatHill(0.2f, ageBiologicalYearsFloat - 3f, ageBiologicalYearsFloat, ageBiologicalYearsFloat + 10f, ageBiologicalYearsFloat + 30f, 0.1f, ageBiologicalYearsFloat2);
                }
                if (pawn.RaceProps.Humanlike && pawn.story.traits.HasTrait(TraitDefOfPsychology.OpenMinded))
                {
                    num2 = 1f;
                }
            }
            float num3 = 1f;

            num3 *= Mathf.Lerp(0.2f, 1f, otherPawn.health.capacities.GetEfficiency(PawnCapacityDefOf.Talking));
            num3 *= Mathf.Lerp(0.2f, 1f, otherPawn.health.capacities.GetEfficiency(PawnCapacityDefOf.Manipulation));
            num3 *= Mathf.Lerp(0.2f, 1f, otherPawn.health.capacities.GetEfficiency(PawnCapacityDefOf.Moving));
            if (pawn.RaceProps.Humanlike && pawn.story.traits.HasTrait(TraitDefOfPsychology.OpenMinded))
            {
                num3 = 1f;
            }
            float num4 = 1f;

            foreach (PawnRelationDef current in pawn.GetRelations(otherPawn))
            {
                num4 *= current.attractionFactor;
            }
            int num5 = 0;

            if (otherPawn.RaceProps.Humanlike)
            {
                num5 = otherPawn.story.traits.DegreeOfTrait(TraitDefOf.Beauty);
            }
            if (pawn.RaceProps.Humanlike && pawn.story.traits.HasTrait(TraitDefOfPsychology.OpenMinded) || pawn.health.capacities.GetEfficiency(PawnCapacityDefOf.Sight) == 0f)
            {
                num5 = 0;
            }
            float num6 = 1f;

            if (num5 < 0)
            {
                num6 = 0.3f;
            }
            else if (num5 > 0)
            {
                num6 = 2.3f;
            }
            float num7 = Mathf.InverseLerp(15f, 18f, ageBiologicalYearsFloat);
            float num8 = Mathf.InverseLerp(15f, 18f, ageBiologicalYearsFloat2);

            return(num * num2 * num3 * num4 * num7 * num8 * num6 * num9);
        }
Esempio n. 13
0
        public static void PsychologyFormula(Pawn_RelationsTracker __instance, ref float __result, Pawn otherPawn)
        {
            Pawn           pawn     = Traverse.Create(__instance).Field("pawn").GetValue <Pawn>();
            PsychologyPawn realPawn = pawn as PsychologyPawn;

            if (realPawn != null)
            {
                if (pawn.def != otherPawn.def || pawn == otherPawn)
                {
                    __result = 0f;
                    return;
                }
                /* Throw away the existing result and substitute our own formula. */
                float ageFactor                = 1f;
                float sexualityFactor          = 1f;
                float ageBiologicalYearsFloat  = pawn.ageTracker.AgeBiologicalYearsFloat;
                float ageBiologicalYearsFloat2 = otherPawn.ageTracker.AgeBiologicalYearsFloat;
                if (PsychologyBase.ActivateKinsey() && realPawn.sexuality != null)
                {
                    float kinsey = 3 - realPawn.sexuality.kinseyRating;
                    float h**o   = (pawn.gender == otherPawn.gender) ? 1f : -1f;
                    sexualityFactor = Mathf.InverseLerp(3f, 0f, kinsey * h**o);
                }
                else if (Rand.ValueSeeded(pawn.thingIDNumber ^ 3273711) >= 0.015f)
                {
                    if (pawn.RaceProps.Humanlike && pawn.story.traits.HasTrait(TraitDefOf.Gay))
                    {
                        if (otherPawn.gender != pawn.gender)
                        {
                            __result = 0f;
                            return;
                        }
                    }
                    else if (otherPawn.gender == pawn.gender)
                    {
                        __result = 0f;
                        return;
                    }
                }
                if (pawn.gender == Gender.Male)
                {
                    if (ageBiologicalYearsFloat2 < 16f)
                    {
                        __result = 0f;
                        return;
                    }
                    float min   = Mathf.Max(16f, ageBiologicalYearsFloat - 30f);
                    float lower = Mathf.Max(20f, ageBiologicalYearsFloat - 10f);
                    ageFactor = GenMath.FlatHill(0.15f, min, lower, ageBiologicalYearsFloat, ageBiologicalYearsFloat + 10f, 0.15f, ageBiologicalYearsFloat2);
                }
                else if (pawn.gender == Gender.Female)
                {
                    if (ageBiologicalYearsFloat2 < 16f)
                    {
                        __result = 0f;
                        return;
                    }
                    if ((ageBiologicalYearsFloat2 < ageBiologicalYearsFloat - 10f) && (!pawn.story.traits.HasTrait(TraitDefOfPsychology.OpenMinded)))
                    {
                        ageFactor *= 0.15f;
                    }
                    if (ageBiologicalYearsFloat2 < ageBiologicalYearsFloat - 3f)
                    {
                        ageFactor *= Mathf.InverseLerp(ageBiologicalYearsFloat - 10f, ageBiologicalYearsFloat - 3f, ageBiologicalYearsFloat2) * 0.3f;
                    }
                    else
                    {
                        ageFactor *= GenMath.FlatHill(0.3f, ageBiologicalYearsFloat - 3f, ageBiologicalYearsFloat, ageBiologicalYearsFloat + 10f, ageBiologicalYearsFloat + 30f, 0.15f, ageBiologicalYearsFloat2);
                    }
                }
                ageFactor = Mathf.Lerp(ageFactor, (1.6f - ageFactor), realPawn.psyche.GetPersonalityRating(PersonalityNodeDefOf.Experimental));
                float disabilityFactor = 1f;
                disabilityFactor *= Mathf.Lerp(0.2f, 1f, otherPawn.health.capacities.GetLevel(PawnCapacityDefOf.Talking));
                disabilityFactor *= Mathf.Lerp(0.2f, 1f, otherPawn.health.capacities.GetLevel(PawnCapacityDefOf.Manipulation));
                disabilityFactor *= Mathf.Lerp(0.2f, 1f, otherPawn.health.capacities.GetLevel(PawnCapacityDefOf.Moving));
                disabilityFactor  = Mathf.Lerp(disabilityFactor, (1.6f - disabilityFactor), realPawn.psyche.GetPersonalityRating(PersonalityNodeDefOf.Experimental));
                if (pawn.RaceProps.Humanlike && pawn.story.traits.HasTrait(TraitDefOfPsychology.OpenMinded))
                {
                    ageFactor        = 1f;
                    disabilityFactor = 1f;
                }
                float relationFactor = 1f;
                foreach (PawnRelationDef current in pawn.GetRelations(otherPawn))
                {
                    relationFactor *= current.attractionFactor;
                }
                int beauty = 0;
                if (otherPawn.RaceProps.Humanlike)
                {
                    beauty = otherPawn.story.traits.DegreeOfTrait(TraitDefOf.Beauty);
                }
                if (pawn.RaceProps.Humanlike && pawn.story.traits.HasTrait(TraitDefOfPsychology.OpenMinded))
                {
                    beauty = 0;
                }
                float beautyFactor = 1f;
                if (beauty < 0)
                {
                    beautyFactor = 0.3f;
                }
                else if (beauty > 0)
                {
                    beautyFactor = 2.3f;
                }
                if (pawn.health.capacities.GetLevel(PawnCapacityDefOf.Sight) < 1f)
                {
                    /* Pawns who can't see as well can't determine beauty as well. */
                    beautyFactor = Mathf.Pow(beautyFactor, pawn.health.capacities.GetLevel(PawnCapacityDefOf.Sight));
                }
                if (realPawn != null && PsychologyBase.ActivateKinsey() && realPawn.sexuality != null && realPawn.sexuality.AdjustedSexDrive < 1f)
                {
                    /* Pawns with low sex drive will care about physical features less. */
                    beautyFactor     = Mathf.Pow(beautyFactor, realPawn.sexuality.AdjustedSexDrive);
                    ageFactor        = Mathf.Pow(ageFactor, realPawn.sexuality.AdjustedSexDrive);
                    disabilityFactor = Mathf.Pow(disabilityFactor, realPawn.sexuality.AdjustedSexDrive);
                }
                float initiatorYouthFactor = Mathf.InverseLerp(15f, 18f, ageBiologicalYearsFloat);
                float recipientYouthFactor = Mathf.InverseLerp(15f, 18f, ageBiologicalYearsFloat2);
                __result = 1f * sexualityFactor * ageFactor * disabilityFactor * relationFactor * beautyFactor * initiatorYouthFactor * recipientYouthFactor;
            }
        }