Massive change to SexAppraser Ideology patch

This commit is contained in:
amevarashi 2022-06-19 17:40:38 +05:00
parent 63692c517f
commit 22ad8c56a8
7 changed files with 288 additions and 64 deletions

View file

@ -1,10 +0,0 @@
using RimWorld;
namespace RJWSexperience.Ideology.Ideology
{
[DefOf]
public static class IssueDefOf
{
[MayRequireIdeology] public static readonly IssueDef Sextype;
}
}

View file

@ -0,0 +1,84 @@
using RimWorld;
using rjw;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using Verse;
namespace RJWSexperience.Ideology
{
public class PreceptDefExtension_ModifyPreference : DefModExtension
{
[SuppressMessage("Minor Code Smell", "S1104:Fields should not have public accessibility", Justification = "Field value loaded from XML")]
public List<Rule> rules;
public void Apply(Pawn pawn, Pawn partner, ref float preference)
{
foreach (Rule rule in rules)
{
if (rule.Applies(pawn, partner))
preference *= rule.multiplier;
}
}
public class Rule
{
[SuppressMessage("Minor Code Smell", "S1104:Fields should not have public accessibility", Justification = "Field value loaded from XML")]
public float multiplier = 1f;
[SuppressMessage("Minor Code Smell", "S1104:Fields should not have public accessibility", Justification = "Field value loaded from XML")]
public Filter filter;
public bool Applies(Pawn pawn, Pawn partner)
{
if (filter == null)
return true;
if (filter.isAnimal != null && filter.isAnimal != partner.IsAnimal())
return false;
if (filter.isVeneratedAnimal != null && filter.isVeneratedAnimal != pawn.Ideo.IsVeneratedAnimal(partner))
return false;
if (!filter.hasOneOfRelations.NullOrEmpty())
{
if (pawn.relations == null)
return false;
bool found = false;
foreach (PawnRelationDef relationDef in filter.hasOneOfRelations)
{
if (pawn.relations?.DirectRelationExists(relationDef, partner) == true)
{
found = true;
break;
}
}
if (!found)
return false;
}
if (!filter.hasNoneOfRelations.NullOrEmpty() && pawn.relations != null)
{
foreach (PawnRelationDef relationDef in filter.hasNoneOfRelations)
{
if (pawn.relations.DirectRelationExists(relationDef, partner))
return false;
}
}
return true;
}
}
public class Filter
{
[SuppressMessage("Minor Code Smell", "S1104:Fields should not have public accessibility", Justification = "Field value loaded from XML")]
public bool? isAnimal;
[SuppressMessage("Minor Code Smell", "S1104:Fields should not have public accessibility", Justification = "Field value loaded from XML")]
public bool? isVeneratedAnimal;
[SuppressMessage("Minor Code Smell", "S1104:Fields should not have public accessibility", Justification = "Field value loaded from XML")]
public List<PawnRelationDef> hasOneOfRelations;
[SuppressMessage("Minor Code Smell", "S1104:Fields should not have public accessibility", Justification = "Field value loaded from XML")]
public List<PawnRelationDef> hasNoneOfRelations;
}
}
}

View file

