public bool TryRemoveDirectRelation(PawnRelationDef def, Pawn otherPawn)
 {
     if (def.implied)
     {
         Log.Warning("Tried to remove implied pawn relation " + def + ", pawn=" + this.pawn + ", otherPawn=" + otherPawn);
         return(false);
     }
     for (int i = 0; i < this.directRelations.Count; i++)
     {
         if (this.directRelations[i].def == def && this.directRelations[i].otherPawn == otherPawn)
         {
             if (def.reflexive)
             {
                 List <DirectPawnRelation> list = otherPawn.relations.directRelations;
                 DirectPawnRelation        item = list.Find((DirectPawnRelation x) => x.def == def && x.otherPawn == this.pawn);
                 list.Remove(item);
                 if (list.Find((DirectPawnRelation x) => x.otherPawn == this.pawn) == null)
                 {
                     this.pawnsWithDirectRelationsWithMe.Remove(otherPawn);
                 }
             }
             this.directRelations.RemoveAt(i);
             if (this.directRelations.Find((DirectPawnRelation x) => x.otherPawn == otherPawn) == null)
             {
                 otherPawn.relations.pawnsWithDirectRelationsWithMe.Remove(this.pawn);
             }
             this.GainedOrLostDirectRelation();
             otherPawn.relations.GainedOrLostDirectRelation();
             return(true);
         }
     }
     return(false);
 }
        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 override float RandomSelectionWeight(Pawn initiator, Pawn recipient)
		{
			DirectPawnRelation directRelation = initiator.relations.GetDirectRelation(PawnRelationDefOf.Lover, recipient);
			if (directRelation == null)
			{
				return 0f;
			}
			Pawn spouse = recipient.GetSpouse();
			Pawn spouse2 = initiator.GetSpouse();
			if (spouse != null && !spouse.Dead)
			{
				goto IL_004e;
			}
			if (spouse2 != null && !spouse2.Dead)
				goto IL_004e;
			float num = 0.4f;
			int ticksGame = Find.TickManager.TicksGame;
			float value = (float)((float)(ticksGame - directRelation.startTicks) / 60000.0);
			num *= Mathf.InverseLerp(0f, 60f, value);
			num *= Mathf.InverseLerp(0f, 60f, (float)initiator.relations.OpinionOf(recipient));
			if (recipient.relations.OpinionOf(initiator) < 0)
			{
				num = (float)(num * 0.30000001192092896);
			}
			if (initiator.gender == Gender.Female)
			{
				num = (float)(num * 0.20000000298023224);
			}
			return num;
			IL_004e:
			return 0f;
		}
 public bool TryRemoveDirectRelation(PawnRelationDef def, Pawn otherPawn)
 {
     if (def.implied)
     {
         Log.Warning(string.Concat("Tried to remove implied pawn relation ", def, ", pawn=", pawn, ", otherPawn=", otherPawn));
         return(false);
     }
     for (int i = 0; i < directRelations.Count; i++)
     {
         if (directRelations[i].def != def || directRelations[i].otherPawn != otherPawn)
         {
             continue;
         }
         if (def.reflexive)
         {
             List <DirectPawnRelation> list = otherPawn.relations.directRelations;
             DirectPawnRelation        item = list.Find((DirectPawnRelation x) => x.def == def && x.otherPawn == pawn);
             list.Remove(item);
             if (list.Find((DirectPawnRelation x) => x.otherPawn == pawn) == null)
             {
                 pawnsWithDirectRelationsWithMe.Remove(otherPawn);
             }
         }
         directRelations.RemoveAt(i);
         if (directRelations.Find((DirectPawnRelation x) => x.otherPawn == otherPawn) == null)
         {
             otherPawn.relations.pawnsWithDirectRelationsWithMe.Remove(pawn);
         }
         GainedOrLostDirectRelation();
         otherPawn.relations.GainedOrLostDirectRelation();
         return(true);
     }
     return(false);
 }
        public static DirectPawnRelation ExistingMostLikedLovePartnerRel(Pawn p, bool allowDead)
        {
            if (!p.RaceProps.IsFlesh)
            {
                return(null);
            }
            DirectPawnRelation directPawnRelation = null;
            int num = int.MinValue;
            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);
        }
        public override float RandomSelectionWeight(Pawn initiator, Pawn recipient)
        {
            DirectPawnRelation directRelation = initiator.relations.GetDirectRelation(PawnRelationDefOf.Lover, recipient);

            if (directRelation == null)
            {
                return(0f);
            }
            Pawn spouse  = recipient.GetSpouse();
            Pawn spouse2 = initiator.GetSpouse();

            if ((spouse != null && !spouse.Dead) || (spouse2 != null && !spouse2.Dead))
            {
                return(0f);
            }
            float num       = 0.4f;
            int   ticksGame = Find.TickManager.TicksGame;
            float value     = (float)(ticksGame - directRelation.startTicks) / 60000f;

            num *= Mathf.InverseLerp(0f, 60f, value);
            num *= Mathf.InverseLerp(0f, 60f, (float)initiator.relations.OpinionOf(recipient));
            if (recipient.relations.OpinionOf(initiator) < 0)
            {
                num *= 0.3f;
            }
            if (initiator.gender == Gender.Female)
            {
                num *= 0.2f;
            }
            return(num);
        }
        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;
		}
        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);
        }
        protected override ThoughtState CurrentStateInternal(Pawn p)
        {
            List <DirectPawnRelation> directRelations = p.relations.DirectRelations;

            for (int i = 0; i < directRelations.Count; i++)
            {
                DirectPawnRelation directPawnRelation = directRelations[i];
                Pawn otherPawn = directPawnRelation.otherPawn;
                if (directPawnRelation.def == PawnRelationDefOf.Bond && !otherPawn.Dead && otherPawn.Spawned && otherPawn.Faction == Faction.OfPlayer && otherPawn.training.IsCompleted(TrainableDefOf.Obedience) && p.skills.GetSkill(SkillDefOf.Animals).Level >= TrainableUtility.MinimumHandlingSkill(otherPawn) && this.AnimalMasterCheck(p, otherPawn))
                {
                    return(ThoughtState.ActiveWithReason(otherPawn.LabelShort));
                }
            }
            return(false);
        }
        public void GetAnimals(Pawn p, List <string> outAnimals)
        {
            outAnimals.Clear();
            List <DirectPawnRelation> directRelations = p.relations.DirectRelations;

            for (int i = 0; i < directRelations.Count; i++)
            {
                DirectPawnRelation directPawnRelation = directRelations[i];
                Pawn otherPawn = directPawnRelation.otherPawn;
                if (directPawnRelation.def == PawnRelationDefOf.Bond && !otherPawn.Dead && otherPawn.Spawned && otherPawn.Faction == Faction.OfPlayer && otherPawn.training.HasLearned(TrainableDefOf.Obedience) && AnimalMasterCheck(p, otherPawn))
                {
                    outAnimals.Add(otherPawn.LabelShort);
                }
            }
        }
		public static Pawn GetFather(this Pawn pawn)
		{
			if (!pawn.RaceProps.IsFlesh)
			{
				return null;
			}
			List<DirectPawnRelation> directRelations = pawn.relations.DirectRelations;
			for (int i = 0; i < directRelations.Count; i++)
			{
				DirectPawnRelation directPawnRelation = directRelations[i];
				if (directPawnRelation.def == PawnRelationDefOf.Parent && directPawnRelation.otherPawn.gender != Gender.Female)
				{
					return directPawnRelation.otherPawn;
				}
			}
			return null;
		}
 public bool DirectRelationExists(PawnRelationDef def, Pawn otherPawn)
 {
     if (def.implied)
     {
         Log.Warning(def + " is not a direct relation.");
         return(false);
     }
     for (int i = 0; i < this.directRelations.Count; i++)
     {
         DirectPawnRelation directPawnRelation = this.directRelations[i];
         if (directPawnRelation.def == def && directPawnRelation.otherPawn == otherPawn)
         {
             return(true);
         }
     }
     return(false);
 }
 public Pawn GetFirstDirectRelationPawn(PawnRelationDef def, Predicate <Pawn> predicate = null)
 {
     if (def.implied)
     {
         Log.Warning(def + " is not a direct relation.");
         return(null);
     }
     for (int i = 0; i < this.directRelations.Count; i++)
     {
         DirectPawnRelation directPawnRelation = this.directRelations[i];
         if (directPawnRelation.def == def && (predicate == null || predicate(directPawnRelation.otherPawn)))
         {
             return(directPawnRelation.otherPawn);
         }
     }
     return(null);
 }
        public static Pawn GetMother(this Pawn pawn)
        {
            Pawn result;

            if (!pawn.RaceProps.IsFlesh)
            {
                result = null;
            }
            else
            {
                List <DirectPawnRelation> directRelations = pawn.relations.DirectRelations;
                for (int i = 0; i < directRelations.Count; i++)
                {
                    DirectPawnRelation directPawnRelation = directRelations[i];
                    if (directPawnRelation.def == PawnRelationDefOf.Parent && directPawnRelation.otherPawn.gender == Gender.Female)
                    {
                        return(directPawnRelation.otherPawn);
                    }
                }
                result = null;
            }
            return(result);
        }
        public override float RandomSelectionWeight(Pawn initiator, Pawn recipient)
        {
            DirectPawnRelation directRelation = initiator.relations.GetDirectRelation(PawnRelationDefOf.Lover, recipient);

            if (directRelation == null)
            {
                return(0f);
            }
            Pawn spouse  = recipient.GetSpouse();
            Pawn spouse2 = initiator.GetSpouse();

            if ((spouse != null && !spouse.Dead) || (spouse2 != null && !spouse2.Dead))
            {
                return(0f);
            }
            float num   = 0.4f;
            float value = (float)(Find.TickManager.TicksGame - directRelation.startTicks) / 60000f;

            num *= Mathf.InverseLerp(0f, 60f, value);
            num *= Mathf.InverseLerp(0f, 60f, initiator.relations.OpinionOf(recipient));
            if (recipient.relations.OpinionOf(initiator) < 0)
            {
                num *= 0.3f;
            }
            if (initiator.gender == Gender.Female)
            {
                num *= 0.2f;
            }
            HediffWithTarget hediffWithTarget = (HediffWithTarget)initiator.health.hediffSet.GetFirstHediffOfDef(HediffDefOf.PsychicLove);

            if (hediffWithTarget != null && hediffWithTarget.target == recipient)
            {
                num *= 10f;
            }
            return(num);
        }
 public void RemoveDirectRelation(DirectPawnRelation relation)
 {
     this.RemoveDirectRelation(relation.def, relation.otherPawn);
 }
 internal bool <> m__0(DirectPawnRelation x)
 {
     return(LovePartnerRelationUtility.IsLovePartnerRelation(x.def) && x.otherPawn.gender == this.pawn.gender);
 }
