public static float IncestOpinionOffsetFor(Pawn other, Pawn pawn)
        {
            float num = 0f;
            List <DirectPawnRelation> directRelations = other.relations.DirectRelations;

            for (int i = 0; i < directRelations.Count; i++)
            {
                if (LovePartnerRelationUtility.IsLovePartnerRelation(directRelations[i].def))
                {
                    if (directRelations[i].otherPawn != pawn)
                    {
                        if (!directRelations[i].otherPawn.Dead)
                        {
                            foreach (PawnRelationDef current in other.GetRelations(directRelations[i].otherPawn))
                            {
                                float incestOpinionOffset = current.incestOpinionOffset;
                                if (incestOpinionOffset < num)
                                {
                                    num = incestOpinionOffset;
                                }
                            }
                        }
                    }
                }
            }
            return(num);
        }
        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 current in building_Bed.CurOccupants)
            {
                if (current != pawn)
                {
                    if (LovePartnerRelationUtility.LovePartnerRelationExists(pawn, current))
                    {
                        return(current);
                    }
                }
            }
            return(null);
        }
        private static float GetGenerationChanceAgeGapFactor(Pawn p1, Pawn p2, bool ex)
        {
            float num = Mathf.Abs(p1.ageTracker.AgeBiologicalYearsFloat - p2.ageTracker.AgeBiologicalYearsFloat);

            if (ex)
            {
                float num2 = LovePartnerRelationUtility.MinPossibleAgeGapAtMinAgeToGenerateAsLovers(p1, p2);
                if (num2 >= 0f)
                {
                    num = Mathf.Min(num, num2);
                }
                float num3 = LovePartnerRelationUtility.MinPossibleAgeGapAtMinAgeToGenerateAsLovers(p2, p1);
                if (num3 >= 0f)
                {
                    num = Mathf.Min(num, num3);
                }
            }
            if (num > 40f)
            {
                return(0f);
            }
            float value = GenMath.LerpDouble(0f, 20f, 1f, 0.001f, num);

            return(Mathf.Clamp(value, 0.001f, 1f));
        }
        public static Pawn GetMostDislikedNonPartnerBedOwner(Pawn p)
        {
            Building_Bed ownedBed = p.ownership.OwnedBed;

            if (ownedBed == null)
            {
                return(null);
            }
            Pawn pawn = null;
            int  num  = 0;

            for (int i = 0; i < ownedBed.owners.Count; i++)
            {
                if (ownedBed.owners[i] != p)
                {
                    if (!LovePartnerRelationUtility.LovePartnerRelationExists(p, ownedBed.owners[i]))
                    {
                        int num2 = p.relations.OpinionOf(ownedBed.owners[i]);
                        if (pawn == null || num2 < num)
                        {
                            pawn = ownedBed.owners[i];
                            num  = num2;
                        }
                    }
                }
            }
            return(pawn);
        }
        public static DirectPawnRelation ExistingMostLikedLovePartnerRel(Pawn p, bool allowDead)
        {
            if (!p.RaceProps.IsFlesh)
            {
                return(null);
            }
            DirectPawnRelation directPawnRelation = null;
            int num = -2147483648;
            List <DirectPawnRelation> directRelations = p.relations.DirectRelations;

            for (int i = 0; i < directRelations.Count; i++)
            {
                if (allowDead || !directRelations[i].otherPawn.Dead)
                {
                    if (LovePartnerRelationUtility.IsLovePartnerRelation(directRelations[i].def))
                    {
                        int num2 = p.relations.OpinionOf(directRelations[i].otherPawn);
                        if (directPawnRelation == null || num2 > num)
                        {
                            directPawnRelation = directRelations[i];
                            num = num2;
                        }
                    }
                }
            }
            return(directPawnRelation);
        }
        protected override ThoughtState CurrentStateInternal(Pawn p)
        {
            DirectPawnRelation directPawnRelation = LovePartnerRelationUtility.ExistingMostLikedLovePartnerRel(p, false);
            ThoughtState       result;

            if (directPawnRelation == null)
            {
                result = false;
            }
            else if (!directPawnRelation.otherPawn.IsColonist || directPawnRelation.otherPawn.IsWorldPawn() || !directPawnRelation.otherPawn.relations.everSeenByPlayer)
            {
                result = false;
            }
            else if (p.ownership.OwnedBed != null && p.ownership.OwnedBed == directPawnRelation.otherPawn.ownership.OwnedBed)
            {
                result = false;
            }
            else if (p.relations.OpinionOf(directPawnRelation.otherPawn) <= 0)
            {
                result = false;
            }
            else
            {
                result = true;
            }
            return(result);
        }
 public static void Married(Pawn firstPawn, Pawn secondPawn)
 {
     LovePartnerRelationUtility.ChangeSpouseRelationsToExSpouse(firstPawn);
     LovePartnerRelationUtility.ChangeSpouseRelationsToExSpouse(secondPawn);
     firstPawn.relations.RemoveDirectRelation(PawnRelationDefOf.Fiance, secondPawn);
     firstPawn.relations.TryRemoveDirectRelation(PawnRelationDefOf.ExSpouse, secondPawn);
     firstPawn.relations.AddDirectRelation(PawnRelationDefOf.Spouse, secondPawn);
     AddNewlyMarriedThoughts(firstPawn, secondPawn);
     AddNewlyMarriedThoughts(secondPawn, firstPawn);
     if (firstPawn.needs.mood != null)
     {
         firstPawn.needs.mood.thoughts.memories.RemoveMemoriesOfDefWhereOtherPawnIs(ThoughtDefOf.DivorcedMe, secondPawn);
     }
     if (secondPawn.needs.mood != null)
     {
         secondPawn.needs.mood.thoughts.memories.RemoveMemoriesOfDefWhereOtherPawnIs(ThoughtDefOf.DivorcedMe, firstPawn);
     }
     if (firstPawn.relations.nextMarriageNameChange != secondPawn.relations.nextMarriageNameChange)
     {
         Log.Warning("Marriage name change is different on marrying pawns. This is weird, but not harmful.");
     }
     SpouseRelationUtility.ChangeNameAfterMarriage(firstPawn, secondPawn, firstPawn.relations.nextMarriageNameChange);
     LovePartnerRelationUtility.TryToShareBed(firstPawn, secondPawn);
     TaleRecorder.RecordTale(TaleDefOf.Marriage, firstPawn, secondPawn);
 }
