RJW-Sexperience/RJWSexperience/IdeologyAddon/Ideology/Utility.cs

50 lines
1.3 KiB
C#
Raw Normal View History

2022-02-25 14:15:48 +00:00
using RimWorld;
2021-08-21 16:29:59 +00:00
using System.Collections.Generic;
using System.Linq;
using Verse;
namespace RJWSexperience.Ideology
{
2022-02-25 14:15:48 +00:00
public static class IdeoUtility
{
public static bool IsSubmissive(this Pawn pawn)
{
Ideo ideo = pawn.Ideo;
if (ideo != null)
{
if (ideo.HasPrecept(VariousDefOf.Submissive_Female) && pawn.gender == Gender.Female) return true;
else if (ideo.HasPrecept(VariousDefOf.Submissive_Male) && pawn.gender == Gender.Male) return true;
}
2021-08-21 16:29:59 +00:00
2022-02-25 14:15:48 +00:00
return false;
}
2021-08-21 16:29:59 +00:00
2022-02-25 14:15:48 +00:00
public static bool ContainAll(string str, string[] tags)
{
string lstr = str.ToLower();
if (!tags.NullOrEmpty()) for (int i = 0; i < tags.Count(); i++)
{
if (!lstr.Contains('[' + tags[i].ToLower() + ']')) return false;
}
return true;
}
2021-08-21 16:29:59 +00:00
2022-02-25 14:15:48 +00:00
public static bool IsIncest(Pawn pawn, Pawn partner)
{
IEnumerable<PawnRelationDef> relations = pawn.GetRelations(partner);
Ideo ideo = pawn.Ideo;
bool wide = false;
if (ideo != null) wide = ideo.HasPrecept(VariousDefOf.Incestuos_Disapproved_CloseOnly);
if (!relations.EnumerableNullOrEmpty()) foreach (PawnRelationDef relation in relations)
{
if (wide)
{
if (relation.incestOpinionOffset < 0) return true;
}
else if (relation.familyByBloodRelation) return true;
}
return false;
}
}
2021-08-21 16:29:59 +00:00
}