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); } } } }
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)); }
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(); 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)); }