public static Pawn GetPartnerInMyBed(Pawn pawn) { Building_Bed building_Bed = pawn.CurrentBed(); if (building_Bed == null) { return(null); } if (building_Bed.SleepingSlotsCount <= 1) { return(null); } if (!LovePartnerRelationUtility.HasAnyLovePartner(pawn)) { return(null); } foreach (Pawn pawn2 in building_Bed.CurOccupants) { if (pawn2 != pawn) { if (LovePartnerRelationUtility.LovePartnerRelationExists(pawn, pawn2)) { return(pawn2); } } } return(null); }
public static Pawn GetPartnerInMyBed(Pawn pawn) { if (pawn.CurJob != null && pawn.jobs.curDriver.layingDown != 0) { Building_Bed building_Bed = pawn.CurrentBed(); if (building_Bed == null) { return(null); } if (building_Bed.SleepingSlotsCount <= 1) { return(null); } if (!LovePartnerRelationUtility.HasAnyLovePartner(pawn)) { return(null); } foreach (Pawn curOccupant in building_Bed.CurOccupants) { if (curOccupant != pawn && LovePartnerRelationUtility.LovePartnerRelationExists(pawn, curOccupant)) { return(curOccupant); } } return(null); } return(null); }
public static Pawn GetPartnerInMyBed(Pawn pawn) { if (pawn.CurJob == null || pawn.jobs.curDriver.layingDown == LayingDownState.NotLaying) { return null; } Building_Bed building_Bed = pawn.CurrentBed(); if (building_Bed == null) { return null; } if (building_Bed.SleepingSlotsCount <= 1) { return null; } if (!LovePartnerRelationUtility.HasAnyLovePartner(pawn)) { return null; } foreach (Pawn current in building_Bed.CurOccupants) { if (current != pawn) { if (LovePartnerRelationUtility.LovePartnerRelationExists(pawn, current)) { return current; } } } return null; }
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); } 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); } 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 = (generated.gender != other.gender) ? 1f : 0.01f; float generationChanceAgeFactor = LovePartnerRelationUtility.GetGenerationChanceAgeFactor(generated); float generationChanceAgeFactor2 = LovePartnerRelationUtility.GetGenerationChanceAgeFactor(other); float generationChanceAgeGapFactor = LovePartnerRelationUtility.GetGenerationChanceAgeGapFactor(generated, other, ex); float num4 = 1f; if (generated.GetRelations(other).Any((PawnRelationDef x) => x.familyByBloodRelation)) { num4 = 0.01f; } float num5; if (request.FixedMelanin != null) { num5 = ChildRelationUtility.GetMelaninSimilarityFactor(request.FixedMelanin.Value, other.story.melanin); } else { num5 = PawnSkinColors.GetMelaninCommonalityFactor(other.story.melanin); } return(num * generationChanceAgeFactor * generationChanceAgeFactor2 * generationChanceAgeGapFactor * num3 * num5 * num4); }
public override void CreateRelation(Pawn generated, Pawn other, ref PawnGenerationRequest request) { if (generated.gender == Gender.Male) { other.SetFather(generated); ResolveMyName(ref request, other, other.GetMother()); ResolveMySkinColor(ref request, other, other.GetMother()); if (other.GetMother() != null) { if (other.GetMother().story.traits.HasTrait(TraitDefOf.Gay)) { generated.relations.AddDirectRelation(PawnRelationDefOf.ExLover, other.GetMother()); } else if (Rand.Value < 0.85f && !LovePartnerRelationUtility.HasAnyLovePartner(other.GetMother())) { generated.relations.AddDirectRelation(PawnRelationDefOf.Spouse, other.GetMother()); if (request.FixedLastName == null && Rand.Value < 0.8f) { request.SetFixedLastName(((NameTriple)other.GetMother().Name).Last); } } else { LovePartnerRelationUtility.GiveRandomExLoverOrExSpouseRelation(generated, other.GetMother()); } } } else if (generated.gender == Gender.Female) { other.SetMother(generated); ResolveMyName(ref request, other, other.GetFather()); ResolveMySkinColor(ref request, other, other.GetFather()); if (other.GetFather() != null) { if (other.GetFather().story.traits.HasTrait(TraitDefOf.Gay)) { generated.relations.AddDirectRelation(PawnRelationDefOf.ExLover, other.GetFather()); } else if (Rand.Value < 0.85f && !LovePartnerRelationUtility.HasAnyLovePartner(other.GetFather())) { generated.relations.AddDirectRelation(PawnRelationDefOf.Spouse, other.GetFather()); if (request.FixedLastName == null && Rand.Value < 0.8f) { request.SetFixedLastName(((NameTriple)other.GetFather().Name).Last); } } else { LovePartnerRelationUtility.GiveRandomExLoverOrExSpouseRelation(generated, other.GetFather()); } } } }
public override void CreateRelation(Pawn generated, Pawn other, ref PawnGenerationRequest request) { 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); }
public override void CreateRelation(Pawn generated, Pawn other, ref PawnGenerationRequest request) { bool num = other.GetMother() != null; bool flag = other.GetFather() != null; bool flag2 = Rand.Value < 0.85f; if (num && LovePartnerRelationUtility.HasAnyLovePartner(other.GetMother())) { flag2 = false; } if (flag && LovePartnerRelationUtility.HasAnyLovePartner(other.GetFather())) { flag2 = false; } if (!num) { Pawn newMother = GenerateParent(generated, other, Gender.Female, request, flag2); other.SetMother(newMother); } generated.SetMother(other.GetMother()); if (!flag) { Pawn newFather = GenerateParent(generated, other, Gender.Male, request, flag2); other.SetFather(newFather); } generated.SetFather(other.GetFather()); if (!num || !flag) { if (other.GetMother().story.traits.HasTrait(TraitDefOf.Gay) || other.GetFather().story.traits.HasTrait(TraitDefOf.Gay)) { other.GetFather().relations.AddDirectRelation(PawnRelationDefOf.ExLover, other.GetMother()); } else if (flag2) { Pawn mother = other.GetMother(); Pawn father = other.GetFather(); NameTriple nameTriple = mother.Name as NameTriple; father.relations.AddDirectRelation(PawnRelationDefOf.Spouse, mother); if (nameTriple != null) { PawnGenerationRequest request2 = default(PawnGenerationRequest); SpouseRelationUtility.ResolveNameForSpouseOnGeneration(ref request2, mother); string b = nameTriple.Last; string text = null; if (request2.FixedLastName != null) { b = request2.FixedLastName; } if (request2.FixedBirthName != null) { text = request2.FixedBirthName; } if (mother.story != null && (nameTriple.Last != b || mother.story.birthLastName != text)) { mother.story.birthLastName = text; } } } else { LovePartnerRelationUtility.GiveRandomExLoverOrExSpouseRelation(other.GetFather(), other.GetMother()); } } ResolveMyName(ref request, generated); ResolveMySkinColor(ref request, generated); }