private bool DoReligionAllowsBuildings(Building_ReligionBuilding building)
 {
     if (assignedReligion != null && assignedReligion.GetSettings <ReligionSettings_AllowedBuildings>(SettingsTagDefOf.AllowedBuildingsTag) != null)
     {
         if (assignedReligion.GetSettings <ReligionSettings_AllowedBuildings>(SettingsTagDefOf.AllowedBuildingsTag).AllowedBuildings.Any(x => x == building.def))
         {
             return(true);
         }
     }
     return(false);
 }
Example #2
0
        public Pawn_PietyTracker(Pawn pawn, Religion religion)
        {
            this.pawn = pawn;

            if (religion.GetSettings <ReligionSettings_PietyNeed>(SettingsTagDefOf.NeedTag) != null)
            {
                this.piety = new Need_Piety(pawn)
                {
                    def = religion.GetSettings <ReligionSettings_PietyNeed>(SettingsTagDefOf.NeedTag).PietyNeed
                };
            }
        }
        public Pawn_PrayTracker(Pawn pawn, Religion religion)
        {
            this.pawn = pawn;

            if (religion.GetSettings <ReligionSettings_Prayings>(SettingsTagDefOf.PrayingsTag) != null)
            {
                this.pray = new Need_Pray(pawn)
                {
                    def = religion.GetSettings <ReligionSettings_Prayings>(SettingsTagDefOf.PrayingsTag).Need
                };
            }
        }
Example #4
0
        protected override ThoughtState CurrentSocialStateInternal(Pawn p, Pawn other)
        {
            if (!p.RaceProps.Humanlike)
            {
                return((ThoughtState)false);
            }

            if (!RelationsUtility.PawnsKnowEachOther(p, other))
            {
                return((ThoughtState)false);
            }

            Religion thisPawnReligion  = p.GetReligionComponent().Religion;
            Religion otherPawnReligion = other.GetReligionComponent().Religion;

            ReligionSettings_Social opinionSettings = thisPawnReligion.GetSettings <ReligionSettings_Social>(SettingsTagDefOf.OpinionTag);

            if (opinionSettings == null)
            {
                return((ThoughtState)false);
            }

            ReligionProperty property = opinionSettings.GetPropertyByObject(p, otherPawnReligion.Def, other);

            if (property == null || property.Witness == null || property.Witness.OpinionThought == null || property.Witness.OpinionThought != this.def)
            {
                return((ThoughtState)false);
            }

            return(ThoughtState.ActiveAtStage(p.GetReligionComponent().PietyTracker.PietyNeed.CurCategoryInt, otherPawnReligion.Def.LabelCap));
        }
        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);
        }
Example #6
0
        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);
        }
Example #7
0
        private IEnumerable <Action <Rect> > Buildings()
        {
            ReligionSettings_AllowedBuildings settings = religion.GetSettings <ReligionSettings_AllowedBuildings>(SettingsTagDefOf.AllowedBuildingsTag);

            if (settings == null)
            {
                yield return(x => Widgets.Label(x, "Religion_NoSuchSettings".Translate()));
            }
            else
            {
                foreach (var building in settings.AllowedBuildings)
                {
                    yield return(x =>
                    {
                        Widgets.DrawTextureFitted(x, building.uiIcon, 1);
                        TooltipHandler.TipRegion(x, (TipSignal)building.LabelCap);
                        if (Mouse.IsOver(x))
                        {
                            Widgets.DrawHighlight(x);
                        }
                    });
                }
            }
        }