Exemple #19
0
        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)
                {
                    Building_Bed bedThing  = sleeper.CurrentBed();
                    Pawn         sleeper2  = sleeper;
                    Pawn         traveler2 = traveler;
                    bool         sleeperWillBePrisoner2   = sleeperWillBePrisoner;
                    bool         checkSocialProperness2   = checkSocialProperness;
                    bool         ignoreOtherReservations2 = ignoreOtherReservations;
                    if (IsValidBedFor(bedThing, sleeper2, traveler2, sleeperWillBePrisoner2, checkSocialProperness2, allowMedBedEvenIfSetToNoCare: false, ignoreOtherReservations2))
                    {
                        return(sleeper.CurrentBed());
                    }
                }
                for (int i = 0; i < bedDefsBestToWorst_Medical.Count; i++)
                {
                    ThingDef thingDef = bedDefsBestToWorst_Medical[i];
                    if (CanUseBedEver(sleeper, thingDef))
                    {
                        for (int j = 0; j < 2; j++)
                        {
                            Danger       maxDanger    = (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, delegate(Thing b)
                            {
                                int result2;
                                if (((Building_Bed)b).Medical && (int)b.Position.GetDangerFor(sleeper, sleeper.Map) <= (int)maxDanger)
                                {
                                    Pawn sleeper4  = sleeper;
                                    Pawn traveler4 = traveler;
                                    bool sleeperWillBePrisoner4   = sleeperWillBePrisoner;
                                    bool checkSocialProperness4   = checkSocialProperness;
                                    bool ignoreOtherReservations4 = ignoreOtherReservations;
                                    result2 = (IsValidBedFor(b, sleeper4, traveler4, sleeperWillBePrisoner4, checkSocialProperness4, allowMedBedEvenIfSetToNoCare: false, ignoreOtherReservations4) ? 1 : 0);
                                }
                                else
                                {
                                    result2 = 0;
                                }
                                return((byte)result2 != 0);
                            });
                            if (building_Bed != null)
                            {
                                return(building_Bed);
                            }
                        }
                    }
                }
            }
            if (sleeper.ownership != null && sleeper.ownership.OwnedBed != null)
            {
                Building_Bed bedThing  = sleeper.ownership.OwnedBed;
                Pawn         traveler2 = sleeper;
                Pawn         sleeper2  = traveler;
                bool         ignoreOtherReservations2 = sleeperWillBePrisoner;
                bool         checkSocialProperness2   = checkSocialProperness;
                bool         sleeperWillBePrisoner2   = ignoreOtherReservations;
                if (IsValidBedFor(bedThing, traveler2, sleeper2, ignoreOtherReservations2, checkSocialProperness2, allowMedBedEvenIfSetToNoCare: false, sleeperWillBePrisoner2))
                {
                    return(sleeper.ownership.OwnedBed);
                }
            }
            DirectPawnRelation directPawnRelation = LovePartnerRelationUtility.ExistingMostLikedLovePartnerRel(sleeper, allowDead: false);

            if (directPawnRelation != null)
            {
                Building_Bed ownedBed = directPawnRelation.otherPawn.ownership.OwnedBed;
                if (ownedBed != null)
                {
                    Building_Bed bedThing  = ownedBed;
                    Pawn         sleeper2  = sleeper;
                    Pawn         traveler2 = traveler;
                    bool         sleeperWillBePrisoner2   = sleeperWillBePrisoner;
                    bool         checkSocialProperness2   = checkSocialProperness;
                    bool         ignoreOtherReservations2 = ignoreOtherReservations;
                    if (IsValidBedFor(bedThing, sleeper2, traveler2, sleeperWillBePrisoner2, checkSocialProperness2, allowMedBedEvenIfSetToNoCare: false, ignoreOtherReservations2))
                    {
                        return(ownedBed);
                    }
                }
            }
            for (int k = 0; k < 2; k++)
            {
                Danger maxDanger2 = (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, delegate(Thing b)
                        {
                            int result;
                            if (!((Building_Bed)b).Medical && (int)b.Position.GetDangerFor(sleeper, sleeper.Map) <= (int)maxDanger2)
                            {
                                Pawn sleeper3  = sleeper;
                                Pawn traveler3 = traveler;
                                bool sleeperWillBePrisoner3   = sleeperWillBePrisoner;
                                bool checkSocialProperness3   = checkSocialProperness;
                                bool ignoreOtherReservations3 = ignoreOtherReservations;
                                result = (IsValidBedFor(b, sleeper3, traveler3, sleeperWillBePrisoner3, checkSocialProperness3, allowMedBedEvenIfSetToNoCare: false, ignoreOtherReservations3) ? 1 : 0);
                            }
                            else
                            {
                                result = 0;
                            }
                            return((byte)result != 0);
                        });
                        if (building_Bed2 != null)
                        {
                            return(building_Bed2);
                        }
                    }
                }
            }
            return(null);
        }
 private static bool <GetAllColonistBondsFor> m__2(DirectPawnRelation bond)
 {
     return(bond.def == PawnRelationDefOf.Bond && bond.otherPawn != null && bond.otherPawn.IsColonistPlayerControlled);
 }
 private static Pawn <GetAllColonistBondsFor> m__3(DirectPawnRelation bond)
 {
     return(bond.otherPawn);
 }
