public static void FoodIngested(Pawn ingester, Thing foodSource, ThingDef foodDef)
        {
            properties.Clear();

            if (ingester.RaceProps.Animal)
            {
                return;
            }

            ReligionSettings_Social settings = ingester.GetReligionComponent().Religion.GetSettings <ReligionSettings_Social>(SettingsTagDefOf.FoodTag);

            if (settings != null)
            {
                properties.Add(settings.GetPropertyByObject(ingester, foodDef));

                CompIngredients comp = foodSource.TryGetComp <CompIngredients>();
                if (comp != null)
                {
                    foreach (ThingDef ingredient in comp.ingredients)
                    {
                        properties.Add(settings.GetPropertyByObject(ingester, ingredient));
                    }
                }

                foreach (ReligionProperty property in properties)
                {
                    if (property != null)
                    {
                        PietyUtility.TryApplyOnPawn(property.Subject, ingester, property.GetObject().LabelCap);
                    }
                }
            }
        }
示例#2
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));
        }
示例#3
0
        private IEnumerable <Action <Rect> > Opinion()
        {
            ReligionSettings_Social oSettings = religion.GetSettings <ReligionSettings_Social>(SettingsTagDefOf.OpinionTag);

            if (oSettings == null)
            {
                yield return(x => Widgets.Label(x, "Religion_NoSuchSettings".Translate()));
            }
            else
            {
                if (oSettings.DefaultPropety != null)
                {
                    yield return(x =>
                    {
                        var op = oSettings.DefaultPropety.Witness;
                        Template(x, 1, 3, new Action <Rect>[3]
                        {
                            u => ColoredOpinionRange(u, op?.OpinionThought),
                            u =>
                            {
                                GUI.color = Color.gray;
                                Widgets.Label(u, oSettings.DefaultPropety.PawnCategory.Label());
                                GUI.color = Color.white;
                                TooltipHandler.TipRegion(u, (TipSignal)"Religion_PawnCategory".Translate());
                                if (Mouse.IsOver(u))
                                {
                                    Widgets.DrawHighlight(u);
                                }
                            },
                            u => Widgets.Label(u, "Religion_Everyone".Translate())
                        }, height);
                    });
                }
                foreach (var opinion in oSettings.Properties)
                {
                    yield return(x =>
                    {
                        var op = opinion.Witness;
                        Template(x, 1, 3, new Action <Rect>[3]
                        {
                            u => ColoredOpinionRange(u, op?.OpinionThought),
                            u =>
                            {
                                GUI.color = Color.gray;
                                Widgets.Label(u, opinion.PawnCategory.Label());
                                GUI.color = Color.white;
                                TooltipHandler.TipRegion(u, (TipSignal)"Religion_PawnCategory".Translate());
                                if (Mouse.IsOver(u))
                                {
                                    Widgets.DrawHighlight(u);
                                }
                            },
                            u => Widgets.Label(u, opinion.GetObject().LabelCap)
                        }, height);
                    });
                }
            }
        }
 private static ReligionProperty GetProperty(Pawn pawn, Pawn otherPawn, SettingsTagDef tag, Def def)
 {
     if (pawn != null && pawn.GetReligionComponent() != null)
     {
         ReligionSettings_Social settings = pawn.GetReligionComponent().Religion.GetSettings <ReligionSettings_Social>(tag);
         if (settings != null)
         {
             return(settings.GetPropertyByObject(pawn, def, otherPawn));
         }
     }
     return(null);
 }
        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));
        }
示例#6
0
        protected override ThoughtState CurrentStateInternal(Pawn p)
        {
            CompReligion comp = p.GetReligionComponent();

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

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

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

            ReligionProperty property = settings.DefaultPropety;

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

            float num = p.AmbientTemperature;

            if ((double)num <= 0.0)
            {
                return(ThoughtState.Inactive);
            }
            if ((double)num < 10.0)
            {
                return(ThoughtState.ActiveAtStage(0));
            }
            if ((double)num < 20.0)
            {
                return(ThoughtState.ActiveAtStage(1));
            }
            if ((double)num < 30.0)
            {
                return(ThoughtState.ActiveAtStage(2));
            }
            if ((double)num < 40.0)
            {
                return(ThoughtState.ActiveAtStage(3));
            }
            return(ThoughtState.ActiveAtStage(4));
        }
        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));
        }
        protected override ThoughtState CurrentStateInternal(Pawn p)
        {
            CompReligion   comp        = p.GetReligionComponent();
            string         reason      = (string)null;
            int            num         = 0;
            List <Apparel> wornApparel = p.apparel.WornApparel;

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

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

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

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

                if (property != null && property.Subject.Thought == this.def)
                {
                    if (reason == null)
                    {
                        reason = wornApparel[index].def.label;
                    }
                    ++num;
                }
            }
            if (num == 0)
            {
                return(ThoughtState.Inactive);
            }
            return(ThoughtState.ActiveAtStage(num - 1, reason));
        }