Exemple #1
0
        private static void ApplyBedThoughts(Pawn actor)
        {
            if (actor.needs.mood == null)
            {
                return;
            }
            Building_Bed building_Bed = actor.CurrentBed();

            actor.needs.mood.thoughts.memories.RemoveMemoriesOfDef(ThoughtDefOf.SleptInBedroom);
            actor.needs.mood.thoughts.memories.RemoveMemoriesOfDef(ThoughtDefOf.SleptInBarracks);
            actor.needs.mood.thoughts.memories.RemoveMemoriesOfDef(ThoughtDefOf.SleptOutside);
            actor.needs.mood.thoughts.memories.RemoveMemoriesOfDef(ThoughtDefOf.SleptOnGround);
            actor.needs.mood.thoughts.memories.RemoveMemoriesOfDef(ThoughtDefOf.SleptInCold);
            actor.needs.mood.thoughts.memories.RemoveMemoriesOfDef(ThoughtDefOf.SleptInHeat);
            if (actor.GetRoom().PsychologicallyOutdoors)
            {
                actor.needs.mood.thoughts.memories.TryGainMemory(ThoughtDefOf.SleptOutside);
            }
            if (building_Bed == null || building_Bed.CostListAdjusted().Count == 0)
            {
                actor.needs.mood.thoughts.memories.TryGainMemory(ThoughtDefOf.SleptOnGround);
            }
            if (actor.AmbientTemperature < actor.def.GetStatValueAbstract(StatDefOf.ComfyTemperatureMin))
            {
                actor.needs.mood.thoughts.memories.TryGainMemory(ThoughtDefOf.SleptInCold);
            }
            if (actor.AmbientTemperature > actor.def.GetStatValueAbstract(StatDefOf.ComfyTemperatureMax))
            {
                actor.needs.mood.thoughts.memories.TryGainMemory(ThoughtDefOf.SleptInHeat);
            }
            if (building_Bed == null || building_Bed != actor.ownership.OwnedBed || building_Bed.ForPrisoners || actor.story.traits.HasTrait(TraitDefOf.Ascetic))
            {
                return;
            }
            ThoughtDef thoughtDef = null;

            if (building_Bed.GetRoom().Role == RoomRoleDefOf.Bedroom)
            {
                thoughtDef = ThoughtDefOf.SleptInBedroom;
            }
            else if (building_Bed.GetRoom().Role == RoomRoleDefOf.Barracks)
            {
                thoughtDef = ThoughtDefOf.SleptInBarracks;
            }
            if (thoughtDef != null)
            {
                int scoreStageIndex = RoomStatDefOf.Impressiveness.GetScoreStageIndex(building_Bed.GetRoom().GetStat(RoomStatDefOf.Impressiveness));
                if (thoughtDef.stages[scoreStageIndex] != null)
                {
                    actor.needs.mood.thoughts.memories.TryGainMemory(ThoughtMaker.MakeThought(thoughtDef, scoreStageIndex));
                }
            }
        }
        private Job TakeToPreferredBedJob(Pawn prisoner, Pawn warden)
        {
            Job result;

            if (prisoner.Downed || !warden.CanReserve(prisoner, 1, -1, null, false))
            {
                result = null;
            }
            else if (RestUtility.FindBedFor(prisoner, prisoner, true, true, false) != null)
            {
                result = null;
            }
            else
            {
                Room         room         = prisoner.GetRoom(RegionType.Set_Passable);
                Building_Bed building_Bed = RestUtility.FindBedFor(prisoner, warden, true, false, false);
                if (building_Bed != null && building_Bed.GetRoom(RegionType.Set_Passable) != room)
                {
                    result = new Job(JobDefOf.EscortPrisonerToBed, prisoner, building_Bed)
                    {
                        count = 1
                    };
                }
                else
                {
                    result = null;
                }
            }
            return(result);
        }
 private Job TakeToPreferredBedJob(Pawn prisoner, Pawn warden)
 {
     if (!prisoner.Downed && warden.CanReserve(prisoner, 1, -1, null, false))
     {
         if (RestUtility.FindBedFor(prisoner, prisoner, true, true, false) != null)
         {
             return(null);
         }
         Room         room         = prisoner.GetRoom(RegionType.Set_Passable);
         Building_Bed building_Bed = RestUtility.FindBedFor(prisoner, warden, true, false, false);
         if (building_Bed != null && building_Bed.GetRoom(RegionType.Set_Passable) != room)
         {
             Job job = new Job(JobDefOf.EscortPrisonerToBed, prisoner, building_Bed);
             job.count = 1;
             return(job);
         }
         return(null);
     }
     return(null);
 }
