public Job GetSpectateJob(Pawn pawn)
        {
            if (activityCurrentStage >= data.ActivityJobs.Count())
            {
                return(null);
            }

            PawnDuty duty = pawn.mindState.duty;

            if (duty == null)
            {
                return((Job)null);
            }

            IntVec3 cell;

            ActivityUtility.TrySendStageEndedSignal(pawn);

            if (pawn == data.Organizer)
            {
                Job job = new Job(JobDefOf.SpectateCeremony, (LocalTargetInfo)data.Facility.Position);
                OrganizerReserve(pawn, job);
            }

            if (!WatchBuildingUtility.TryFindBestWatchCell(data.Facility, pawn, true, out IntVec3 result, out Building chair))
            {
                WatchBuildingUtility.TryFindBestWatchCell(data.Facility, pawn, false, out result, out chair);
            }
            return(new Job(JobDefOf.SpectateCeremony, (LocalTargetInfo)result, (LocalTargetInfo)data.Facility));
        }
        private static void ForceListenersTest(BuildingAltar altar)
        {
            IntVec3  result;
            Building chair;

            foreach (Pawn p in altar.Map.mapPawns.AllPawnsSpawned.FindAll(x => x.RaceProps.intelligence == Intelligence.Humanlike))
            {
                if (!SermonUtility.IsPreacher(p))
                {
                    if (!WatchBuildingUtility.TryFindBestWatchCell(altar, p, true, out result, out chair))
                    {
                        if (!WatchBuildingUtility.TryFindBestWatchCell(altar as Thing, p, false, out result, out chair))
                        {
                            return;
                        }
                    }
                    if (chair != null)
                    {
                        Job J = new Job(C_JobDefOf.AttendSermon, altar.preacher, altar, chair);
                        p.QueueJob(J);
                        p.jobs.EndCurrentJob(JobCondition.InterruptForced);
                    }
                    else
                    {
                        Job J = new Job(C_JobDefOf.AttendSermon, altar.preacher, altar, result);
                        p.QueueJob(J);
                        p.jobs.EndCurrentJob(JobCondition.InterruptForced);
                    }
                }
            }
        }
Exemplo n.º 3
0
        protected override Job TryGiveJob(Pawn pawn)
        {
            if (this.GetPriority(pawn) == 0f)
            {
                return((Job)null);
            }

            CompReligion comp = pawn.GetReligionComponent();

            if (comp.ReligionRestrictions.MayPray)
            {
                Building placeToPray = GetRightPlaceToPray(pawn);
                if (placeToPray == null)
                {
                    return((Job)null);
                }

                if (!WatchBuildingUtility.TryFindBestWatchCell(placeToPray, pawn, true, out IntVec3 result, out Building chair))
                {
                    WatchBuildingUtility.TryFindBestWatchCell(placeToPray, pawn, false, out result, out chair);
                }

                return(new Job(comp.Religion.GetSettings <ReligionSettings_Prayings>(SettingsTagDefOf.PrayingsTag).Property.GetObject <JobDef>(), placeToPray, (LocalTargetInfo)result, (LocalTargetInfo)((Thing)chair)));
            }
            return((Job)null);
        }
Exemplo n.º 4
0
        protected override Job TryGiveJob(Pawn pawn)
        {
            Lord           lord    = pawn.GetLord();
            LordJob_Sermon lordJob = lord.LordJob as LordJob_Sermon;

            if (lordJob != null)
            {
                if (lordJob.Preacher == pawn)
                {
                    return(new Job(C_JobDefOf.HoldSermon, lordJob.altar, lordJob.altar.InteractionCell));
                }
                else
                {
                    IntVec3  result;
                    Building chair;
                    if (!WatchBuildingUtility.TryFindBestWatchCell(lordJob.altar, pawn, true, out result, out chair))
                    {
                        if (!WatchBuildingUtility.TryFindBestWatchCell(lordJob.altar, pawn, false, out result, out chair))
                        {
                            Log.Error("No watch cell found");
                            return(null);
                        }
                    }
                    if (chair != null)
                    {
                        return(new Job(C_JobDefOf.AttendSermon, lordJob.Preacher, lordJob.altar, chair));
                    }
                    return(new Job(C_JobDefOf.AttendSermon, lordJob.Preacher, lordJob.altar, result));
                }
            }
            return(null);
        }