Exemple #8
0
 public override void CreateRelation(Pawn generated, Pawn other, ref PawnGenerationRequest request)
 {
     generated.relations.AddDirectRelation(PawnRelationDefOf.Spouse, other);
     LovePartnerRelationUtility.TryToShareChildrenForGeneratedLovePartner(generated, other, request, 1f);
     SpouseRelationUtility.ResolveNameForSpouseOnGeneration(ref request, generated);
     ResolveMySkinColor(ref request, generated, other);
 }
        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);
        }
Exemple #10
0
        public override float GenerationChance(Pawn generated, Pawn other, PawnGenerationRequest request)
        {
            float num = 1f;

            num *= this.GetOldAgeFactor(generated);
            num *= this.GetOldAgeFactor(other);
            return(LovePartnerRelationUtility.LovePartnerRelationGenerationChance(generated, other, request, false) * base.BaseGenerationChanceFactor(generated, other, request) * num);
        }
 public static void TryToShareBed(Pawn first, Pawn second)
 {
     if (LovePartnerRelationUtility.TryToShareBed_Int(first, second))
     {
         return;
     }
     LovePartnerRelationUtility.TryToShareBed_Int(second, first);
 }
 protected override ThoughtState CurrentStateInternal(Pawn p)
 {
     if (!p.RaceProps.Humanlike)
     {
         return(false);
     }
     return(LovePartnerRelationUtility.GetMostDislikedNonPartnerBedOwner(p) != null);
 }
        public static Building_Bed FindBedFor(Pawn sleeper, Pawn traveler, bool sleeperWillBePrisoner, bool checkSocialProperness, bool ignoreOtherReservations = false)
        {
            if (HealthAIUtility.ShouldSeekMedicalRest(sleeper))
            {
                if (sleeper.InBed() && sleeper.CurrentBed().Medical&& IsValidBedFor(sleeper.CurrentBed(), sleeper, traveler, sleeperWillBePrisoner, checkSocialProperness, allowMedBedEvenIfSetToNoCare: false, ignoreOtherReservations))
                {
                    return(sleeper.CurrentBed());
                }
                for (int i = 0; i < bedDefsBestToWorst_Medical.Count; i++)
                {
                    ThingDef thingDef = bedDefsBestToWorst_Medical[i];
                    if (!CanUseBedEver(sleeper, thingDef))
                    {
                        continue;
                    }
                    for (int j = 0; j < 2; j++)
                    {
                        Danger       maxDanger2   = ((j == 0) ? Danger.None : Danger.Deadly);
                        Building_Bed building_Bed = (Building_Bed)GenClosest.ClosestThingReachable(sleeper.Position, sleeper.Map, ThingRequest.ForDef(thingDef), PathEndMode.OnCell, TraverseParms.For(traveler), 9999f, (Thing b) => ((Building_Bed)b).Medical && (int)b.Position.GetDangerFor(sleeper, sleeper.Map) <= (int)maxDanger2 && IsValidBedFor(b, sleeper, traveler, sleeperWillBePrisoner, checkSocialProperness, allowMedBedEvenIfSetToNoCare: false, ignoreOtherReservations));
                        if (building_Bed != null)
                        {
                            return(building_Bed);
                        }
                    }
                }
            }
            if (sleeper.ownership != null && sleeper.ownership.OwnedBed != null && IsValidBedFor(sleeper.ownership.OwnedBed, sleeper, traveler, sleeperWillBePrisoner, checkSocialProperness, allowMedBedEvenIfSetToNoCare: false, ignoreOtherReservations))
            {
                return(sleeper.ownership.OwnedBed);
            }
            DirectPawnRelation directPawnRelation = LovePartnerRelationUtility.ExistingMostLikedLovePartnerRel(sleeper, allowDead: false);

            if (directPawnRelation != null)
            {
                Building_Bed ownedBed = directPawnRelation.otherPawn.ownership.OwnedBed;
                if (ownedBed != null && IsValidBedFor(ownedBed, sleeper, traveler, sleeperWillBePrisoner, checkSocialProperness, allowMedBedEvenIfSetToNoCare: false, ignoreOtherReservations))
                {
                    return(ownedBed);
                }
            }
            for (int k = 0; k < 2; k++)
            {
                Danger maxDanger = ((k == 0) ? Danger.None : Danger.Deadly);
                for (int l = 0; l < bedDefsBestToWorst_RestEffectiveness.Count; l++)
                {
                    ThingDef thingDef2 = bedDefsBestToWorst_RestEffectiveness[l];
                    if (CanUseBedEver(sleeper, thingDef2))
                    {
                        Building_Bed building_Bed2 = (Building_Bed)GenClosest.ClosestThingReachable(sleeper.Position, sleeper.Map, ThingRequest.ForDef(thingDef2), PathEndMode.OnCell, TraverseParms.For(traveler), 9999f, (Thing b) => !((Building_Bed)b).Medical && (int)b.Position.GetDangerFor(sleeper, sleeper.Map) <= (int)maxDanger && IsValidBedFor(b, sleeper, traveler, sleeperWillBePrisoner, checkSocialProperness, allowMedBedEvenIfSetToNoCare: false, ignoreOtherReservations));
                        if (building_Bed2 != null)
                        {
                            return(building_Bed2);
                        }
                    }
                }
            }
            return(null);
        }
		public static Pawn ExistingMostLikedLovePartner(Pawn p, bool allowDead)
		{
			DirectPawnRelation directPawnRelation = LovePartnerRelationUtility.ExistingMostLikedLovePartnerRel(p, allowDead);
			if (directPawnRelation != null)
			{
				return directPawnRelation.otherPawn;
			}
			return null;
		}
