public void RecalculateState()
        {
            PietyState state = this.CurrentStateInternal();

            if (state.ActiveFor(this.def))
            {
                this.curStageIndex = state.StageIndexFor(this.def);
                this.reason        = state.Reason;
            }
            else
            {
                this.curStageIndex = -1;
            }
        }
        public override PietyState CurrentState(Pawn p)
        {
            CompReligion comp = p.GetReligionComponent();

            if (comp == null)
            {
                return(PietyState.Inactive);
            }

            ReligionSettings_Social settings = comp.Religion.GetSettings <ReligionSettings_Social>(SettingsTagDefOf.TemperatureTag);

            if (settings == null)
            {
                return(PietyState.Inactive);
            }

            ReligionProperty property = settings.DefaultPropety;

            if (property == null || property.Subject == null || property.Subject.Piety == null || property.Subject.Piety != this.def)
            {
                return(PietyState.Inactive);
            }

            float num = p.AmbientTemperature;

            if ((double)num >= 0.0)
            {
                return(PietyState.Inactive);
            }
            if ((double)num > -10.0)
            {
                return(PietyState.ActiveAtStage(0));
            }
            if ((double)num > -20.0)
            {
                return(PietyState.ActiveAtStage(1));
            }
            if ((double)num > -30.0)
            {
                return(PietyState.ActiveAtStage(2));
            }
            if ((double)num > -40.0)
            {
                return(PietyState.ActiveAtStage(3));
            }
            return(PietyState.ActiveAtStage(4));
        }
        public override PietyState CurrentState(Pawn p)
        {
            Room room = p.GetRoom(RegionType.Set_Passable);

            if (room == null)
            {
                return(PietyState.Inactive);
            }
            int scoreStageIndex = RoomStatDefOf.Impressiveness.GetScoreStageIndex(room.GetStat(RoomStatDefOf.Impressiveness));

            if (this.def.Stages.ElementAt(scoreStageIndex) == null)
            {
                return(PietyState.Inactive);
            }
            if (p.GetRoom(RegionType.Set_Passable).Role == MiscDefOf.Temple)
            {
                return(PietyState.ActiveAtStage(scoreStageIndex));
            }
            return(PietyState.Inactive);
        }
        public override PietyState CurrentState(Pawn p)
        {
            CompReligion   comp        = p.GetReligionComponent();
            string         reason      = (string)null;
            int            num         = 0;
            List <Apparel> wornApparel = p.apparel.WornApparel;

            if (comp == null)
            {
                return(PietyState.Inactive);
            }

            ReligionSettings_Social settings = comp.Religion.GetSettings <ReligionSettings_Social>(SettingsTagDefOf.ApparelTag);

            if (settings == null)
            {
                return(PietyState.Inactive);
            }

            for (int index = 0; index < wornApparel.Count; ++index)
            {
                ReligionProperty property = settings.GetPropertyByObject(p, wornApparel[index].Stuff);

                if (property != null && property.Subject.Piety == this.def)
                {
                    if (reason == null)
                    {
                        reason = wornApparel[index].def.label;
                    }
                    ++num;
                }
            }
            if (num == 0)
            {
                return(PietyState.Inactive);
            }
            return(PietyState.ActiveAtStage((num - 1) + (comp.PietyTracker.PietyNeed.CurCategoryInt * 5), reason));
        }