Exemplo n.º 5
0
 public static void GiveAttendSermonJob(BuildingAltar altar, Pawn attendee)
 {
     if (!SermonUtility.IsPreacher(attendee))
     {
         IntVec3  result;
         Building chair;
         if (!WatchBuildingUtility.TryFindBestWatchCell(altar, attendee, true, out result, out chair))
         {
             if (!WatchBuildingUtility.TryFindBestWatchCell(altar as Thing, attendee, false, out result, out chair))
             {
                 return;
             }
         }
         if (chair != null)
         {
             Job J = new Job(C_JobDefOf.AttendSermon, altar.preacher, altar, chair);
             attendee.QueueJob(J);
             attendee.jobs.EndCurrentJob(JobCondition.InterruptForced);
         }
         else
         {
             Job J = new Job(C_JobDefOf.AttendSermon, altar.preacher, altar, result);
             attendee.QueueJob(J);
             attendee.jobs.EndCurrentJob(JobCondition.InterruptForced);
         }
     }
 }
Exemplo n.º 6
0
        public static bool TryFindRandomCellInSermonArea(BuildingAltar altar, Pawn pawn, out IntVec3 result)
        {
            if (pawn.mindState.duty.focus.Cell == null)
            {
                Log.Message("NoFocusCell");
            }
            IntVec3  cell;
            Building chair;

            WatchBuildingUtility.TryFindBestWatchCell(altar, pawn, true, out cell, out chair);


            if (chair != null)
            {
                result = chair.Position;
                return(true);
            }

            result = cell;
            if (cell == null)
            {
                return(false);
            }
            return(true);
        }
Exemplo n.º 7
0
        //public static void AttendedWorshipThought(Pawn prayer)
        //{
        //    if (prayer == null) return;
        //    TryGainTempleRoomThought(prayer);
        //    ThoughtDef newThought = ReligionDefOf.AttendedWorship; // DefDatabase<ThoughtDef>.GetNamed("HeldSermon");
        //    if (newThought != null)
        //    {
        //        prayer.needs.mood.thoughts.memories.TryGainMemory(newThought);
        //    }
        //}

        #endregion

        #region LecternManagement

        public static void GiveAttendJob(Building_Lectern lectern, Pawn attendee)
        {
            if (attendee.Drafted)
            {
                return;
            }

            if (attendee.IsPrisoner)
            {
                return;
            }

            if (attendee.jobs.curJob.def == ReligionDefOf.AttendWorship)
            {
                return;
            }

            if (!WatchBuildingUtility.TryFindBestWatchCell(lectern, attendee, true, out var result, out var chair))
            {
                WatchBuildingUtility.TryFindBestWatchCell(lectern, attendee, false, out result, out chair);
            }

            var J = new Job(ReligionDefOf.AttendWorship, lectern, result, chair)
            {
                playerForced            = true,
                ignoreJoyTimeAssignment = true,
                expiryInterval          = 9999,
                ignoreDesignations      = true,
                ignoreForbidden         = true
            };

            //attendee.jobs.EndCurrentJob(JobCondition.Incompletable);
            attendee.jobs.TryTakeOrderedJob(J);
        }
        public static void GiveAttendLessonJob(Building_TeachingSpot spot, Pawn attendee)
        {
            if (IsTeacher(attendee))
            {
                return;
            }
            if (attendee.Drafted)
            {
                return;
            }
            if (attendee.IsPrisoner)
            {
                return;
            }
            if (attendee.jobs.curJob.def.defName == "AttendLesson")
            {
                return;
            }

            IntVec3  result;
            Building chair;

            if (!WatchBuildingUtility.TryFindBestWatchCell(spot, attendee, true, out result, out chair))
            {
                if (!WatchBuildingUtility.TryFindBestWatchCell(spot as Thing, attendee, false, out result, out chair))
                {
                    return;
                }
            }

            int dir = spot.Rotation.Opposite.AsInt;

            if (chair != null)
            {
                IntVec3 newPos = chair.Position + GenAdj.CardinalDirections[dir];

                Job J = new Job(DefDatabase <JobDef> .GetNamed("AttendLesson"), spot, newPos, chair);
                J.playerForced            = true;
                J.ignoreJoyTimeAssignment = true;
                J.expiryInterval          = 9999;
                J.ignoreDesignations      = true;
                J.ignoreForbidden         = true;
                attendee.jobs.jobQueue.EnqueueLast(J);
                attendee.jobs.EndCurrentJob(JobCondition.Incompletable);
            }
            else
            {
                IntVec3 newPos = result + GenAdj.CardinalDirections[dir];

                Job J = new Job(DefDatabase <JobDef> .GetNamed("AttendLesson"), spot, newPos, result);
                J.playerForced            = true;
                J.ignoreJoyTimeAssignment = true;
                J.expiryInterval          = 9999;
                J.ignoreDesignations      = true;
                J.ignoreForbidden         = true;
                attendee.jobs.jobQueue.EnqueueLast(J);
                attendee.jobs.EndCurrentJob(JobCondition.Incompletable);
            }
        }
