2022-02-25 14:15:48 +00:00
|
|
|
|
using RimWorld;
|
2021-08-21 16:29:59 +00:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
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;
|
2022-06-18 08:54:29 +00:00
|
|
|
|
if (ideo == null)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
{
|
2022-06-18 08:54:29 +00:00
|
|
|
|
if (tags.NullOrEmpty())
|
|
|
|
|
return true;
|
|
|
|
|
|
2022-02-25 14:15:48 +00:00
|
|
|
|
string lstr = str.ToLower();
|
2022-06-18 08:54:29 +00:00
|
|
|
|
for (int i = 0; i < tags.Length; i++)
|
|
|
|
|
{
|
|
|
|
|
if (!lstr.Contains('[' + tags[i].ToLower() + ']'))
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2022-02-25 14:15:48 +00:00
|
|
|
|
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);
|
2022-06-18 08:54:29 +00:00
|
|
|
|
if (relations.EnumerableNullOrEmpty())
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
bool wide = pawn.Ideo?.HasPrecept(VariousDefOf.Incestuos_Disapproved_CloseOnly) == true;
|
|
|
|
|
foreach (PawnRelationDef relation in relations)
|
|
|
|
|
{
|
|
|
|
|
if (wide)
|
2022-02-25 14:15:48 +00:00
|
|
|
|
{
|
2022-06-18 08:54:29 +00:00
|
|
|
|
if (relation.incestOpinionOffset < 0)
|
|
|
|
|
return true;
|
2022-02-25 14:15:48 +00:00
|
|
|
|
}
|
2022-06-18 08:54:29 +00:00
|
|
|
|
else if (relation.familyByBloodRelation)
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-02-25 14:15:48 +00:00
|
|
|
|
return false;
|
|
|
|
|
}
|
2022-06-19 18:49:17 +00:00
|
|
|
|
|
|
|
|
|
public static float GetPreceptsMtbMultiplier<T>(Ideo ideo) where T : Precepts.DefExtension_ModifyMtb
|
|
|
|
|
{
|
|
|
|
|
float finalMultiplier = 1f;
|
|
|
|
|
for (int i = 0; i < ideo.PreceptsListForReading.Count; i++)
|
|
|
|
|
{
|
2022-06-23 04:40:33 +00:00
|
|
|
|
T defExtension = ideo.PreceptsListForReading[i].def.GetModExtension<T>();
|
|
|
|
|
|
|
|
|
|
if (defExtension == null)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
if (defExtension.disable)
|
|
|
|
|
return -1f;
|
|
|
|
|
|
|
|
|
|
finalMultiplier *= defExtension.multiplier;
|
2022-06-19 18:49:17 +00:00
|
|
|
|
}
|
|
|
|
|
return finalMultiplier;
|
|
|
|
|
}
|
2022-02-25 14:15:48 +00:00
|
|
|
|
}
|
2021-08-21 16:29:59 +00:00
|
|
|
|
}
|