Exemple #15
0
        public override float RandomSelectionWeight(Pawn initiator, Pawn recipient)
        {
            if (LovePartnerRelationUtility.LovePartnerRelationExists(initiator, recipient))
            {
                return(0f);
            }
            float num = initiator.relations.SecondaryRomanceChanceFactor(recipient);

            if (num < 0.25f)
            {
                return(0f);
            }
            int num2 = initiator.relations.OpinionOf(recipient);

            if (num2 < 5)
            {
                return(0f);
            }
            if (recipient.relations.OpinionOf(initiator) < 5)
            {
                return(0f);
            }
            float num3 = 1f;
            Pawn  pawn = LovePartnerRelationUtility.ExistingMostLikedLovePartner(initiator, false);

            if (pawn != null)
            {
                float value = (float)initiator.relations.OpinionOf(pawn);
                num3 = Mathf.InverseLerp(50f, -50f, value);
            }
            float num4 = (!initiator.story.traits.HasTrait(TraitDefOf.Gay)) ? ((initiator.gender != Gender.Female) ? 1f : 0.15f) : 1f;
            float num5 = Mathf.InverseLerp(0.25f, 1f, num);
            float num6 = Mathf.InverseLerp(5f, 100f, (float)num2);
            float num7;

            if (initiator.gender == recipient.gender)
            {
                if (initiator.story.traits.HasTrait(TraitDefOf.Gay) && recipient.story.traits.HasTrait(TraitDefOf.Gay))
                {
                    num7 = 1f;
                }
                else
                {
                    num7 = 0.15f;
                }
            }
            else if (!initiator.story.traits.HasTrait(TraitDefOf.Gay) && !recipient.story.traits.HasTrait(TraitDefOf.Gay))
            {
                num7 = 1f;
            }
            else
            {
                num7 = 0.15f;
            }
            return(1.15f * num4 * num5 * num6 * num3 * num7);
        }
