示例#1
0
 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)
        {
            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);
        }
示例#3
0
        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 && !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 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;
		}
示例#5
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);
        }
示例#6
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);
 }
        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);
        }
示例#8
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);
        }
        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);
        }
示例#10
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.25)
            {
                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 = (float)((!initiator.story.traits.HasTrait(TraitDefOf.Gay)) ? ((initiator.gender != Gender.Female) ? 1.0 : 0.15000000596046448) : 1.0);
            float num5 = Mathf.InverseLerp(0.25f, 1f, num);
            float num6 = Mathf.InverseLerp(5f, 100f, (float)num2);
            float num7 = (float)((initiator.gender != recipient.gender) ? ((initiator.story.traits.HasTrait(TraitDefOf.Gay) || recipient.story.traits.HasTrait(TraitDefOf.Gay)) ? 0.15000000596046448 : 1.0) : ((!initiator.story.traits.HasTrait(TraitDefOf.Gay) || !recipient.story.traits.HasTrait(TraitDefOf.Gay)) ? 0.15000000596046448 : 1.0));

            return((float)(1.1499999761581421 * num4 * num5 * num6 * num3 * num7));
        }
        public static float ChanceOfBecomingChildOf(Pawn child, Pawn father, Pawn mother, PawnGenerationRequest?childGenerationRequest, PawnGenerationRequest?fatherGenerationRequest, PawnGenerationRequest?motherGenerationRequest)
        {
            if (father != null && father.gender != Gender.Male)
            {
                Log.Warning("Tried to calculate chance for father with gender \"" + father.gender + "\".", false);
                return(0f);
            }
            if (mother != null && mother.gender != Gender.Female)
            {
                Log.Warning("Tried to calculate chance for mother with gender \"" + mother.gender + "\".", false);
                return(0f);
            }
            if (father != null && child.GetFather() != null && child.GetFather() != father)
            {
                return(0f);
            }
            if (mother != null && child.GetMother() != null && child.GetMother() != mother)
            {
                return(0f);
            }
            if (mother != null && father != null && !LovePartnerRelationUtility.LovePartnerRelationExists(mother, father) && !LovePartnerRelationUtility.ExLovePartnerRelationExists(mother, father))
            {
                return(0f);
            }
            float?melanin         = ChildRelationUtility.GetMelanin(child, childGenerationRequest);
            float?melanin2        = ChildRelationUtility.GetMelanin(father, fatherGenerationRequest);
            float?melanin3        = ChildRelationUtility.GetMelanin(mother, motherGenerationRequest);
            bool  fatherIsNew     = father != null && child.GetFather() != father;
            bool  motherIsNew     = mother != null && child.GetMother() != mother;
            float skinColorFactor = ChildRelationUtility.GetSkinColorFactor(melanin, melanin2, melanin3, fatherIsNew, motherIsNew);

            if (skinColorFactor <= 0f)
            {
                return(0f);
            }
            float num  = 1f;
            float num2 = 1f;
            float num3 = 1f;
            float num4 = 1f;

            if (father != null && child.GetFather() == null)
            {
                num = ChildRelationUtility.GetParentAgeFactor(father, child, 14f, 30f, 50f);
                if (num == 0f)
                {
                    return(0f);
                }
                if (father.story.traits.HasTrait(TraitDefOf.Gay))
                {
                    num4 = 0.1f;
                }
            }
            if (mother != null && child.GetMother() == null)
            {
                num2 = ChildRelationUtility.GetParentAgeFactor(mother, child, 16f, 27f, 45f);
                if (num2 == 0f)
                {
                    return(0f);
                }
                int num5 = ChildRelationUtility.NumberOfChildrenFemaleWantsEver(mother);
                if (mother.relations.ChildrenCount >= num5)
                {
                    return(0f);
                }
                num3 = 1f - (float)mother.relations.ChildrenCount / (float)num5;
                if (mother.story.traits.HasTrait(TraitDefOf.Gay))
                {
                    num4 = 0.1f;
                }
            }
            float num6 = 1f;

            if (mother != null)
            {
                Pawn firstDirectRelationPawn = mother.relations.GetFirstDirectRelationPawn(PawnRelationDefOf.Spouse, null);
                if (firstDirectRelationPawn != null && firstDirectRelationPawn != father)
                {
                    num6 *= 0.15f;
                }
            }
            if (father != null)
            {
                Pawn firstDirectRelationPawn2 = father.relations.GetFirstDirectRelationPawn(PawnRelationDefOf.Spouse, null);
                if (firstDirectRelationPawn2 != null && firstDirectRelationPawn2 != mother)
                {
                    num6 *= 0.15f;
                }
            }
            return(skinColorFactor * num * num2 * num3 * num6 * num4);
        }
示例#12
0
        public bool HasPersonalBedroom()
        {
            Building_Bed ownedBed = pawn.ownership.OwnedBed;

            if (ownedBed == null)
            {
                return(false);
            }
            Room ownedRoom = pawn.ownership.OwnedRoom;

            if (ownedRoom == null)
            {
                return(false);
            }
            foreach (Building_Bed containedBed in ownedRoom.ContainedBeds)
            {
                if (containedBed != ownedBed && containedBed.OwnersForReading.Any((Pawn p) => p != pawn && !p.RaceProps.Animal && !LovePartnerRelationUtility.LovePartnerRelationExists(p, pawn)))
                {
                    return(false);
                }
            }
            return(true);
        }