Esempio n. 1
0
        public static float PackmateGeneratorChance(
            Pawn generated,
            Pawn other,
            PawnGenerationRequest request,
            bool ex)
        {
            if ((double)generated.ageTracker.AgeBiologicalYearsFloat < 5.0)
            {
                if (!(generated.RaceProps.body.defName == AvaliDefs.RimValiBody.defName))
                {
                    return(0.0f);
                }
            }
            if (!(other.RaceProps.body.defName == AvaliDefs.RimValiBody.defName))
            {
                return(0.0f);
            }
            float num1 = 2f;
            float generationChanceAgeFactor1 = PackRelationUtilityWorker.GetGenerationChanceAgeFactor(generated);
            float generationChanceAgeFactor2 = PackRelationUtilityWorker.GetGenerationChanceAgeFactor(other);
            float chanceAgeGapFactor         = PackRelationUtilityWorker.GetGenerationChanceAgeGapFactor(generated, other, ex);
            float num4 = 2f;
            float num5 = !request.FixedMelanin.HasValue ? PawnSkinColors.GetMelaninCommonalityFactor(other.story.melanin) : ChildRelationUtility.GetMelaninSimilarityFactor(request.FixedMelanin.Value, other.story.melanin);

            return(num1 * generationChanceAgeFactor1 * generationChanceAgeFactor2 * chanceAgeGapFactor * num5 * num4);
        }