Exemple #16
0
 public override void Interacted(Pawn initiator, Pawn recipient, List <RulePackDef> extraSentencePacks, out string letterText, out string letterLabel, out LetterDef letterDef)
 {
     if (Rand.Value < this.SuccessChance(initiator, recipient))
     {
         List <Pawn> list;
         this.BreakLoverAndFianceRelations(initiator, out list);
         List <Pawn> list2;
         this.BreakLoverAndFianceRelations(recipient, out list2);
         for (int i = 0; i < list.Count; i++)
         {
             this.TryAddCheaterThought(list[i], initiator);
         }
         for (int j = 0; j < list2.Count; j++)
         {
             this.TryAddCheaterThought(list2[j], recipient);
         }
         initiator.relations.TryRemoveDirectRelation(PawnRelationDefOf.ExLover, recipient);
         initiator.relations.AddDirectRelation(PawnRelationDefOf.Lover, recipient);
         TaleRecorder.RecordTale(TaleDefOf.BecameLover, new object[]
         {
             initiator,
             recipient
         });
         initiator.needs.mood.thoughts.memories.RemoveMemoriesOfDefWhereOtherPawnIs(ThoughtDefOf.BrokeUpWithMe, recipient);
         recipient.needs.mood.thoughts.memories.RemoveMemoriesOfDefWhereOtherPawnIs(ThoughtDefOf.BrokeUpWithMe, initiator);
         initiator.needs.mood.thoughts.memories.RemoveMemoriesOfDefWhereOtherPawnIs(ThoughtDefOf.FailedRomanceAttemptOnMe, recipient);
         initiator.needs.mood.thoughts.memories.RemoveMemoriesOfDefWhereOtherPawnIs(ThoughtDefOf.FailedRomanceAttemptOnMeLowOpinionMood, recipient);
         recipient.needs.mood.thoughts.memories.RemoveMemoriesOfDefWhereOtherPawnIs(ThoughtDefOf.FailedRomanceAttemptOnMe, initiator);
         recipient.needs.mood.thoughts.memories.RemoveMemoriesOfDefWhereOtherPawnIs(ThoughtDefOf.FailedRomanceAttemptOnMeLowOpinionMood, initiator);
         if (PawnUtility.ShouldSendNotificationAbout(initiator) || PawnUtility.ShouldSendNotificationAbout(recipient))
         {
             this.GetNewLoversLetter(initiator, recipient, list, list2, out letterText, out letterLabel, out letterDef);
         }
         else
         {
             letterText  = null;
             letterLabel = null;
             letterDef   = null;
         }
         extraSentencePacks.Add(RulePackDefOf.Sentence_RomanceAttemptAccepted);
         LovePartnerRelationUtility.TryToShareBed(initiator, recipient);
     }
     else
     {
         initiator.needs.mood.thoughts.memories.TryGainMemory(ThoughtDefOf.RebuffedMyRomanceAttempt, recipient);
         recipient.needs.mood.thoughts.memories.TryGainMemory(ThoughtDefOf.FailedRomanceAttemptOnMe, initiator);
         if (recipient.relations.OpinionOf(initiator) <= 0)
         {
             recipient.needs.mood.thoughts.memories.TryGainMemory(ThoughtDefOf.FailedRomanceAttemptOnMeLowOpinionMood, initiator);
         }
         extraSentencePacks.Add(RulePackDefOf.Sentence_RomanceAttemptRejected);
         letterText  = null;
         letterLabel = null;
         letterDef   = null;
     }
 }