Exemple #4
0
        private Job TakeToPreferredBedJob(Pawn prisoner, Pawn warden)
        {
            if (prisoner.Downed || !warden.CanReserve(prisoner))
            {
                return(null);
            }
            if (RestUtility.FindBedFor(prisoner, prisoner, sleeperWillBePrisoner: true, checkSocialProperness: true) != null)
            {
                return(null);
            }
            Room         room         = prisoner.GetRoom();
            Building_Bed building_Bed = RestUtility.FindBedFor(prisoner, warden, sleeperWillBePrisoner: true, checkSocialProperness: false);

            if (building_Bed != null && building_Bed.GetRoom() != room)
            {
                Job job = JobMaker.MakeJob(JobDefOf.EscortPrisonerToBed, prisoner, building_Bed);
                job.count = 1;
                return(job);
            }
            return(null);
        }
        public static IEnumerable <LocalTargetInfo> AllMeditationSpotCandidates(Pawn pawn, bool allowFallbackSpots = true)
        {
            bool flag = false;

            if (pawn.royalty != null && pawn.royalty.AllTitlesInEffectForReading.Count > 0 && !pawn.IsPrisonerOfColony)
            {
                Building_Throne building_Throne = RoyalTitleUtility.FindBestUsableThrone(pawn);
                if (building_Throne != null)
                {
                    yield return(building_Throne);

                    flag = true;
                }
            }
            if (!pawn.IsPrisonerOfColony)
            {
                foreach (Building item in pawn.Map.listerBuildings.AllBuildingsColonistOfDef(ThingDefOf.MeditationSpot).Where(delegate(Building s)
                {
                    if (s.IsForbidden(pawn) || !s.Position.Standable(s.Map))
                    {
                        return(false);
                    }
                    if (s.GetAssignedPawn() != null && s.GetAssignedPawn() != pawn)
                    {
                        return(false);
                    }
                    Room room4 = s.GetRoom();
                    return((room4 == null || CanUseRoomToMeditate(room4, pawn)) && pawn.CanReserveAndReach(s, PathEndMode.OnCell, pawn.NormalMaxDanger()));
                }))
                {
                    yield return(item);

                    flag = true;
                }
            }
            if (flag || !allowFallbackSpots)
            {
                yield break;
            }
            List <Thing> list = pawn.Map.listerThings.ThingsInGroup(ThingRequestGroup.MeditationFocus);

            foreach (Thing item2 in list)
            {
                if (item2.def == ThingDefOf.Wall)
                {
                    continue;
                }
                Room room = item2.GetRoom();
                if ((room == null || CanUseRoomToMeditate(room, pawn)) && item2.GetStatValueForPawn(StatDefOf.MeditationFocusStrength, pawn) > 0f)
                {
                    LocalTargetInfo localTargetInfo = MeditationSpotForFocus(item2, pawn);
                    if (localTargetInfo.IsValid)
                    {
                        yield return(localTargetInfo);
                    }
                }
            }
            Building_Bed bed   = pawn.ownership.OwnedBed;
            Room         room2 = bed?.GetRoom();
            IntVec3      c2;

            if (room2 != null && !room2.PsychologicallyOutdoors && pawn.CanReserveAndReach(bed, PathEndMode.OnCell, pawn.NormalMaxDanger()))
            {
                foreach (LocalTargetInfo item3 in FocusSpotsInTheRoom(pawn, room2))
                {
                    yield return(item3);
                }
                c2 = RCellFinder.RandomWanderDestFor(pawn, bed.Position, WanderRadius, (Pawn p, IntVec3 c, IntVec3 r) => c.Standable(p.Map) && c.GetDoor(p.Map) == null && WanderRoomUtility.IsValidWanderDest(p, c, r), pawn.NormalMaxDanger());
                if (c2.IsValid)
                {
                    yield return(c2);
                }
            }
            if (pawn.IsPrisonerOfColony)
            {
                yield break;
            }
            IntVec3 colonyWanderRoot = WanderUtility.GetColonyWanderRoot(pawn);

            c2 = RCellFinder.RandomWanderDestFor(pawn, colonyWanderRoot, WanderRadius, delegate(Pawn p, IntVec3 c, IntVec3 r)
            {
                if (!c.Standable(p.Map) || c.GetDoor(p.Map) != null || !p.CanReserveAndReach(c, PathEndMode.OnCell, p.NormalMaxDanger()))
                {
                    return(false);
                }
                Room room3 = c.GetRoom(p.Map);
                return((room3 == null || CanUseRoomToMeditate(room3, pawn)) ? true : false);
            }, pawn.NormalMaxDanger());
            if (c2.IsValid)
            {
                yield return(c2);
            }
        }