@ -278,61 +278,32 @@ namespace RJWSexperience.Ideology
public static float PreceptSextype(Ideo ideo, float sexdrive, float score, InteractionWithExtension interaction)
{
Precept sextypePrecept = ideo.GetPreceptOfIssue(Ideology.IssueDefOf.Sextype);
bool boostSextype = sextypePrecept.def.GetModExtension<PreceptDefExtension_PreferSextype>().HasSextype(interaction.Extension.rjwSextype);
if (!boostSextype)
return score;
for (int i = 0; i < ideo.PreceptsListForReading.Count; i++)
{
if (ideo.PreceptsListForReading[i].def.GetModExtension<PreceptDefExtension_PreferSextype>()?.HasSextype(interaction.Extension.rjwSextype) == true)
{
float mult = 8.0f * Math.Max(0.3f, 1 / Math.Max(0.01f, sexdrive));
return score * mult;
}
}
return score;
}
}
[HarmonyPatch(typeof(SexAppraiser), "would_fuck", new Type[] { typeof(Pawn), typeof(Pawn), typeof(bool), typeof(bool), typeof(bool) })]
[HarmonyPatch(typeof(SexAppraiser), nameof(SexAppraiser.would_fuck), new Type[] { typeof(Pawn), typeof(Pawn), typeof(bool), typeof(bool), typeof(bool) })]
public static class RJW_Patch_would_fuck
{
public static void Postfix(Pawn fucker, Pawn fucked, bool invert_opinion, bool ignore_bleeding, bool ignore_gender, ref float __result)
{
if (xxx.is_human(fucker))
public static void Postfix(Pawn fucker, Pawn fucked, ref float __result)
{
if (!xxx.is_human(fucker))
return;
Ideo ideo = fucker.Ideo;
if (ideo != null)
{
if (IdeoUtility.IsIncest(fucker, fucked))
{
if (ideo.HasPrecept(VariousDefOf.Incestuos_IncestOnly))
{
__result *= 2.0f;
}
else if (!fucker.relations?.DirectRelationExists(PawnRelationDefOf.Spouse, fucked) ?? false)
{
if (ideo.HasPrecept(VariousDefOf.Incestuos_Disapproved)) __result *= 0.5f;
else if (ideo.HasPrecept(VariousDefOf.Incestuos_Forbidden)) __result *= 0.1f;
}
}
if (fucked.IsAnimal())
{
if (ideo.HasPrecept(VariousDefOf.Bestiality_Honorable))
{
__result *= 2.0f;
}
else if (ideo.HasPrecept(VariousDefOf.Bestiality_OnlyVenerated))
{
if (ideo.IsVeneratedAnimal(fucked)) __result *= 2.0f;
else __result *= 0.05f;
}
else if (ideo.HasPrecept(VariousDefOf.Bestiality_Acceptable))
{
__result *= 1.0f;
}
else
{
__result *= 0.5f;
}
}
}
}
if (ideo == null)
return;
for(int i = 0; i < ideo.PreceptsListForReading.Count; i++)
ideo.PreceptsListForReading[i].def.GetModExtension<PreceptDefExtension_ModifyPreference>()?.Apply(fucker, fucked, ref __result);
}
}

View file

@ -45,9 +45,9 @@
<Compile Include="GlobalSuppressions.cs" />
<Compile Include="Ideology\GoodwillSituationWorker_MemeCompatibility.cs" />
<Compile Include="Harmony.cs" />
<Compile Include="Ideology\IssueDefOf.cs" />
<Compile Include="Ideology\IssueUtility.cs" />
<Compile Include="Ideology\Keyed.cs" />
<Compile Include="Ideology\PreceptDefExtension_ModifyPreference.cs" />
<Compile Include="Ideology\PreceptDefExtension_PreferSextype.cs" />
<Compile Include="Ideology\PreceptDefExtension_MultipleMemesRequired.cs" />
<Compile Include="Ideology\Rituals\JobGiver_GangbangConsensual.cs" />

View file