Exemple #17
0
 private static bool IsAnyOwnerLovePartnerOf(Building_Bed bed, Pawn sleeper)
 {
     for (int i = 0; i < bed.owners.Count; i++)
     {
         if (LovePartnerRelationUtility.LovePartnerRelationExists(sleeper, bed.owners[i]))
         {
             return(true);
         }
     }
     return(false);
 }
Exemple #18
0
 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());
             }
         }
     }
 }
        // Token: 0x0600001E RID: 30 RVA: 0x000027A0 File Offset: 0x000009A0
        public virtual void Interacted(Pawn initiator, Pawn recipient, List <RulePackDef> extraSentencePacks)
        {
            bool flag = Rand.Value < this.SuccessChance(initiator, recipient);

            if (flag)
            {
                List <Pawn> list;
                this.BreakLoverAndFianceRelations(initiator, out list);
                List <Pawn> list2;
                this.BreakLoverAndFianceRelations(recipient, out list2);
                for (int i = 0; i < list.Count; i++)
                {
                    this.TryAddCheaterThought(list[i], initiator);
                }
                for (int j = 0; j < list2.Count; j++)
                {
                    this.TryAddCheaterThought(list2[j], recipient);
                }
                initiator.relations.TryRemoveDirectRelation(PawnRelationDefOf.ExLover, recipient);
                initiator.relations.AddDirectRelation(PawnRelationDefOf.Lover, recipient);
                TaleRecorder.RecordTale(TaleDefOf.BecameLover, new object[]
                {
                    initiator,
                    recipient
                });
                initiator.needs.mood.thoughts.memories.RemoveMemoriesOfDefWhereOtherPawnIs(ThoughtDefOf.BrokeUpWithMe, recipient);
                recipient.needs.mood.thoughts.memories.RemoveMemoriesOfDefWhereOtherPawnIs(ThoughtDefOf.BrokeUpWithMe, initiator);
                initiator.needs.mood.thoughts.memories.RemoveMemoriesOfDefWhereOtherPawnIs(ThoughtDefOf.FailedRomanceAttemptOnMe, recipient);
                initiator.needs.mood.thoughts.memories.RemoveMemoriesOfDefWhereOtherPawnIs(ThoughtDefOf.FailedRomanceAttemptOnMeLowOpinionMood, recipient);
                recipient.needs.mood.thoughts.memories.RemoveMemoriesOfDefWhereOtherPawnIs(ThoughtDefOf.FailedRomanceAttemptOnMe, initiator);
                recipient.needs.mood.thoughts.memories.RemoveMemoriesOfDefWhereOtherPawnIs(ThoughtDefOf.FailedRomanceAttemptOnMeLowOpinionMood, initiator);
                bool flag2 = initiator.IsColonist || recipient.IsColonist;
                if (flag2)
                {
                    this.SendNewLoversLetter(initiator, recipient, list, list2);
                }
                extraSentencePacks.Add(RulePackDefOf.Sentence_RomanceAttemptAccepted);
                LovePartnerRelationUtility.TryToShareBed(initiator, recipient);
            }
            else
            {
                initiator.needs.mood.thoughts.memories.TryGainMemory(ThoughtDefOf.RebuffedMyRomanceAttempt, recipient);
                recipient.needs.mood.thoughts.memories.TryGainMemory(ThoughtDefOf.FailedRomanceAttemptOnMe, initiator);
                bool flag3 = recipient.relations.OpinionOf(initiator) <= 0;
                if (flag3)
                {
                    recipient.needs.mood.thoughts.memories.TryGainMemory(ThoughtDefOf.FailedRomanceAttemptOnMeLowOpinionMood, initiator);
                }
                extraSentencePacks.Add(RulePackDefOf.Sentence_RomanceAttemptRejected);
            }
        }
 public static void Married(Pawn firstPawn, Pawn secondPawn)
 {
     LovePartnerRelationUtility.ChangeSpouseRelationsToExSpouse(firstPawn);
     LovePartnerRelationUtility.ChangeSpouseRelationsToExSpouse(secondPawn);
     firstPawn.relations.RemoveDirectRelation(PawnRelationDefOf.Fiance, secondPawn);
     firstPawn.relations.TryRemoveDirectRelation(PawnRelationDefOf.ExSpouse, secondPawn);
     firstPawn.relations.AddDirectRelation(PawnRelationDefOf.Spouse, secondPawn);
     AddNewlyMarriedThoughts(firstPawn, secondPawn);
     AddNewlyMarriedThoughts(secondPawn, firstPawn);
     firstPawn.needs.mood.thoughts.memories.RemoveMemoriesOfDefWhereOtherPawnIs(ThoughtDefOf.DivorcedMe, secondPawn);
     secondPawn.needs.mood.thoughts.memories.RemoveMemoriesOfDefWhereOtherPawnIs(ThoughtDefOf.DivorcedMe, firstPawn);
     LovePartnerRelationUtility.TryToShareBed(firstPawn, secondPawn);
     TaleRecorder.RecordTale(TaleDefOf.Marriage, firstPawn, secondPawn);
 }
        protected override ThoughtState CurrentStateInternal(Pawn p)
        {
            DirectPawnRelation directPawnRelation = LovePartnerRelationUtility.ExistingMostLikedLovePartnerRel(p, allowDead: false);

            if (directPawnRelation == null)
            {
                return(false);
            }
            if (!directPawnRelation.otherPawn.IsColonist || directPawnRelation.otherPawn.IsWorldPawn() || !directPawnRelation.otherPawn.relations.everSeenByPlayer)
            {
                return(false);
            }
            return(p.relations.OpinionOf(directPawnRelation.otherPawn) != 0);
        }
        public static float GetLovinMtbHours(Pawn pawn, Pawn partner)
        {
            float result;

            if (pawn.Dead || partner.Dead)
            {
                result = -1f;
            }
            else if (DebugSettings.alwaysDoLovin)
            {
                result = 0.1f;
            }
            else if (pawn.needs.food.Starving || partner.needs.food.Starving)
            {
                result = -1f;
            }
            else if (pawn.health.hediffSet.BleedRateTotal > 0f || partner.health.hediffSet.BleedRateTotal > 0f)
            {
                result = -1f;
            }
            else
            {
                float num = LovePartnerRelationUtility.LovinMtbSinglePawnFactor(pawn);
                if (num <= 0f)
                {
                    result = -1f;
                }
                else
                {
                    float num2 = LovePartnerRelationUtility.LovinMtbSinglePawnFactor(partner);
                    if (num2 <= 0f)
                    {
                        result = -1f;
                    }
                    else
                    {
                        float num3 = 12f;
                        num3  *= num;
                        num3  *= num2;
                        num3  /= Mathf.Max(pawn.relations.SecondaryLovinChanceFactor(partner), 0.1f);
                        num3  /= Mathf.Max(partner.relations.SecondaryLovinChanceFactor(pawn), 0.1f);
                        num3  *= GenMath.LerpDouble(-100f, 100f, 1.3f, 0.7f, (float)pawn.relations.OpinionOf(partner));
                        num3  *= GenMath.LerpDouble(-100f, 100f, 1.3f, 0.7f, (float)partner.relations.OpinionOf(pawn));
                        result = num3;
                    }
                }
            }
            return(result);
        }
        public override float RandomSelectionWeight(Pawn initiator, Pawn recipient)
        {
            if (!LovePartnerRelationUtility.LovePartnerRelationExists(initiator, recipient))
            {
                return(0f);
            }
            float num  = Mathf.InverseLerp(100f, -100f, initiator.relations.OpinionOf(recipient));
            float num2 = 1f;

            if (initiator.relations.DirectRelationExists(PawnRelationDefOf.Spouse, recipient))
            {
                num2 = 0.4f;
            }
            return(0.02f * num * num2);
        }
 protected override ThoughtState CurrentSocialStateInternal(Pawn pawn, Pawn other)
 {
     if (!other.RaceProps.Humanlike)
     {
         return(false);
     }
     if (!RelationsUtility.PawnsKnowEachOther(pawn, other))
     {
         return(false);
     }
     if (LovePartnerRelationUtility.IncestOpinionOffsetFor(other, pawn) == 0f)
     {
         return(false);
     }
     return(true);
 }
        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 static void Married(Pawn firstPawn, Pawn secondPawn)
 {
     LovePartnerRelationUtility.ChangeSpouseRelationsToExSpouse(firstPawn);
     LovePartnerRelationUtility.ChangeSpouseRelationsToExSpouse(secondPawn);
     firstPawn.relations.RemoveDirectRelation(PawnRelationDefOf.Fiance, secondPawn);
     firstPawn.relations.TryRemoveDirectRelation(PawnRelationDefOf.ExSpouse, secondPawn);
     firstPawn.relations.AddDirectRelation(PawnRelationDefOf.Spouse, secondPawn);
     MarriageCeremonyUtility.AddNewlyMarriedThoughts(firstPawn, secondPawn);
     MarriageCeremonyUtility.AddNewlyMarriedThoughts(secondPawn, firstPawn);
     firstPawn.needs.mood.thoughts.RemoveSocialThoughts(ThoughtDefOf.DivorcedMe, secondPawn);
     secondPawn.needs.mood.thoughts.RemoveSocialThoughts(ThoughtDefOf.DivorcedMe, firstPawn);
     LovePartnerRelationUtility.TryToShareBed(firstPawn, secondPawn);
     TaleRecorder.RecordTale(TaleDefOf.Marriage, new object[]
     {
         firstPawn,
         secondPawn
     });
 }
