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); } } } }
public static void OpenPreacherSelectMenu(BuildingAltar altar) { List <FloatMenuOption> list = new List <FloatMenuOption>(); list.Add(new FloatMenuOption("(" + "NoneLower".Translate() + ")", delegate { altar.preacher = null; }, MenuOptionPriority.Default, null, null, 0f, null)); foreach (Pawn current in altar.Map.mapPawns.FreeColonistsSpawned) { if (!SermonUtility.IsPreacher(current)) { Need_Soul nsoul = current.needs.TryGetNeed <Need_Soul>(); if (nsoul == null) { nsoul = new Need_Soul(current); } SoulTrait strait = nsoul.DevotionTrait; string text1 = current.NameStringShort + " (" + strait.SoulCurrentData.label + ")"; Action action; Pawn localCol = current; action = delegate { altar.preacher = localCol; }; list.Add(new FloatMenuOption(text1, action, MenuOptionPriority.Default, null, null, 0f, null)); } } Find.WindowStack.Add(new FloatMenu(list)); }
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); } } }
public static bool IsBestPreacher(Pawn p, Pawn preacher) { List <Pawn> opposingDevotees = p.needs.TryGetNeed <Need_Soul>().OpposingDevotees; if (opposingDevotees == null) { opposingDevotees = new List <Pawn>(); } List <Pawn> availablePreachers = p.Map.mapPawns.AllPawnsSpawned.ToList <Pawn>().FindAll(x => SermonUtility.IsPreacher(x)); Pawn bestcurrentPreacher; if (availablePreachers != null) { bestcurrentPreacher = availablePreachers.Aggregate((i1, i2) => i1.skills.GetSkill(SkillDefOf.Social).Level > i2.skills.GetSkill(SkillDefOf.Social).Level ? i1 : i2); if (bestcurrentPreacher == preacher && !opposingDevotees.Contains(preacher)) { return(true); } } return(false); }