RJW-Sexperience/RJWSexperience/IdeologyAddon/Ideology/Patches/Rimworld_Patch.cs

74 lines
2.2 KiB
C#
Raw Normal View History

2022-02-25 14:15:48 +00:00
using HarmonyLib;
2021-08-21 16:29:59 +00:00
using RimWorld;
using rjw;
2022-06-19 13:26:35 +00:00
using RJWSexperience.Ideology.Precepts;
2022-02-25 14:15:48 +00:00
using System.Collections.Generic;
using Verse;
2021-08-21 16:29:59 +00:00
2022-06-20 04:51:35 +00:00
namespace RJWSexperience.Ideology.Patches
2021-08-21 16:29:59 +00:00
{
2022-02-25 14:15:48 +00:00
[HarmonyPatch(typeof(MarriageCeremonyUtility), "Married")]
public static class Rimworld_Patch_Marriage
{
public static void Postfix(Pawn firstPawn, Pawn secondPawn)
{
if (IdeoUtility.IsIncest(firstPawn, secondPawn))
{
Find.HistoryEventsManager.RecordEvent(new HistoryEvent(VariousDefOf.Incestuos_Marriage, firstPawn.Named(HistoryEventArgsNames.Doer)));
Find.HistoryEventsManager.RecordEvent(new HistoryEvent(VariousDefOf.Incestuos_Marriage, secondPawn.Named(HistoryEventArgsNames.Doer)));
}
}
}
[HarmonyPatch(typeof(Pawn_RelationsTracker), "SecondaryRomanceChanceFactor")]
public static class Rimworld_Patch_SecondaryRomanceChanceFactor
{
public static void Postfix(Pawn otherPawn, Pawn ___pawn, ref float __result)
{
Ideo ideo = ___pawn.Ideo;
2022-04-15 16:46:29 +00:00
if (ideo?.HasPrecept(VariousDefOf.Incestuos_IncestOnly) == true && IdeoUtility.IsIncest(___pawn, otherPawn))
2022-02-25 14:15:48 +00:00
{
2022-04-15 16:46:29 +00:00
__result *= 8f;
2022-02-25 14:15:48 +00:00
}
}
}
[HarmonyPatch(typeof(RitualOutcomeEffectWorker_FromQuality), "GiveMemoryToPawn")]
public static class Rimworld_Patch_GiveMemoryToPawn
{
public static bool Prefix(Pawn pawn, ThoughtDef memory, LordJob_Ritual jobRitual)
{
if (pawn.IsAnimal()) return false;
return true;
}
}
[HarmonyPatch(typeof(IdeoFoundation), "CanAdd")]
public static class Rimworld_Patch_IdeoFoundation
{
public static void Postfix(PreceptDef precept, bool checkDuplicates, ref IdeoFoundation __instance, ref AcceptanceReport __result)
{
2022-06-19 13:26:35 +00:00
DefExtension_MultipleMemesRequired extension = precept.GetModExtension<DefExtension_MultipleMemesRequired>();
if (extension == null)
return;
if (extension.requiredAllMemes.NullOrEmpty())
return;
for (int i = 0; i < extension.requiredAllMemes.Count; i++)
2022-02-25 14:15:48 +00:00
{
if (!__instance.ideo.memes.Contains(extension.requiredAllMemes[i]))
2022-02-25 14:15:48 +00:00
{
List<string> report = new List<string>();
foreach (MemeDef meme in extension.requiredAllMemes) report.Add(meme.LabelCap);
2022-02-25 14:15:48 +00:00
__result = new AcceptanceReport("RequiresMeme".Translate() + ": " + report.ToCommaList());
return;
2022-02-25 14:15:48 +00:00
}
}
}
}
2021-08-21 16:29:59 +00:00
}