Exemple #27
0
        public override float RandomSelectionWeight(Pawn initiator, Pawn recipient)
        {
            if (TutorSystem.TutorialMode)
            {
                return(0f);
            }
            if (LovePartnerRelationUtility.LovePartnerRelationExists(initiator, recipient))
            {
                return(0f);
            }
            float num = initiator.relations.SecondaryRomanceChanceFactor(recipient);

            if (num < 0.15f)
            {
                return(0f);
            }
            int num2 = initiator.relations.OpinionOf(recipient);

            if (num2 < 5)
            {
                return(0f);
            }
            if (recipient.relations.OpinionOf(initiator) < 5)
            {
                return(0f);
            }
            float num3 = 1f;
            Pawn  pawn = LovePartnerRelationUtility.ExistingMostLikedLovePartner(initiator, allowDead: false);

            if (pawn != null)
            {
                float value = initiator.relations.OpinionOf(pawn);
                num3 = Mathf.InverseLerp(50f, -50f, value);
            }
            float num4 = (initiator.story.traits.HasTrait(TraitDefOf.Gay) ? 1f : ((initiator.gender == Gender.Female) ? 0.15f : 1f));
            float num5 = Mathf.InverseLerp(0.15f, 1f, num);
            float num6 = Mathf.InverseLerp(5f, 100f, num2);
            float num7 = ((initiator.gender == recipient.gender) ? ((!initiator.story.traits.HasTrait(TraitDefOf.Gay) || !recipient.story.traits.HasTrait(TraitDefOf.Gay)) ? 0.15f : 1f) : ((initiator.story.traits.HasTrait(TraitDefOf.Gay) || recipient.story.traits.HasTrait(TraitDefOf.Gay)) ? 0.15f : 1f));

            return(1.15f * num4 * num5 * num6 * num3 * num7);
        }
