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);
        }
Exemplo n.º 2
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&& 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);
        }
Exemplo n.º 5
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);
        }
Exemplo n.º 6
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);
        }