Cleanup RJW_Patch_Ideo.cs

This commit is contained in:
amevarashi 2022-06-05 10:37:57 +05:00
parent 61bd959ba8
commit 3ab0c36b53

View file

@ -1,22 +1,18 @@
using System; using HarmonyLib;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using HarmonyLib;
using rjw;
using RimWorld; using RimWorld;
using Verse; using rjw;
using rjw.Modules.Interactions.Internals.Implementation;
using rjw.Modules.Interactions.Contexts; using rjw.Modules.Interactions.Contexts;
using rjw.Modules.Interactions.Internals.Implementation;
using rjw.Modules.Interactions.Objects; using rjw.Modules.Interactions.Objects;
using rjw.Modules.Interactions.Rules.InteractionRules; using rjw.Modules.Interactions.Rules.InteractionRules;
using System;
using System.Collections.Generic;
using Verse;
namespace RJWSexperience.Ideology namespace RJWSexperience.Ideology
{ {
public static class RJWUtility_Ideo public static class RJWUtility_Ideo
{ {
public static HistoryEvent TaggedEvent(this HistoryEventDef def, Pawn pawn, string tag, Pawn partner) public static HistoryEvent TaggedEvent(this HistoryEventDef def, Pawn pawn, string tag, Pawn partner)
{ {
return new HistoryEvent(def, pawn.Named(HistoryEventArgsNames.Doer), tag.Named(HistoryEventArgsNamesCustom.Tag), partner.Named(HistoryEventArgsNamesCustom.Partner)); return new HistoryEvent(def, pawn.Named(HistoryEventArgsNames.Doer), tag.Named(HistoryEventArgsNamesCustom.Tag), partner.Named(HistoryEventArgsNamesCustom.Partner));
@ -45,8 +41,6 @@ namespace RJWSexperience.Ideology
ideo = mother?.Ideo; ideo = mother?.Ideo;
return mother?.Faction ?? baby.Faction; return mother?.Faction ?? baby.Faction;
} }
} }
[HarmonyPatch(typeof(ThinkNode_ChancePerHour_Bestiality), "MtbHours")] [HarmonyPatch(typeof(ThinkNode_ChancePerHour_Bestiality), "MtbHours")]
@ -115,7 +109,6 @@ namespace RJWSexperience.Ideology
__result = __result || ideo.HasMeme(VariousDefOf.Rapist); __result = __result || ideo.HasMeme(VariousDefOf.Rapist);
} }
} }
} }
[HarmonyPatch(typeof(xxx), "is_zoophile")] [HarmonyPatch(typeof(xxx), "is_zoophile")]
@ -129,7 +122,6 @@ namespace RJWSexperience.Ideology
__result = __result || ideo.HasMeme(VariousDefOf.Zoophile); __result = __result || ideo.HasMeme(VariousDefOf.Zoophile);
} }
} }
} }
[HarmonyPatch(typeof(xxx), "is_necrophiliac")] [HarmonyPatch(typeof(xxx), "is_necrophiliac")]
@ -143,34 +135,26 @@ namespace RJWSexperience.Ideology
__result = __result || ideo.HasMeme(VariousDefOf.Necrophile); __result = __result || ideo.HasMeme(VariousDefOf.Necrophile);
} }
} }
} }
[HarmonyPatch(typeof(SexUtility), "Aftersex", new Type[] { typeof(SexProps) })] [HarmonyPatch(typeof(SexUtility), "Aftersex", new Type[] { typeof(SexProps) })]
public static class RJW_Patch_Aftersex public static class RJW_Patch_Aftersex
{ {
public static void Postfix(SexProps props) public static void Postfix(SexProps props)
{ {
Pawn pawn = props.pawn; Pawn pawn = props.pawn;
Pawn partner = props.partner; Pawn partner = props.partner;
bool usedCondom = props.usedCondom;
bool rape = props.isRape; bool rape = props.isRape;
bool isCoreLovin = props.isCoreLovin;
xxx.rjwSextype sextype = props.sexType; xxx.rjwSextype sextype = props.sexType;
if (partner != null) if (partner != null)
{ {
if (xxx.is_human(pawn)) AfterSexHuman(pawn, partner, usedCondom, rape, isCoreLovin, sextype); if (xxx.is_human(pawn)) AfterSexHuman(pawn, partner, rape, sextype);
else if (xxx.is_human(partner)) AfterSexHuman(partner, pawn, usedCondom, false, isCoreLovin, sextype, true); else if (xxx.is_human(partner)) AfterSexHuman(partner, pawn, false, sextype, true);
}
} }
} public static void AfterSexHuman(Pawn human, Pawn partner, bool rape, xxx.rjwSextype sextype, bool isHumanReceiving = false)
public static void AfterSexHuman(Pawn human, Pawn partner, bool usedCondom, bool rape, bool isCoreLovin, xxx.rjwSextype sextype, bool isHumanReceiving = false)
{ {
string tag = ""; string tag = "";
if (IdeoUtility.IsIncest(human, partner)) if (IdeoUtility.IsIncest(human, partner))
@ -236,17 +220,14 @@ namespace RJWSexperience.Ideology
if (suppression != null) if (suppression != null)
{ {
Hediff broken = victim.health.hediffSet.GetFirstHediffOfDef(xxx.feelingBroken); Hediff broken = victim.health.hediffSet.GetFirstHediffOfDef(xxx.feelingBroken);
if (broken != null) suppression.CurLevel += 0.3f * broken.Severity + 0.05f; if (broken != null) suppression.CurLevel += (0.3f * broken.Severity) + 0.05f;
else suppression.CurLevel += 0.05f; else suppression.CurLevel += 0.05f;
} }
} }
/// <summary> /// <summary>
/// only for non-violate human sex /// only for non-violate human sex
/// </summary> /// </summary>
/// <param name="pawn"></param>
/// <param name="partner"></param>
/// <param name="sextype"></param> /// <param name="sextype"></param>
/// <returns></returns> /// <returns></returns>
public static HistoryEventDef GetSexHistoryDef(xxx.rjwSextype sextype) public static HistoryEventDef GetSexHistoryDef(xxx.rjwSextype sextype)
@ -280,12 +261,9 @@ namespace RJWSexperience.Ideology
case xxx.rjwSextype.Sixtynine: case xxx.rjwSextype.Sixtynine:
return VariousDefOf.PromiscuousSex; return VariousDefOf.PromiscuousSex;
} }
} }
} }
/// <summary> /// <summary>
/// Set prefer sextype using precepts /// Set prefer sextype using precepts
/// </summary> /// </summary>
@ -294,13 +272,11 @@ namespace RJWSexperience.Ideology
{ {
public static void Postfix(InteractionContext context, InteractionWithExtension interaction, IInteractionRule rule, ref float __result) public static void Postfix(InteractionContext context, InteractionWithExtension interaction, IInteractionRule rule, ref float __result)
{ {
Ideo ideo = context.Inputs.Initiator.Ideo; Ideo ideo = context.Inputs.Initiator.Ideo;
if (ideo != null) PreceptSextype(ideo, context.Inputs.Initiator.GetStatValue(xxx.sex_drive_stat), ref __result, 0, interaction); if (ideo != null) PreceptSextype(ideo, context.Inputs.Initiator.GetStatValue(xxx.sex_drive_stat), ref __result, interaction);
ideo = context.Inputs.Partner.Ideo; ideo = context.Inputs.Partner.Ideo;
if (!context.Inputs.IsRape && ideo != null) PreceptSextype(ideo, context.Inputs.Partner.GetStatValue(xxx.sex_drive_stat), ref __result, 1, interaction); if (!context.Inputs.IsRape && ideo != null) PreceptSextype(ideo, context.Inputs.Partner.GetStatValue(xxx.sex_drive_stat), ref __result, interaction);
} }
private static readonly List<String> promiscuousSexTypes = new List<String> { private static readonly List<String> promiscuousSexTypes = new List<String> {
@ -310,7 +286,7 @@ namespace RJWSexperience.Ideology
"Fisting", "Fisting",
}; };
public static void PreceptSextype(Ideo ideo, float sexdrive, ref float result, int offset, InteractionWithExtension interaction) public static void PreceptSextype(Ideo ideo, float sexdrive, ref float result, InteractionWithExtension interaction)
{ {
float mult = 8.0f * Math.Max(0.3f, 1 / Math.Max(0.01f, sexdrive)); float mult = 8.0f * Math.Max(0.3f, 1 / Math.Max(0.01f, sexdrive));
if ((interaction.Extension.rjwSextype == "Vaginal") if ((interaction.Extension.rjwSextype == "Vaginal")
@ -336,7 +312,6 @@ namespace RJWSexperience.Ideology
} }
} }
[HarmonyPatch(typeof(SexAppraiser), "would_fuck", new Type[] { typeof(Pawn), typeof(Pawn), typeof(bool), typeof(bool), typeof(bool) })] [HarmonyPatch(typeof(SexAppraiser), "would_fuck", new Type[] { typeof(Pawn), typeof(Pawn), typeof(bool), typeof(bool), typeof(bool) })]
public static class RJW_Patch_would_fuck public static class RJW_Patch_would_fuck
{ {
@ -349,7 +324,10 @@ namespace RJWSexperience.Ideology
{ {
if (IdeoUtility.IsIncest(fucker, fucked)) if (IdeoUtility.IsIncest(fucker, fucked))
{ {
if (ideo.HasPrecept(VariousDefOf.Incestuos_IncestOnly)) __result *= 2.0f; if (ideo.HasPrecept(VariousDefOf.Incestuos_IncestOnly))
{
__result *= 2.0f;
}
else if (!fucker.relations?.DirectRelationExists(PawnRelationDefOf.Spouse, fucked) ?? false) else if (!fucker.relations?.DirectRelationExists(PawnRelationDefOf.Spouse, fucked) ?? false)
{ {
if (ideo.HasPrecept(VariousDefOf.Incestuos_Disapproved)) __result *= 0.5f; if (ideo.HasPrecept(VariousDefOf.Incestuos_Disapproved)) __result *= 0.5f;
@ -358,21 +336,27 @@ namespace RJWSexperience.Ideology
} }
if (fucked.IsAnimal()) if (fucked.IsAnimal())
{ {
if (ideo.HasPrecept(VariousDefOf.Bestiality_Honorable)) __result *= 2.0f; if (ideo.HasPrecept(VariousDefOf.Bestiality_Honorable))
{
__result *= 2.0f;
}
else if (ideo.HasPrecept(VariousDefOf.Bestiality_OnlyVenerated)) else if (ideo.HasPrecept(VariousDefOf.Bestiality_OnlyVenerated))
{ {
if (ideo.IsVeneratedAnimal(fucked)) __result *= 2.0f; if (ideo.IsVeneratedAnimal(fucked)) __result *= 2.0f;
else __result *= 0.05f; else __result *= 0.05f;
} }
else if (ideo.HasPrecept(VariousDefOf.Bestiality_Acceptable)) __result *= 1.0f; else if (ideo.HasPrecept(VariousDefOf.Bestiality_Acceptable))
else __result *= 0.5f; {
__result *= 1.0f;
}
else
{
__result *= 0.5f;
}
} }
} }
} }
} }
} }
[HarmonyPatch(typeof(PawnDesignations_Breedee), "UpdateCanDesignateBreeding")] [HarmonyPatch(typeof(PawnDesignations_Breedee), "UpdateCanDesignateBreeding")]
@ -381,7 +365,7 @@ namespace RJWSexperience.Ideology
public static void Postfix(Pawn pawn, ref bool __result) public static void Postfix(Pawn pawn, ref bool __result)
{ {
Ideo ideo = pawn.Ideo; Ideo ideo = pawn.Ideo;
if (ideo != null && ideo.HasMeme(VariousDefOf.Zoophile)) if (ideo?.HasMeme(VariousDefOf.Zoophile) == true)
{ {
SaveStorage.DataStore.GetPawnData(pawn).CanDesignateBreeding = true; SaveStorage.DataStore.GetPawnData(pawn).CanDesignateBreeding = true;
__result = true; __result = true;
@ -416,5 +400,4 @@ namespace RJWSexperience.Ideology
} }
} }
} }
} }