public static void DoWindowContents(Rect fillRect, ref Vector2 scrollPosition, ref float scrollViewHeight) { Rect position = new Rect(0.0f, 0.0f, fillRect.width, fillRect.height); GUI.BeginGroup(position); Verse.Text.Font = GameFont.Small; GUI.color = Color.white; Rect outRect = new Rect(0.0f, 50f, position.width, position.height - 50f); Rect rect = new Rect(0.0f, 0.0f, position.width - 16f, scrollViewHeight); Widgets.BeginScrollView(outRect, ref scrollPosition, rect, true); float num = 0.0f; foreach (Religion religion in ReligionExtensions.GetReligionManager().AllReligions) { GUI.color = new Color(1f, 1f, 1f, 0.2f); Widgets.DrawLineHorizontal(0.0f, num, rect.width); GUI.color = Color.white; num += DrawReligionRow(religion, num, rect); } if (Event.current.type == EventType.Layout) { scrollViewHeight = num; } Widgets.EndScrollView(); GUI.EndGroup(); }
public override bool TryStart(Pawn pawn, string reason, bool causedByMood) { Religion religion = ReligionExtensions.GetReligionManager().AllReligions.RandomElement(); if (religion.GetSettings <ReligionSettings_MentalBreaks>(SettingsTagDefOf.MentalBreaksTag) != null) { ReligionSettings_MentalBreaks settings = religion.GetSettings <ReligionSettings_MentalBreaks>(SettingsTagDefOf.MentalBreaksTag); if (settings.MentalBreaks.Any(x => x == this.def)) { if (!pawn.GetReligionComponent().TryChangeReligion(religion)) { return(false); } return(base.TryStart(pawn, reason, causedByMood)); } } return(false); }
public void RecalculateCompabilities() { compabilities.Clear(); IEnumerable <Religion> religions = ReligionExtensions.GetReligionManager().AllReligions; if (religions == null) { religions = ReligionsBuffer.religions; } if (religions != null && religions.Count() > 0) { foreach (Religion religion in religions) { compabilities.Add(religion, CalculateCompabilityForReligion(religion.GetSettings <ReligionSettings_JoiningCriteria>(SettingsTagDefOf.JoiningCriteriaTag))); } } }
protected override bool TryExecuteWorker(IncidentParms parms) { Religion religion = ReligionExtensions.GetReligionManager().AllReligions.RandomElement(); if (religion.GetSettings <ReligionSettings_Incidents>(SettingsTagDefOf.IncidentsTag) != null) { ReligionSettings_Incidents settings = religion.GetSettings <ReligionSettings_Incidents>(SettingsTagDefOf.IncidentsTag); if (settings.Incidents.Any(x => x == this.def)) { Pawn pawn = PotentialVictimCandidates(parms.target).RandomElement(); if (pawn == null) { return(false); } if (!pawn.GetReligionComponent().TryChangeReligion(religion)) { return(false); } Find.LetterStack.ReceiveLetter(this.def.letterLabel, pawn.LabelCap + " " + def.letterText + " " + religion.Label, this.def.letterDef, (LookTargets)pawn, (Faction)null, (string)null); return(true); } } return(false); }
public static void DrawSelectReligion(Rect rect, Pawn pawn, ref float curY) { GUI.BeginGroup(rect); float y = 0.0f; Widgets.ListSeparator(ref y, rect.width, "ReligionInfo_Religion".Translate()); Rect rect2 = new Rect(rect.x, y, rect.width, 24f); y += 24f; if (Widgets.ButtonText(rect2, "ReligionInfo_Religion".Translate(), true, false, true)) { List <FloatMenuOption> options = new List <FloatMenuOption>(); foreach (var religion in ReligionExtensions.GetReligionManager().AllReligions) { options.Add(new FloatMenuOption(religion.Label, (Action)(() => pawn.GetReligionComponent().TryChangeReligion(religion)), MenuOptionPriority.Default, (Action)null, (Thing)null, 0.0f, (Func <Rect, bool>)null, (WorldObject)null)); } Find.WindowStack.Add((Window) new FloatMenu(options)); } curY += y; GUI.EndClip(); }
public override void DoWindowContents(Rect inRect) { Text.Font = GameFont.Small; Rect outRect = new Rect(inRect); outRect.yMin += 20f; outRect.yMax -= 40f; outRect.width -= 16f; Rect viewRect = new Rect(0.0f, 0.0f, outRect.width - 16f, (float)(ReligionExtensions.GetReligionManager().AllReligions.Count() * 35.0 + 100.0)); Widgets.BeginScrollView(outRect, ref this.scrollPosition, viewRect, true); try { float y = 0.0f; bool flag = false; if (assignable.AssignedReligion != null) { flag = true; Rect rect = new Rect(0.0f, y, viewRect.width * 0.6f, 32f); Widgets.Label(rect, assignable.AssignedReligion.Label); rect.x = rect.xMax; rect.width = viewRect.width * 0.4f; if (Widgets.ButtonText(rect, "BuildingUnassign".Translate(), true, false, true)) { if (assignable.AssignedBuildings.Count() != 0) { Messages.Message("ReligiousBuilgingAssigner_BuildingWasUnassigned".Translate(), MessageTypeDefOf.NeutralEvent); } this.assignable.TryUnassignReligion(); SoundDefOf.Click.PlayOneShotOnCamera((Map)null); return; } y += 35f; } if (flag) { y += 15f; } foreach (Religion assigningCandidate in ReligionExtensions.GetReligionManager().AllReligions) { if (assigningCandidate != assignable.AssignedReligion && assigningCandidate.GetSettings <ReligionSettings_AllowedBuildings>(SettingsTagDefOf.AllowedBuildingsTag) != null && assigningCandidate.GetSettings <ReligionSettings_AllowedBuildings>(SettingsTagDefOf.AllowedBuildingsTag).AllowedBuildings.Any(x => x == assignable.def)) { Rect rect = new Rect(0.0f, y, viewRect.width * 0.6f, 32f); Widgets.Label(rect, assigningCandidate.Label); rect.x = rect.xMax; rect.width = viewRect.width * 0.4f; if (Widgets.ButtonText(rect, "BuildingAssign".Translate(), true, false, true)) { this.assignable.TryAssignReligion(assigningCandidate); SoundDefOf.Click.PlayOneShotOnCamera((Map)null); break; } y += 35f; } } } finally { Widgets.EndScrollView(); } }