Exemple #22
0
        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)
                {
                    Building_Bed bedThing = sleeper.CurrentBed();
                    Pawn         pawn     = sleeper;
                    Pawn         pawn2    = traveler;
                    bool         flag     = sleeperWillBePrisoner;
                    bool         checkSocialProperness2 = checkSocialProperness;
                    bool         flag2 = ignoreOtherReservations;
                    if (RestUtility.IsValidBedFor(bedThing, pawn, pawn2, flag, checkSocialProperness2, false, flag2))
                    {
                        return(sleeper.CurrentBed());
                    }
                }
                for (int i = 0; i < RestUtility.bedDefsBestToWorst_Medical.Count; i++)
                {
                    ThingDef thingDef = RestUtility.bedDefsBestToWorst_Medical[i];
                    if (RestUtility.CanUseBedEver(sleeper, thingDef))
                    {
                        for (int j = 0; j < 2; j++)
                        {
                            Danger       maxDanger    = (j != 0) ? Danger.Deadly : Danger.None;
                            Building_Bed building_Bed = (Building_Bed)GenClosest.ClosestThingReachable(sleeper.Position, sleeper.Map, ThingRequest.ForDef(thingDef), PathEndMode.OnCell, TraverseParms.For(traveler, Danger.Deadly, TraverseMode.ByPawn, false), 9999f, delegate(Thing b)
                            {
                                bool arg_92_0;
                                if (((Building_Bed)b).Medical && b.Position.GetDangerFor(sleeper, sleeper.Map) <= maxDanger)
                                {
                                    Pawn sleeper2  = sleeper;
                                    Pawn traveler2 = traveler;
                                    bool sleeperWillBePrisoner2   = sleeperWillBePrisoner;
                                    bool checkSocialProperness3   = checkSocialProperness;
                                    bool ignoreOtherReservations2 = ignoreOtherReservations;
                                    arg_92_0 = RestUtility.IsValidBedFor(b, sleeper2, traveler2, sleeperWillBePrisoner2, checkSocialProperness3, false, ignoreOtherReservations2);
                                }
                                else
                                {
                                    arg_92_0 = false;
                                }
                                return(arg_92_0);
                            }, null, 0, -1, false, RegionType.Set_Passable, false);
                            if (building_Bed != null)
                            {
                                return(building_Bed);
                            }
                        }
                    }
                }
            }
            if (sleeper.ownership != null && sleeper.ownership.OwnedBed != null)
            {
                Building_Bed bedThing = sleeper.ownership.OwnedBed;
                Pawn         pawn2    = sleeper;
                Pawn         pawn     = traveler;
                bool         flag2    = sleeperWillBePrisoner;
                bool         checkSocialProperness2 = checkSocialProperness;
                bool         flag = ignoreOtherReservations;
                if (RestUtility.IsValidBedFor(bedThing, pawn2, pawn, flag2, checkSocialProperness2, false, flag))
                {
                    return(sleeper.ownership.OwnedBed);
                }
            }
            DirectPawnRelation directPawnRelation = LovePartnerRelationUtility.ExistingMostLikedLovePartnerRel(sleeper, false);

            if (directPawnRelation != null)
            {
                Building_Bed ownedBed = directPawnRelation.otherPawn.ownership.OwnedBed;
                if (ownedBed != null)
                {
                    Building_Bed bedThing = ownedBed;
                    Pawn         pawn     = sleeper;
                    Pawn         pawn2    = traveler;
                    bool         flag     = sleeperWillBePrisoner;
                    bool         checkSocialProperness2 = checkSocialProperness;
                    bool         flag2 = ignoreOtherReservations;
                    if (RestUtility.IsValidBedFor(bedThing, pawn, pawn2, flag, checkSocialProperness2, false, flag2))
                    {
                        return(ownedBed);
                    }
                }
            }
            for (int k = 0; k < 2; k++)
            {
                Danger maxDanger = (k != 0) ? Danger.Deadly : Danger.None;
                for (int l = 0; l < RestUtility.bedDefsBestToWorst_RestEffectiveness.Count; l++)
                {
                    ThingDef thingDef2 = RestUtility.bedDefsBestToWorst_RestEffectiveness[l];
                    if (RestUtility.CanUseBedEver(sleeper, thingDef2))
                    {
                        Building_Bed building_Bed2 = (Building_Bed)GenClosest.ClosestThingReachable(sleeper.Position, sleeper.Map, ThingRequest.ForDef(thingDef2), PathEndMode.OnCell, TraverseParms.For(traveler, Danger.Deadly, TraverseMode.ByPawn, false), 9999f, delegate(Thing b)
                        {
                            bool arg_92_0;
                            if (!((Building_Bed)b).Medical && b.Position.GetDangerFor(sleeper, sleeper.Map) <= maxDanger)
                            {
                                Pawn sleeper2  = sleeper;
                                Pawn traveler2 = traveler;
                                bool sleeperWillBePrisoner2   = sleeperWillBePrisoner;
                                bool checkSocialProperness3   = checkSocialProperness;
                                bool ignoreOtherReservations2 = ignoreOtherReservations;
                                arg_92_0 = RestUtility.IsValidBedFor(b, sleeper2, traveler2, sleeperWillBePrisoner2, checkSocialProperness3, false, ignoreOtherReservations2);
                            }
                            else
                            {
                                arg_92_0 = false;
                            }
                            return(arg_92_0);
                        }, null, 0, -1, false, RegionType.Set_Passable, false);
                        if (building_Bed2 != null)
                        {
                            return(building_Bed2);
                        }
                    }
                }
            }
            return(null);
        }
Exemple #23
0
 internal bool <> m__1(DirectPawnRelation x)
 {
     return(x.otherPawn == this.p1);
 }