//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 Thing AppropriateRelic(Pawn p, TraitDef religionOfPawn) //{ // TraitDef rel; // foreach (Thing t in p.Map.listerThings.AllThings.FindAll(x => x.TryGetComp<CompRelic>() != null)) // { // rel = t.TryGetComp<CompRelic>().religion; // if (rel == religionOfPawn) // if (p.CanReach((LocalTargetInfo)t, PathEndMode.ClosestTouch, Danger.Deadly, false, TraverseMode.ByPawn)) // return t; // } // return null; //} //public static Thing AppropriateBookInInventory(Pawn p, TraitDef religionOfPawn) //{ // foreach (Thing t in p.inventory.innerContainer) // if (t.def is ReligionBook_ThingDef && (t.def as ReligionBook_ThingDef).religion == religionOfPawn) // return t; // return null; //} public static void Wipe(Building_Lectern lectern) { lectern.CompAssignableToPawn.UnassignAllPawns(); lectern.religion.Clear(); lectern.listeners.Clear(); for (var i = 0; i < lectern.daysOfWorships.Count; ++i) { lectern.daysOfWorships[i] = false; } lectern.timeOfWorship = 9; lectern.timeOfbuffer = string.Empty; lectern.didWorship = false; lectern.altar = null; }
public static Building_Altar FindAtlarToLectern(Building_Lectern lectern, Map map) { var room = lectern.GetRoom(); var andAdjacentThings = room.ContainedAndAdjacentThings; foreach (var thing in andAdjacentThings) { if (thing is not Building_Altar) { continue; } var adjacentThing = thing as Building_Altar; if (adjacentThing.lectern == null) { return(adjacentThing); } } return(null); }
public static void Listeners(Building_Lectern lectern, List <Pawn> listenersOfLectern) { if (listenersOfLectern.Count != 0) { listenersOfLectern.Clear(); } if (listenersOfLectern.Count != 0) { return; } foreach (var x in lectern.Map.mapPawns.FreeColonists) { if (x.story.traits.HasTrait(lectern.religion[0]) && x != lectern.CompAssignableToPawn.AssignedPawnsForReading[0] && x.RaceProps.Humanlike && !x.IsPrisoner && x.Faction == Faction.OfPlayer && x.RaceProps.intelligence == Intelligence.Humanlike && !x.Downed && !x.Dead && !x.InMentalState && !x.InAggroMentalState && x.CurJob.def != ReligionDefOf.HoldWorship && x.CurJob.def != ReligionDefOf.AttendWorship /* &&*/ //x.CurJob.def != JobDefOf.Capture && //x.CurJob.def != JobDefOf.ExtinguishSelf && //Oh god help //x.CurJob.def != JobDefOf.Rescue && //Saving lives is more important //x.CurJob.def != JobDefOf.TendPatient && //Saving lives is more important //x.CurJob.def != JobDefOf.BeatFire && //Fire?! This is more important //x.CurJob.def != JobDefOf.Lovin && //Not ready~~ //x.CurJob.def != JobDefOf.LayDown && //They're resting //x.CurJob.def != JobDefOf.FleeAndCower //They're not cowering ) { listenersOfLectern.Add(x); } } }
public static void TryWorship(Building_Lectern lectern, bool forced) { if (lectern == null) { Messages.Message("ErrorLectern".Translate(), MessageTypeDefOf.NegativeEvent); return; } var lectern_ = lectern; if (lectern_.religion.NullOrEmpty()) { Messages.Message("CantGiveWorshipJobToPreacher".Translate() + " : " + "SelectAReligion".Translate(), MessageTypeDefOf.NegativeEvent); lectern_.didWorship = true; return; } if (lectern_.CompAssignableToPawn.AssignedPawnsForReading.NullOrEmpty()) { Messages.Message("CantGiveWorshipJobToPreacher".Translate() + " : " + "SelectAPreacher".Translate(), MessageTypeDefOf.NegativeEvent); lectern_.didWorship = true; return; } var preacher = lectern_.CompAssignableToPawn.AssignedPawnsForReading[0]; if (lectern_.altar.relic == null) { Messages.Message("CantGiveWorshipJobToPreacher".Translate() + " : " + "NoRelicOnAltar".Translate(), MessageTypeDefOf.NegativeEvent); lectern_.didWorship = true; return; } if (preacher.Dead || preacher.Drafted || preacher.IsPrisoner || preacher.jobs.curJob.def == ReligionDefOf.HoldWorship || preacher.InMentalState || preacher.InAggroMentalState) { Messages.Message("CantGiveWorshipJobToPreacher".Translate(), MessageTypeDefOf.NegativeEvent); if (preacher.Dead) { Messages.Message("PreacherIsDead".Translate(), MessageTypeDefOf.NegativeEvent); lectern_.CompAssignableToPawn.UnassignAllPawns(); } lectern_.didWorship = true; return; } if (AppropriateBook(preacher, lectern_.religion[0]) == null) { Messages.Message("CantGiveWorshipJobToPreacher".Translate() + " : " + "NoBookAvaliable".Translate(), MessageTypeDefOf.NegativeEvent); lectern_.didWorship = true; return; } var book = AppropriateBook(preacher, lectern_.religion[0]); //Log.Message(book.Position.ToString()); //if (book == null) //{ // Messages.Message("NoBookOfReligion".Translate(), MessageTypeDefOf.NegativeEvent); // return; //} ////if (AppropriateBookInInventory(preacher, lectern.religion[0]) != null) //// book = AppropriateBookInInventory(preacher, lectern.religion[0]); if (!forced) { lectern_.didWorship = true; } var J = new Job(ReligionDefOf.HoldWorship, lectern_, book) { count = 1, playerForced = true }; //preacher.jobs.EndCurrentJob(JobCondition.Incompletable); preacher.jobs.TryTakeOrderedJob(J); }