protected override Job TryGiveJob(Pawn pawn) { if (this.GetPriority(pawn) == 0f) { return((Job)null); } CompReligion comp = pawn.GetReligionComponent(); if (comp.ReligionRestrictions.MayPray) { Building placeToPray = GetRightPlaceToPray(pawn); if (placeToPray == null) { return((Job)null); } if (!WatchBuildingUtility.TryFindBestWatchCell(placeToPray, pawn, true, out IntVec3 result, out Building chair)) { WatchBuildingUtility.TryFindBestWatchCell(placeToPray, pawn, false, out result, out chair); } return(new Job(comp.Religion.GetSettings <ReligionSettings_Prayings>(SettingsTagDefOf.PrayingsTag).Property.GetObject <JobDef>(), placeToPray, (LocalTargetInfo)result, (LocalTargetInfo)((Thing)chair))); } return((Job)null); }
public override bool CanBeGivenTo(Pawn pawn) { CompReligion rel = pawn.GetReligionComponent(); if (rel == null || rel.Religion.GetSettings <ReligionSettings_Prayings>(SettingsTagDefOf.PrayingsTag) == null || !rel.ReligionRestrictions.MayPray) { return(false); } return(base.CanBeGivenTo(pawn)); }
private IEnumerable <Def> GetVictimThoughtsCriteria() { yield return(victim.def); CompReligion comp = victim.GetReligionComponent(); if (comp != null) { yield return(comp.Religion.Def); yield return(comp.Religion.GroupTag); } }
public override void Interacted(Pawn initiator, Pawn recipient, List <RulePackDef> extraSentencePacks, out string letterText, out string letterLabel, out LetterDef letterDef) { base.Interacted(initiator, recipient, extraSentencePacks, out letterText, out letterLabel, out letterDef); CompReligion compReligion = initiator.GetReligionComponent(); float successChance = ChanceToConvert(initiator, recipient); if ((float)new Random().NextDouble() <= successChance) { letterText = recipient.ToString() + " " + "ReligionInfo_NowBelieveIn".Translate() + " " + compReligion.Religion.Label; letterLabel = "ReligionInfo_IsNowReligious".Translate(); letterDef = LetterDefOf.NeutralEvent; recipient.GetReligionComponent().TryChangeReligion(compReligion.Religion); } }
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)); }
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 float VoluntaryJoinPriorityFor(Pawn p) { CompReligion comp = p.GetReligionComponent(); if (comp.Religion == data.Religion && comp.ReligionRestrictions.MayDoReligionActivities) { if (p == data.Organizer) { return(100f); } else { return(p.GetReligionComponent().PietyTracker.PietyNeed.CurCategoryIntWithoutZero * 19f); } } return(0.0f); }
private float ChanceToConvert(Pawn initiator, Pawn recipient) { CompReligion initiatorComp = initiator.GetReligionComponent(); CompReligion recipientComp = recipient.GetReligionComponent(); ReligionSettings_ReligionTalks settings = initiatorComp.Religion.GetSettings <ReligionSettings_ReligionTalks>(SettingsTagDefOf.TalksTag); if (recipientComp.ReligionRestrictions.MayConvertByTalking) { float opinionFactor = settings.OpinionFactorCurve.Curve != null?settings.OpinionFactorCurve.Curve.Evaluate((float)recipient.relations.OpinionOf(initiator)) : 1f; float moodFactor = settings.MoodFactorCurve.Curve != null?settings.MoodFactorCurve.Curve.Evaluate((float)recipient.needs.mood.CurLevel) : 1f; float compabilityFactor = recipientComp.ReligionCompability.CompabilityFor(initiatorComp.Religion); return(1f * opinionFactor * moodFactor * compabilityFactor); } else { return(0f); } }
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)); }
protected override ThoughtState CurrentStateInternal(Pawn p) { CompReligion comp = p.GetReligionComponent(); if (comp == null) { return(ThoughtState.Inactive); } ReligionSettings_PietyNeed settings = comp.Religion.GetSettings <ReligionSettings_PietyNeed>(SettingsTagDefOf.NeedTag); if (settings == null) { return(ThoughtState.Inactive); } if (settings.NeedThought != null && settings.NeedThought == this.def) { return(ThoughtState.ActiveAtStage(comp.PietyTracker.PietyNeed.CurCategoryInt)); } return(ThoughtState.Inactive); }