Exemplo n.º 9
0
 public Job DoTryGiveJob(Pawn pawn, Thing t, JoyGiverDef def)
 {
     if (!WatchBuildingUtility.TryFindBestWatchCell(t, pawn, def.desireSit, out var result, out var chair))
     {
         return(null);
     }
     return(JobMaker.MakeJob(def.jobDef, t, result, chair));
 }
Exemplo n.º 10
0
 protected override Job TryGivePlayJob(Pawn pawn, Thing t)
 {
     if (!WatchBuildingUtility.TryFindBestWatchCell(t, pawn, def.desireSit, out IntVec3 c, out Building t2))
     {
         return(null);
     }
     return(new Job(def.jobDef, t, c, t2));
 }
        protected override Job TryGivePlayJob(Pawn pawn, Thing t)
        {
            if (!WatchBuildingUtility.TryFindBestWatchCell(t, pawn, def.desireSit, out var result, out var chair))
            {
                return(null);
            }

            return(new Job(def.jobDef, t, result, chair));
        }
Exemplo n.º 12
0
        protected override Job TryGiveJob(Pawn pawn)
        {
            if (!CultKnowledge.isExposed)
            {
                return(null);
            }
            if (CultKnowledge.selectedDeity == null)
            {
                return(null);
            }

            /*
             *  Get [CurrentAssignment] indirectly, because [pawn.timetable.CurrentAssignment] getter has harmony patch.
             *  Patch overrides result from [Cults_TimeAssignment_Worship] to [TimeAssignmentDefOf.Anything]
             *  Vanilla functions can't check custom timetable defs otherwise they throw [NotImplementedException]
             *  [JobGiver_Worship] happens before core colonist behavior
             *
             *  Classes that check a schedule:
             *      ThinkNode_Priority_GetJoy
             *      JobGiver_GetRest
             *      JobGiver_Work
             */
            // TimeAssignmentDef assignment = pawn.timetable.CurrentAssignment;
            TimeAssignmentDef assignment = pawn.timetable.times[GenLocalDate.HourOfDay(pawn)];

            // TODO: implement reservations

            IEnumerable <Building_BaseAltar> altars = pawn.Map.listerBuildings.AllBuildingsColonistOfClass <Building_BaseAltar>();
            TraverseParms parms = TraverseParms.For(pawn, Danger.Deadly, TraverseMode.ByPawn, false);
            Thing         altar = GenClosest.ClosestThing_Global_Reachable(pawn.Position, pawn.Map, altars, PathEndMode.OnCell, parms);

            if (altar != null)
            {
                if (!WatchBuildingUtility.TryFindBestWatchCell(altar, pawn, true, out IntVec3 spot, out Building chair))
                {
                    if (!WatchBuildingUtility.TryFindBestWatchCell(altar, pawn, false, out spot, out chair))
                    {
                        return(null);
                    }
                }
                ;

                Job job = JobMaker.MakeJob(CultsDefOf.Cults_Job_Worship, spot, altar);
                //if(pawn.CurJob != null)Log.Message("info " + pawn.HasReserved(pawn.CurJob.targetA).ToString() + " " + pawn.CurJobDef.defName.ToString());
                //if(pawn.CanReserve(spot, 1, -1)) pawn.Reserve(spot, job, 1, -1);
                if (assignment == Cults.CultsDefOf.Cults_TimeAssignment_Worship)
                {
                    return(job);
                }
            }
            ;
            return(null);
        }
Exemplo n.º 13
0
        public static bool TryFindRandomCellInSermonArea(BuildingAltar altar, Pawn pawn, out IntVec3 result)
        {
            IntVec3  cell;
            Building chair;

            WatchBuildingUtility.TryFindBestWatchCell(altar, pawn, true, out cell, out chair);


            if (chair != null)
            {
                result = chair.Position;
                return(true);
            }

            result = cell;
            if (cell == null)
            {
                return(false);
            }
            return(true);
        }
        protected virtual Job TryGiveAltarJob(Pawn pawn, Thing totem)
        {
            IntVec3  result;
            Building chair;

            if (!WatchBuildingUtility.TryFindBestWatchCell(totem, pawn, this.def.desireSit, out result, out chair))
            {
                if (this.def.desireSit)
                {
                    if (!WatchBuildingUtility.TryFindBestWatchCell(totem, pawn, false, out result, out chair))
                    {
                        return((Job)null);
                    }
                }
            }
            if (chair != null)
            {
                return(new Job(this.def.jobDef, totem, chair));
            }
            return(new Job(this.def.jobDef, totem, result));
        }