@ -35,8 +35,6 @@ namespace RJWSexperience.Ideology
[MayRequireIdeology] public static readonly HistoryEventDef Virgin_TakenM = DefDatabase<HistoryEventDef>.GetNamed("Virgin_TakenM");
[MayRequireIdeology] public static readonly HistoryEventDef Virgin_TookF = DefDatabase<HistoryEventDef>.GetNamed("Virgin_TookF");
[MayRequireIdeology] public static readonly HistoryEventDef Virgin_TookM = DefDatabase<HistoryEventDef>.GetNamed("Virgin_TookM");
[MayRequireIdeology] public static readonly PreceptDef Bestiality_Abhorrent = DefDatabase<PreceptDef>.GetNamed("Bestiality_Abhorrent");
[MayRequireIdeology] public static readonly PreceptDef Bestiality_Horrible = DefDatabase<PreceptDef>.GetNamed("Bestiality_Horrible");
[MayRequireIdeology] public static readonly PreceptDef Bestiality_Disapproved = DefDatabase<PreceptDef>.GetNamed("Bestiality_Disapproved");
[MayRequireIdeology] public static readonly PreceptDef Bestiality_Acceptable = DefDatabase<PreceptDef>.GetNamed("Bestiality_Acceptable");
[MayRequireIdeology] public static readonly PreceptDef Bestiality_OnlyVenerated = DefDatabase<PreceptDef>.GetNamed("Bestiality_OnlyVenerated");
@ -46,8 +44,6 @@ namespace RJWSexperience.Ideology
[MayRequireIdeology] public static readonly PreceptDef Rape_Disapproved = DefDatabase<PreceptDef>.GetNamed("Rape_Disapproved");
[MayRequireIdeology] public static readonly PreceptDef Rape_Acceptable = DefDatabase<PreceptDef>.GetNamed("Rape_Acceptable");
[MayRequireIdeology] public static readonly PreceptDef Rape_Honorable = DefDatabase<PreceptDef>.GetNamed("Rape_Honorable");
[MayRequireIdeology] public static readonly PreceptDef Incestuos_Disapproved = DefDatabase<PreceptDef>.GetNamed("Incestuos_Disapproved");
[MayRequireIdeology] public static readonly PreceptDef Incestuos_Forbidden = DefDatabase<PreceptDef>.GetNamed("Incestuos_Forbidden");
[MayRequireIdeology] public static readonly PreceptDef Incestuos_IncestOnly = DefDatabase<PreceptDef>.GetNamed("Incestuos_IncestOnly");
[MayRequireIdeology] public static readonly PreceptDef Incestuos_Disapproved_CloseOnly = DefDatabase<PreceptDef>.GetNamed("Incestuos_Disapproved_CloseOnly");
[MayRequireIdeology] public static readonly PreceptDef BabyFaction_AlwaysMother = DefDatabase<PreceptDef>.GetNamed("BabyFaction_AlwaysMother");

View file

@ -57,6 +57,18 @@
<exclusive>true</exclusive>
</li>
</comps>
<modExtensions>
<li Class="RJWSexperience.Ideology.PreceptDefExtension_ModifyPreference">
<rules>
<li>
<filter>
<isAnimal>true</isAnimal>
</filter>
<multiplier>0.05</multiplier>
</li>
</rules>
</li>
</modExtensions>
</PreceptDef>
<PreceptDef>
@ -96,6 +108,18 @@
<exclusive>true</exclusive>
</li>
</comps>
<modExtensions>
<li Class="RJWSexperience.Ideology.PreceptDefExtension_ModifyPreference">
<rules>
<li>
<filter>
<isAnimal>true</isAnimal>
</filter>
<multiplier>0.1</multiplier>
</li>
</rules>
</li>
</modExtensions>
</PreceptDef>
<PreceptDef>
@ -135,6 +159,18 @@
<exclusive>true</exclusive>
</li>
</comps>
<modExtensions>
<li Class="RJWSexperience.Ideology.PreceptDefExtension_ModifyPreference">
<rules>
<li>
<filter>
<isAnimal>true</isAnimal>
</filter>
<multiplier>0.5</multiplier>
</li>
</rules>
</li>
</modExtensions>
</PreceptDef>
<PreceptDef>
@ -187,6 +223,24 @@
<onlyForNonSlaves>true</onlyForNonSlaves>
</li>
</comps>
<modExtensions>
<li Class="RJWSexperience.Ideology.PreceptDefExtension_ModifyPreference">
<rules>
<li>
<filter>
<isVeneratedAnimal>true</isVeneratedAnimal>
</filter>
<multiplier>2.0</multiplier>
</li>
<li>
<filter>
<isVeneratedAnimal>false</isVeneratedAnimal>
</filter>
<multiplier>0.05</multiplier>
</li>
</rules>
</li>
</modExtensions>
</PreceptDef>
<PreceptDef>
@ -227,6 +281,18 @@
<onlyForNonSlaves>true</onlyForNonSlaves>
</li>
</comps>
<modExtensions>
<li Class="RJWSexperience.Ideology.PreceptDefExtension_ModifyPreference">
<rules>
<li>
<filter>
<isAnimal>true</isAnimal>
</filter>
<multiplier>2.0</multiplier>
</li>
</rules>
</li>
</modExtensions>
</PreceptDef>
<!-- Thoughts -->

