private float CalculateCompabilityForReligion(ReligionSettings_JoiningCriteria settings)
        {
            float currentCompability = 1f;

            if (settings != null)
            {
                foreach (JoiningCriteria permission in settings.Criteria)
                {
                    currentCompability *= (1 - permission.PermissionRate(pawn));
                }
            }
            return(currentCompability);
        }
Esempio n. 2
0
        private IEnumerable <Action <Rect> > Criteria()
        {
            ReligionSettings_JoiningCriteria jSettings = religion.GetSettings <ReligionSettings_JoiningCriteria>(SettingsTagDefOf.JoiningCriteriaTag);

            if (jSettings == null)
            {
                yield return(x => Widgets.Label(x, "Religion_NoSuchSettings".Translate()));
            }
            else
            {
                foreach (var criteria in jSettings.Criteria.OrderByDescending(o => o.Importance))
                {
                    yield return(x =>
                    {
                        Template(x, 1, 3, new Action <Rect>[3]
                        {
                            u =>
                            {
                                Widgets.DrawTextureFitted(u, criteria.ShouldHave ? GraphicsCache.CheckboxOnTex : GraphicsCache.CheckboxOffTex, 1);
                                TooltipHandler.TipRegion(u, (TipSignal)"ShouldHave".Translate());
                                if (Mouse.IsOver(u))
                                {
                                    Widgets.DrawHighlight(u);
                                }
                            },
                            u =>
                            {
                                GUI.color = Color.gray;
                                Widgets.Label(u, criteria.Importance.Label());
                                GUI.color = Color.white;
                                TooltipHandler.TipRegion(u, (TipSignal)"CriteriaImportance".Translate());
                                if (Mouse.IsOver(u))
                                {
                                    Widgets.DrawHighlight(u);
                                }
                            },
                            u => Widgets.Label(u, criteria.Reason)
                        }, height);
                    });
                }
            }
        }