Exemple #28
0
 protected override Job TryGiveJob(Pawn pawn)
 {
     if (Find.TickManager.TicksGame < pawn.mindState.canLovinTick)
     {
         return(null);
     }
     if (pawn.CurrentBed() != null && !pawn.CurrentBed().Medical&& pawn.health.capacities.CanBeAwake)
     {
         Pawn partnerInMyBed = LovePartnerRelationUtility.GetPartnerInMyBed(pawn);
         if (partnerInMyBed != null && partnerInMyBed.health.capacities.CanBeAwake && Find.TickManager.TicksGame >= partnerInMyBed.mindState.canLovinTick)
         {
             if (pawn.CanReserve(partnerInMyBed, 1, -1, null, false) && partnerInMyBed.CanReserve(pawn, 1, -1, null, false))
             {
                 return(new Job(JobDefOf.Lovin, partnerInMyBed, pawn.CurrentBed()));
             }
             return(null);
         }
         return(null);
     }
     return(null);
 }
        public override float RandomSelectionWeight(Pawn initiator, Pawn recipient)
        {
            if (!LovePartnerRelationUtility.LovePartnerRelationExists(initiator, recipient))
            {
                return(0f);
            }
            float num  = Mathf.InverseLerp(100f, -100f, initiator.relations.OpinionOf(recipient));
            float num2 = 1f;

            if (initiator.relations.DirectRelationExists(PawnRelationDefOf.Spouse, recipient))
            {
                num2 = 0.4f;
            }
            float            num3             = 1f;
            HediffWithTarget hediffWithTarget = (HediffWithTarget)initiator.health.hediffSet.GetFirstHediffOfDef(HediffDefOf.PsychicLove);

            if (hediffWithTarget != null && hediffWithTarget.target == recipient)
            {
                num3 = 0.1f;
            }
            return(0.02f * num * num2 * num3);
        }
Exemple #30
0
        protected override Job TryGiveJob(Pawn pawn)
        {
            if (Find.TickManager.TicksGame < pawn.mindState.canLovinTick)
            {
                return(null);
            }
            if (pawn.CurrentBed() == null || pawn.CurrentBed().Medical || !pawn.health.capacities.CanBeAwake)
            {
                return(null);
            }
            Pawn partnerInMyBed = LovePartnerRelationUtility.GetPartnerInMyBed(pawn);

            if (partnerInMyBed == null || !partnerInMyBed.health.capacities.CanBeAwake || Find.TickManager.TicksGame < partnerInMyBed.mindState.canLovinTick)
            {
                return(null);
            }
            if (!pawn.CanReserve(partnerInMyBed) || !partnerInMyBed.CanReserve(pawn))
            {
                return(null);
            }
            return(JobMaker.MakeJob(JobDefOf.Lovin, partnerInMyBed, pawn.CurrentBed()));
        }