Esempio n. 1
0
        //
        // Methods
        //
        // EdB: Copy of CreateRelation() with changes to assign the other pawn's mother or father to this sibling if
        // they exist.  The logic that's in there already seems to take this into account, but doing it this
        // results in more predictable behavior in the context of Prepare Carefully customization.
        public override void CreateRelation(Pawn generated, Pawn other, ref PawnGenerationRequest request)
        {
            // EdB: Added this block to immediately assign the other pawn's parent to the sibling.
            bool otherPawnHasMother = other.GetMother() != null;
            bool otherPawnHasFather = other.GetFather() != null;

            if (generated.GetMother() != null && generated.GetFather() != null && !otherPawnHasMother && !otherPawnHasFather)
            {
                other.SetMother(generated.GetMother());
                other.SetFather(generated.GetFather());
                return;
            }
            // EdB: This is the end of the change.  Everything after this is the original implementation.

            bool flag  = other.GetMother() != null;
            bool flag2 = other.GetFather() != null;
            bool flag3 = Rand.Value < 0.85f;

            if (flag && LovePartnerRelationUtility.HasAnyLovePartner(other.GetMother()))
            {
                flag3 = false;
            }
            if (flag2 && LovePartnerRelationUtility.HasAnyLovePartner(other.GetFather()))
            {
                flag3 = false;
            }
            if (!flag)
            {
                Pawn newMother = PawnRelationWorker_Sibling.GenerateParent(generated, other, Gender.Female, request, flag3);
                other.SetMother(newMother);
            }
            generated.SetMother(other.GetMother());
            if (!flag2)
            {
                Pawn newFather = PawnRelationWorker_Sibling.GenerateParent(generated, other, Gender.Male, request, flag3);
                other.SetFather(newFather);
            }
            generated.SetFather(other.GetFather());
            if (!flag || !flag2)
            {
                bool flag4 = other.GetMother().story.traits.HasTrait(TraitDefOf.Gay) || other.GetFather().story.traits.HasTrait(TraitDefOf.Gay);
                if (flag4)
                {
                    other.GetFather().relations.AddDirectRelation(PawnRelationDefOf.ExLover, other.GetMother());
                }
                else if (flag3)
                {
                    other.GetFather().relations.AddDirectRelation(PawnRelationDefOf.Spouse, other.GetMother());
                }
                else
                {
                    LovePartnerRelationUtility.GiveRandomExLoverOrExSpouseRelation(other.GetFather(), other.GetMother());
                }
            }
            PawnRelationWorker_Sibling.ResolveMyName(ref request, generated);
            PawnRelationWorker_Sibling.ResolveMySkinColor(ref request, generated);
        }
Esempio n. 2
0
        //
        // Static Methods
        //
        private static Pawn GenerateParent(Pawn generatedChild, Pawn existingChild, Gender genderToGenerate, PawnGenerationRequest childRequest, bool newlyGeneratedParentsWillBeSpousesIfNotGay)
        {
            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);
            float  value;
            float  value2;
            float  value3;
            string last;

            PawnRelationWorker_Sibling.GenerateParentParams(num4, maxChronologicalAge, midChronologicalAge, num, generatedChild, existingChild, childRequest, out value, out value2, out value3, out last);
            bool allowGay = true;

            if (newlyGeneratedParentsWillBeSpousesIfNotGay && last.NullOrEmpty() && Rand.Value < 0.8f)
            {
                if (genderToGenerate == Gender.Male && existingChild.GetMother() != null && !existingChild.GetMother().story.traits.HasTrait(TraitDefOf.Gay))
                {
                    last     = ((NameTriple)existingChild.GetMother().Name).Last;
                    allowGay = false;
                }
                else if (genderToGenerate == Gender.Female && existingChild.GetFather() != null && !existingChild.GetFather().story.traits.HasTrait(TraitDefOf.Gay))
                {
                    last     = ((NameTriple)existingChild.GetFather().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, null, true, false, true, true, false, false, 1f, false, allowGay, true, 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);
            }
            return(pawn);
        }