View file

@ -67,6 +67,30 @@
<tag>Incestuos</tag>
</li>
</comps>
<modExtensions>
<li Class="RJWSexperience.Ideology.PreceptDefExtension_ModifyPreference">
<rules>
<li>
<filter>
<hasOneOfRelations>
<li>Parent</li>
<li>Child</li>
<li>Sibling</li>
<li>HalfSibling</li>
<li>Grandparent</li>
<li>Grandchild</li>
<li>NephewOrNiece</li>
<li>UncleOrAunt</li>
</hasOneOfRelations>
<hasNoneOfRelations>
<li>Spouse</li>
</hasNoneOfRelations>
</filter>
<multiplier>0.5</multiplier>
</li>
</rules>
</li>
</modExtensions>
</PreceptDef>
<PreceptDef>
@ -113,6 +137,38 @@
<tag>Incestuos</tag>
</li>
</comps>
<modExtensions>
<li Class="RJWSexperience.Ideology.PreceptDefExtension_ModifyPreference">
<rules>
<li>
<filter>
<hasOneOfRelations>
<li>Parent</li>
<li>Child</li>
<li>Sibling</li>
<li>HalfSibling</li>
<li>Grandparent</li>
<li>Grandchild</li>
<li>NephewOrNiece</li>
<li>UncleOrAunt</li>
<li>GreatGrandparent</li>
<li>GreatGrandchild</li>
<li>GranduncleOrGrandaunt</li>
<li>GrandnephewOrGrandniece</li>
<li>CousinOnceRemoved</li>
<li>SecondCousin</li>
<li>Cousin</li>
<li>Kin</li>
</hasOneOfRelations>
<hasNoneOfRelations>
<li>Spouse</li>
</hasNoneOfRelations>
</filter>
<multiplier>0.5</multiplier>
</li>
</rules>
</li>
</modExtensions>
</PreceptDef>
<PreceptDef>
@ -159,6 +215,38 @@
<tag>Incestuos</tag>
</li>
</comps>
<modExtensions>
<li Class="RJWSexperience.Ideology.PreceptDefExtension_ModifyPreference">
<rules>
<li>
<filter>
<hasOneOfRelations>
<li>Parent</li>
<li>Child</li>
<li>Sibling</li>
<li>HalfSibling</li>
<li>Grandparent</li>
<li>Grandchild</li>
<li>NephewOrNiece</li>
<li>UncleOrAunt</li>
<li>GreatGrandparent</li>
<li>GreatGrandchild</li>
<li>GranduncleOrGrandaunt</li>
<li>GrandnephewOrGrandniece</li>
<li>CousinOnceRemoved</li>
<li>SecondCousin</li>
<li>Cousin</li>
<li>Kin</li>
</hasOneOfRelations>
<hasNoneOfRelations>
<li>Spouse</li>
</hasNoneOfRelations>
</filter>
<multiplier>0.1</multiplier>
</li>
</rules>
</li>
</modExtensions>
</PreceptDef>
<PreceptDef>
@ -210,6 +298,35 @@
<exclusive>true</exclusive>
</li>
</comps>
<modExtensions>
<li Class="RJWSexperience.Ideology.PreceptDefExtension_ModifyPreference">
<rules>
<li>
<filter>
<hasOneOfRelations>
<li>Parent</li>
<li>Child</li>
<li>Sibling</li>
<li>HalfSibling</li>
<li>Grandparent</li>
<li>Grandchild</li>
<li>NephewOrNiece</li>
<li>UncleOrAunt</li>
<li>GreatGrandparent</li>
<li>GreatGrandchild</li>
<li>GranduncleOrGrandaunt</li>
<li>GrandnephewOrGrandniece</li>
<li>CousinOnceRemoved</li>
<li>SecondCousin</li>
<li>Cousin</li>
<li>Kin</li>
</hasOneOfRelations>
</filter>
<multiplier>2.0</multiplier>
</li>
</rules>
</li>
</modExtensions>
</PreceptDef>