Esempio n. 2
0
        public override float GenerationChance(Pawn generated, Pawn other, PawnGenerationRequest request)
        {
            float num  = 1f;
            float num2 = 1f;

            if (other.GetFather() != null || other.GetMother() != null)
            {
                num = ChildRelationUtility.ChanceOfBecomingChildOf(generated, other.GetFather(), other.GetMother(), new PawnGenerationRequest?(request), null, null);
            }
            else if (request.FixedMelanin.HasValue)
            {
                num2 = ChildRelationUtility.GetMelaninSimilarityFactor(request.FixedMelanin.Value, other.story.melanin);
            }
            else
            {
                num2 = PawnSkinColors.GetMelaninCommonalityFactor(other.story.melanin);
            }
            float num3 = Mathf.Abs(generated.ageTracker.AgeChronologicalYearsFloat - other.ageTracker.AgeChronologicalYearsFloat);
            float num4 = 1f;

            if (num3 > 40f)
            {
                num4 = 0.2f;
            }
            else if (num3 > 10f)
            {
                num4 = 0.65f;
            }
            return(num * num2 * num4 * base.BaseGenerationChanceFactor(generated, other, request));
        }
        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;
        }
        // LovePartnerRelationUtility.LovePartnerRelationGenerationChance, but with the gender and sexuality code removed.
        public static float LovePartnerRelationGenerationChance(Pawn generated, Pawn other,
                                                                PawnGenerationRequest request, bool ex)
        {
            if (generated.ageTracker.AgeBiologicalYearsFloat < 14f)
            {
                return(0f);
            }

            if (other.ageTracker.AgeBiologicalYearsFloat < 14f)
            {
                return(0f);
            }

            var num = 1f;

            if (ex)
            {
                var num2            = 0;
                var directRelations = other.relations.DirectRelations;
                foreach (var directPawnRelation in directRelations)
                {
                    if (LovePartnerRelationUtility.IsExLovePartnerRelation(directPawnRelation.def))
                    {
                        num2++;
                    }
                }

                num = Mathf.Pow(0.2f, num2);
            }
            else if (LovePartnerRelationUtility.HasAnyLovePartner(other))
            {
                return(0f);
            }

            var generationChanceAgeFactor    = GetGenerationChanceAgeFactor(generated);
            var generationChanceAgeFactor2   = GetGenerationChanceAgeFactor(other);
            var generationChanceAgeGapFactor = GetGenerationChanceAgeGapFactor(generated, other, ex);
            var num3 = 1f;

            if (generated.GetRelations(other).Any(x => x.familyByBloodRelation))
            {
                num3 = 0.01f;
            }

            var num4 = request.FixedMelanin.HasValue
                ? ChildRelationUtility.GetMelaninSimilarityFactor(request.FixedMelanin.Value, other.story.melanin)
                : PawnSkinColors.GetMelaninCommonalityFactor(other.story.melanin);

            return(num * generationChanceAgeFactor * generationChanceAgeFactor2 * generationChanceAgeGapFactor * num3 *
                   num4);
        }
        internal static float _LovePartnerRelationGenerationChance(Pawn generated, Pawn other, PawnGenerationRequest request, bool ex)
        {
            if (generated.ageTracker.AgeBiologicalYearsFloat < 14f)
            {
                return(0f);
            }
            if (other.ageTracker.AgeBiologicalYearsFloat < 14f)
            {
                return(0f);
            }
            if (!PsychologyBase.ActivateKinsey())
            {
                if (generated.gender == other.gender && (!other.story.traits.HasTrait(TraitDefOf.Gay) || !request.AllowGay))
                {
                    return(0f);
                }
                if (generated.gender != other.gender && other.story.traits.HasTrait(TraitDefOf.Gay))
                {
                    return(0f);
                }
            }
            else if (generated.gender == other.gender && !request.AllowGay)
            {
                return(0f);
            }
            float num = 1f;

            if (ex)
            {
                int num2 = 0;
                List <DirectPawnRelation> directRelations = other.relations.DirectRelations;
                for (int i = 0; i < directRelations.Count; i++)
                {
                    if (LovePartnerRelationUtility.IsExLovePartnerRelation(directRelations[i].def))
                    {
                        num2++;
                    }
                }
                num = Mathf.Pow(0.2f, (float)num2);
            }
            else if (LovePartnerRelationUtility.HasAnyLovePartner(other))
            {
                return(0f);
            }
            float          num3          = 1f;
            PsychologyPawn realGenerated = generated as PsychologyPawn;
            PsychologyPawn realOther     = other as PsychologyPawn;

            if (PsychologyBase.ActivateKinsey() && realGenerated != null && realOther != null)
            {
                float kinsey  = 3 - realGenerated.sexuality.kinseyRating;
                float kinsey2 = 3 - realOther.sexuality.kinseyRating;
                float h**o    = (generated.gender == other.gender) ? 1f : -1f;
                num3 *= Mathf.InverseLerp(3f, 0f, kinsey * h**o);
                num3 *= Mathf.InverseLerp(3f, 0f, kinsey2 * h**o);
            }
            else
            {
                num3 = (generated.gender != other.gender) ? 1f : 0.01f;
            }
            var   GetGenerationChanceAgeFactor    = typeof(LovePartnerRelationUtility).GetMethod("GetGenerationChanceAgeFactor", BindingFlags.Static | BindingFlags.NonPublic);
            var   GetGenerationChanceAgeGapFactor = typeof(LovePartnerRelationUtility).GetMethod("GetGenerationChanceAgeGapFactor", BindingFlags.Static | BindingFlags.NonPublic);
            float generationChanceAgeFactor       = (float)GetGenerationChanceAgeFactor.Invoke(null, new object[] { generated });
            float generationChanceAgeFactor2      = (float)GetGenerationChanceAgeFactor.Invoke(null, new object[] { other });
            float generationChanceAgeGapFactor    = (float)GetGenerationChanceAgeGapFactor.Invoke(null, new object[] { generated, other, ex });
            float num4 = 1f;

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

            if (request.FixedMelanin.HasValue)
            {
                num5 = ChildRelationUtility.GetMelaninSimilarityFactor(request.FixedMelanin.Value, other.story.melanin);
            }
            else
            {
                num5 = PawnSkinColors.GetMelaninCommonalityFactor(other.story.melanin);
            }
            return(num * generationChanceAgeFactor * generationChanceAgeFactor2 * generationChanceAgeGapFactor * num3 * num5 * num4);
        }
        private static float LovePartnerRelationGenerationChance_Method(Pawn generated, Pawn other, PawnGenerationRequest request, bool ex)
        {
            if (generated.ageTracker.AgeBiologicalYearsFloat < 14f || other.ageTracker.AgeBiologicalYearsFloat < 14f)
            {
                return(0f);
            }
            float LoveChance   = 1f;
            float GenderFactor = 1f;
            var   comp         = other.TryGetComp <CompIndividuality>();

            if (generated.gender != other.gender && comp != null)
            {
                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.05f;
                }
            }
            if (generated.gender == other.gender && comp != null)
            {
                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.05f;
                }
            }
            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++;
                    }
                }
                LoveChance = Mathf.Pow(0.2f, (float)ExLovers);
            }
            else if (LovePartnerRelationUtility.HasAnyLovePartner(other))
            {
                return(0f);
            }
            float generationChanceAgeFactor    = Mathf.Clamp(GenMath.LerpDouble(14f, 27f, 0f, 1f, generated.ageTracker.AgeBiologicalYearsFloat), 0f, 1f);
            float generationChanceAgeFactor2   = Mathf.Clamp(GenMath.LerpDouble(14f, 27f, 0f, 1f, other.ageTracker.AgeBiologicalYearsFloat), 0f, 1f);
            float generationChanceAgeGapFactor = (float)GetGenerationChanceAgeGapFactor.Invoke(null, 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 != null)
            {
                MelaninFactor = ChildRelationUtility.GetMelaninSimilarityFactor(request.FixedMelanin.Value, other.story.melanin);
            }
            else
            {
                MelaninFactor = PawnSkinColors.GetMelaninCommonalityFactor(other.story.melanin);
            }
            return(LoveChance * generationChanceAgeFactor * generationChanceAgeFactor2 * generationChanceAgeGapFactor * GenderFactor * MelaninFactor * IncestFactor);
        }