mirror of
https://gitgud.io/LonelyRain/rjw-quirks.git
synced 2024-08-15 00:03:31 +00:00
Initial upload
This commit is contained in:
parent
feb28b10a4
commit
7585da099c
106 changed files with 4860 additions and 0 deletions
74
RJW-Quirks/HarmonyPatches/Patch_CasualSex_Helper.cs
Normal file
74
RJW-Quirks/HarmonyPatches/Patch_CasualSex_Helper.cs
Normal file
|
@ -0,0 +1,74 @@
|
|||
using HarmonyLib;
|
||||
using RimWorld;
|
||||
using rjw;
|
||||
using rjwquirks.Modules.Quirks;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Verse;
|
||||
|
||||
namespace rjwquirks.HarmonyPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(CasualSex_Helper), nameof(CasualSex_Helper.GetScore))]
|
||||
public class Patch_CasualSex_Helper
|
||||
{
|
||||
// Edits the "score" of a cell for a pawn to fuck in
|
||||
public static void Postfix(Pawn pawn, IntVec3 cell, Pawn partner, ref int __result)
|
||||
{
|
||||
QuirkSet quirks = pawn.GetQuirks();
|
||||
|
||||
if (quirks.AllQuirks.EnumerableNullOrEmpty())
|
||||
return;
|
||||
|
||||
List<Pawn> all_pawns = pawn.Map.mapPawns.AllPawnsSpawned.Where(x
|
||||
=> x.Position.DistanceTo(pawn.Position) < 100
|
||||
&& xxx.is_human(x)
|
||||
&& x != pawn
|
||||
&& x != partner
|
||||
).ToList();
|
||||
|
||||
// Somnophile code
|
||||
if (partner != null && quirks.Contains(QuirkDefOf.Somnophile))
|
||||
{
|
||||
if (all_pawns.Any(x
|
||||
=> !x.Awake()
|
||||
&& x.Position.DistanceTo(cell) < 6
|
||||
&& GenSight.LineOfSight(cell, x.Position, pawn.Map)
|
||||
))
|
||||
__result += 50;
|
||||
}
|
||||
|
||||
// Exhibitionist code
|
||||
if (quirks.Contains(QuirkDefOf.Exhibitionist))
|
||||
{
|
||||
bool might_be_seen = CasualSex_Helper.MightBeSeen(all_pawns, cell, pawn, partner);
|
||||
Room room = cell.GetRoom(pawn.Map);
|
||||
|
||||
// Readd the 30 score removed in regular RJW
|
||||
__result += 30;
|
||||
// Readd the 100 score taken from being in a doorway in regular RJW
|
||||
__result += 100;
|
||||
|
||||
if (might_be_seen)
|
||||
__result += 5;
|
||||
else
|
||||
__result -= 10;
|
||||
|
||||
if (room.Role == RoomRoleDefOf.Barracks || room.Role == RoomRoleDefOf.PrisonBarracks || room.Role == RoomRoleDefOf.PrisonCell
|
||||
|| room.Role == RoomRoleDefOf.Laboratory || room.Role == RoomRoleDefOf.RecRoom
|
||||
|| room.Role == RoomRoleDefOf.DiningRoom || room.Role == RoomRoleDefOf.Hospital
|
||||
)
|
||||
__result += 15; // Add 15 instead of 10 to counteract the -5 in regular RJW
|
||||
|
||||
Dictionary<int, int> cell_doors = new Dictionary<int, int>();
|
||||
|
||||
var doors = cell_doors.TryGetValue(room.ID);
|
||||
|
||||
if (doors > 1)
|
||||
__result += 7 * doors; // Multiply by 7 instead of 2 to counteract the negative in regular RJW
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
37
RJW-Quirks/HarmonyPatches/Patch_CondomUtility.cs
Normal file
37
RJW-Quirks/HarmonyPatches/Patch_CondomUtility.cs
Normal file
|
@ -0,0 +1,37 @@
|
|||
using HarmonyLib;
|
||||
using rjw;
|
||||
using rjwquirks.Modules.Quirks;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Verse;
|
||||
|
||||
namespace rjwquirks.HarmonyPatches
|
||||
{
|
||||
// Skips condom code entirely if they have pregnation fetish or similar. RJW used to do this with the same quirk.
|
||||
[HarmonyPatch(typeof(CondomUtility))]
|
||||
public class Patch_CondomUtility
|
||||
{
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(nameof(CondomUtility.TryUseCondom))]
|
||||
public static bool UseCondomPrefix(Pawn pawn)
|
||||
{
|
||||
if (xxx.is_human(pawn) && pawn.HasQuirk(QuirkDefOf.ImpregnationFetish))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(nameof(CondomUtility.GetCondomFromRoom))]
|
||||
public static bool GetCondomPrefix(Pawn pawn)
|
||||
{
|
||||
if (xxx.is_human(pawn) && pawn.HasQuirk(QuirkDefOf.ImpregnationFetish))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
131
RJW-Quirks/HarmonyPatches/Patch_Dialog_Sexcard.cs
Normal file
131
RJW-Quirks/HarmonyPatches/Patch_Dialog_Sexcard.cs
Normal file
|
@ -0,0 +1,131 @@
|
|||
using HarmonyLib;
|
||||
using rjw;
|
||||
using rjwquirks.Modules.Quirks;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Reflection.Emit;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using Verse;
|
||||
|
||||
namespace rjwquirks.HarmonyPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(Dialog_Sexcard), "SexualityCard")]
|
||||
public static class Patch_Dialog_Sexcard
|
||||
{
|
||||
static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
|
||||
{
|
||||
MethodInfo InsertQuirks = AccessTools.Method(typeof(Patch_Dialog_Sexcard), nameof(DrawQuirks));
|
||||
MethodInfo DrawSexuality = AccessTools.Method(typeof(Dialog_Sexcard), "DrawSexuality");
|
||||
bool found = false;
|
||||
|
||||
// When RJW calls draw sexuality we inject our quirk drawing.
|
||||
foreach (CodeInstruction i in instructions)
|
||||
{
|
||||
if (i.opcode == OpCodes.Call && i.operand as MethodInfo == DrawSexuality)
|
||||
found = true;
|
||||
|
||||
if (found)
|
||||
{
|
||||
yield return new CodeInstruction(OpCodes.Ldarg_2);
|
||||
yield return new CodeInstruction(OpCodes.Ldloc_3);
|
||||
yield return new CodeInstruction(OpCodes.Call, InsertQuirks);
|
||||
found = false;
|
||||
}
|
||||
|
||||
yield return i;
|
||||
}
|
||||
}
|
||||
|
||||
public static void DrawQuirks(Pawn pawn, Rect rect)
|
||||
{
|
||||
QuirkSet quirks = pawn.GetQuirks();
|
||||
rect.y += 24;
|
||||
|
||||
if (quirks == null)
|
||||
return;
|
||||
|
||||
var quirkString = quirks.AllQuirks
|
||||
.Select(quirk => quirk.Label)
|
||||
.OrderBy(Label => Label)
|
||||
.ToCommaList();
|
||||
|
||||
if ((Current.ProgramState == ProgramState.Playing &&
|
||||
pawn.IsDesignatedHero() && pawn.IsHeroOwner() || Prefs.DevMode) ||
|
||||
Current.ProgramState == ProgramState.Entry)
|
||||
{
|
||||
if (Widgets.ButtonText(rect, "Quirks".Translate() + quirkString, false))
|
||||
DrawQuirkEditMenu(pawn, quirks);
|
||||
}
|
||||
else
|
||||
Widgets.Label(rect, "Quirks".Translate() + quirkString);
|
||||
|
||||
if (!Mouse.IsOver(rect)) return;
|
||||
|
||||
Widgets.DrawHighlight(rect);
|
||||
|
||||
TooltipHandler.TipRegion(rect, quirks.TipString());
|
||||
}
|
||||
|
||||
static void DrawQuirkEditMenu(Pawn pawn, QuirkSet quirks)
|
||||
{
|
||||
var quirkDefsAll = DefDatabase<QuirkDef>.AllDefs.OrderBy(def => def.GetLabelFor(pawn));
|
||||
|
||||
var menuOptions = new List<FloatMenuOption>();
|
||||
|
||||
if (RJWSettings.DevMode)
|
||||
menuOptions.Add(new FloatMenuOption("[DEV] Forced Reset", () => quirks.Clear(true)));
|
||||
|
||||
menuOptions.Add(new FloatMenuOption("Reset", () => quirks.Clear()));
|
||||
|
||||
foreach (QuirkDef quirkDef in quirkDefsAll)
|
||||
{
|
||||
if (quirkDef.hidden && !RJWSettings.DevMode && !quirks.Contains(quirkDef))
|
||||
continue;
|
||||
|
||||
Quirk quirk = quirks.GetQuirk(quirkDef);
|
||||
FloatMenuOption option;
|
||||
|
||||
if (quirk == null)
|
||||
{
|
||||
AcceptanceReport report = quirks.CanBeAdded(quirkDef);
|
||||
if (report.Accepted)
|
||||
{
|
||||
option = new FloatMenuOption(
|
||||
quirkDef.GetLabelFor(pawn),
|
||||
() => quirks.AddQuirk(quirkDef),
|
||||
mouseoverGuiAction: (Rect rect) => TooltipHandler.TipRegion(rect, quirkDef.GetDescriptionFor(pawn))
|
||||
);
|
||||
}
|
||||
else if (RJWSettings.DevMode)
|
||||
option = new FloatMenuOption($"[DEV]{quirkDef.GetLabelFor(pawn)}: {report.Reason}", () => quirks.AddQuirk(quirkDef, true));
|
||||
else
|
||||
// Game does not call mouseoverGuiAction for the disabled entries
|
||||
option = new FloatMenuOption($"{quirkDef.GetLabelFor(pawn)}: {report.Reason}", null);
|
||||
}
|
||||
else
|
||||
{
|
||||
AcceptanceReport report = quirks.CanBeRemoved(quirkDef);
|
||||
if (report.Accepted)
|
||||
{
|
||||
option = new FloatMenuOption(
|
||||
"- " + quirk.Label,
|
||||
() => quirks.RemoveQuirk(quirk),
|
||||
mouseoverGuiAction: (Rect rect) => TooltipHandler.TipRegion(rect, quirk.Description)
|
||||
);
|
||||
}
|
||||
else if (RJWSettings.DevMode)
|
||||
option = new FloatMenuOption($"- {quirk.Label}: {report.Reason}", () => quirks.RemoveQuirk(quirk, true));
|
||||
else
|
||||
option = new FloatMenuOption($"- {quirk.Label}: {report.Reason}", null);
|
||||
}
|
||||
|
||||
menuOptions.Add(option);
|
||||
}
|
||||
Find.WindowStack.Add(new FloatMenu(menuOptions));
|
||||
}
|
||||
}
|
||||
}
|
24
RJW-Quirks/HarmonyPatches/Patch_DrawNude.cs
Normal file
24
RJW-Quirks/HarmonyPatches/Patch_DrawNude.cs
Normal file
|
@ -0,0 +1,24 @@
|
|||
using HarmonyLib;
|
||||
using rjw;
|
||||
using rjwquirks.Modules.Quirks;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Verse;
|
||||
|
||||
namespace rjwquirks.HarmonyPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(SexUtility), nameof(SexUtility.DrawNude))]
|
||||
public class Patch_DrawNude
|
||||
{
|
||||
public static bool Prefix(Pawn pawn)
|
||||
{
|
||||
if (pawn.HasQuirk(QuirkDefOf.Endytophile))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
35
RJW-Quirks/HarmonyPatches/Patch_Hediff_BasePregnancy.cs
Normal file
35
RJW-Quirks/HarmonyPatches/Patch_Hediff_BasePregnancy.cs
Normal file
|
@ -0,0 +1,35 @@
|
|||
using HarmonyLib;
|
||||
using rjw;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection.Emit;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Verse;
|
||||
|
||||
namespace rjwquirks.HarmonyPatches
|
||||
{
|
||||
/*[HarmonyPatch(typeof(Hediff_BasePregnancy))]
|
||||
public class Patch_Hediff_BasePregnancy
|
||||
{
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch("GenerateBabies")]
|
||||
public static IEnumerable<CodeInstruction> AdjustMaxLitterSize(IEnumerable<CodeInstruction> instructions)
|
||||
{
|
||||
bool found = false;
|
||||
|
||||
foreach (CodeInstruction i in instructions)
|
||||
{
|
||||
if (i.opcode == OpCodes.Ldc_R4 && i.operand as string == "0.33333334")
|
||||
found = true;
|
||||
|
||||
if (found && i.opcode == OpCodes.Stloc_S)
|
||||
Log.Warning(i.operand as string);
|
||||
|
||||
|
||||
yield return i;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
43
RJW-Quirks/HarmonyPatches/Patch_Hediff_PartBaseArtifical.cs
Normal file
43
RJW-Quirks/HarmonyPatches/Patch_Hediff_PartBaseArtifical.cs
Normal file
|
@ -0,0 +1,43 @@
|
|||
using HarmonyLib;
|
||||
using rjw;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Reflection.Emit;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Verse;
|
||||
|
||||
namespace rjwquirks.HarmonyPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(Hediff_PartBaseArtifical))]
|
||||
public class Patch_Hediff_PartBaseArtifical
|
||||
{
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch(nameof(Hediff_PartBaseArtifical.Tick))]
|
||||
public static IEnumerable<CodeInstruction> ChangeMaxEggsSize(IEnumerable<CodeInstruction> instructions)
|
||||
{
|
||||
FieldInfo Pawn = AccessTools.Field(typeof(Hediff_PartBaseArtifical), nameof(Hediff_PartBaseArtifical.pawn));
|
||||
MethodInfo EggSize = AccessTools.Method(typeof(Patch_Hediff_PartBaseArtifical), nameof(EditMaxEggsSize));
|
||||
|
||||
foreach (CodeInstruction i in instructions)
|
||||
{
|
||||
if (i.opcode == OpCodes.Ldc_R4 && i.operand as string == "0.0")
|
||||
{
|
||||
yield return new CodeInstruction(OpCodes.Ldfld, Pawn);
|
||||
yield return new CodeInstruction(OpCodes.Ldloc_3);
|
||||
yield return new CodeInstruction(OpCodes.Call, EggSize);
|
||||
}
|
||||
|
||||
yield return i;
|
||||
}
|
||||
}
|
||||
|
||||
public static void EditMaxEggsSize(Pawn pawn, float eggsSize)
|
||||
{
|
||||
if (pawn.GetQuirks() != null)
|
||||
pawn.GetQuirks().ApplyValueModifiers("maxEggsSize", ref eggsSize);
|
||||
}
|
||||
}
|
||||
}
|
47
RJW-Quirks/HarmonyPatches/Patch_Hediff_PartBaseNatural.cs
Normal file
47
RJW-Quirks/HarmonyPatches/Patch_Hediff_PartBaseNatural.cs
Normal file
|
@ -0,0 +1,47 @@
|
|||
using HarmonyLib;
|
||||
using rjw;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection.Emit;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Verse;
|
||||
|
||||
namespace rjwquirks.HarmonyPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(Hediff_PartBaseNatural))]
|
||||
public class Patch_Hediff_PartBaseNatural
|
||||
{
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch(nameof(Hediff_PartBaseNatural.Tick))]
|
||||
public static IEnumerable<CodeInstruction> ChangeMaxEggsSize(IEnumerable<CodeInstruction> instructions)
|
||||
{
|
||||
FieldInfo Pawn = AccessTools.Field(typeof(Hediff_PartBaseNatural), nameof(Hediff_PartBaseNatural.pawn));
|
||||
MethodInfo EggSize = AccessTools.Method(typeof(Patch_Hediff_PartBaseNatural), nameof(EditMaxEggsSize));
|
||||
bool found = false;
|
||||
|
||||
foreach (CodeInstruction i in instructions)
|
||||
{
|
||||
if (i.opcode == OpCodes.Ldc_R4 && i.operand as string == "0.0" && found)
|
||||
{
|
||||
yield return new CodeInstruction(OpCodes.Ldfld, Pawn);
|
||||
yield return new CodeInstruction(OpCodes.Ldloc_3);
|
||||
yield return new CodeInstruction(OpCodes.Call, EggSize);
|
||||
}
|
||||
|
||||
if (i.opcode == OpCodes.Ldc_R4 && i.operand as string == "0.0")
|
||||
found = true;
|
||||
|
||||
yield return i;
|
||||
}
|
||||
}
|
||||
|
||||
public static void EditMaxEggsSize(Pawn pawn, float eggsSize)
|
||||
{
|
||||
if (pawn.GetQuirks() != null)
|
||||
pawn.GetQuirks().ApplyValueModifiers("maxEggsSize", ref eggsSize);
|
||||
}
|
||||
}
|
||||
}
|
59
RJW-Quirks/HarmonyPatches/Patch_JobGiver_Masturbate.cs
Normal file
59
RJW-Quirks/HarmonyPatches/Patch_JobGiver_Masturbate.cs
Normal file
|
@ -0,0 +1,59 @@
|
|||
using HarmonyLib;
|
||||
using rjw;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection.Emit;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Verse;
|
||||
using rjwquirks.Modules.Quirks;
|
||||
|
||||
namespace rjwquirks.HarmonyPatches
|
||||
{
|
||||
/*[HarmonyPatch(typeof(JobGiver_Masturbate))]
|
||||
public class Patch_JobGiver_Masturbate
|
||||
{
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch("TryGiveJob")]
|
||||
public static IEnumerable<CodeInstruction> ApplyQuirkToMasturbate(IEnumerable<CodeInstruction> instructions)
|
||||
{
|
||||
MethodInfo Frustrated = AccessTools.Method(typeof(xxx), nameof(xxx.is_frustrated));
|
||||
MethodInfo Apply = AccessTools.Method(typeof(Patch_JobGiver_Masturbate), nameof(ApplyQuirk));
|
||||
var labels = instructions.ElementAt(0).labels.ListFullCopy<Label>();
|
||||
Log.Warning(labels.Count.ToString());
|
||||
bool found = false;
|
||||
|
||||
foreach (CodeInstruction i in instructions)
|
||||
{
|
||||
if (i.opcode == OpCodes.Call && i.operand as MethodInfo == Frustrated)
|
||||
{
|
||||
yield return new CodeInstruction(OpCodes.Ldarg_1);
|
||||
yield return new CodeInstruction(OpCodes.Call, Apply);
|
||||
yield return new CodeInstruction(OpCodes.Brtrue_S, labels[4]);
|
||||
found = true;
|
||||
}
|
||||
|
||||
if (found && i.opcode == OpCodes.Call && i.operand as MethodInfo == Frustrated)
|
||||
{
|
||||
yield return new CodeInstruction(OpCodes.Ldarg_1);
|
||||
yield return new CodeInstruction(OpCodes.Call, Apply);
|
||||
yield return new CodeInstruction(OpCodes.Brtrue_S, labels[5]);
|
||||
found = false;
|
||||
}
|
||||
|
||||
|
||||
yield return i;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool ApplyQuirk(Pawn pawn)
|
||||
{
|
||||
if (pawn.GetQuirks() != null)
|
||||
return pawn.HasQuirk(QuirkDefOf.Exhibitionist);
|
||||
|
||||
return false;
|
||||
}
|
||||
}*/
|
||||
}
|
28
RJW-Quirks/HarmonyPatches/Patch_QuirkPartPreference.cs
Normal file
28
RJW-Quirks/HarmonyPatches/Patch_QuirkPartPreference.cs
Normal file
|
@ -0,0 +1,28 @@
|
|||
using HarmonyLib;
|
||||
using rjw.Modules.Interactions.Contexts;
|
||||
using rjw.Modules.Interactions.Internals.Implementation;
|
||||
using rjw.Modules.Interactions.Rules.PartKindUsageRules;
|
||||
using rjwquirks.Modules.Interactions;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Verse;
|
||||
|
||||
namespace rjwquirks.HarmonyPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(PartPreferenceDetectorService), nameof(PartPreferenceDetectorService.DetectPartPreferences))]
|
||||
public class Patch_QuirkPartPreference
|
||||
{
|
||||
public static void Prefix(InteractionContext context, IList<IPartPreferenceRule> ____partKindUsageRules)
|
||||
{
|
||||
if (____partKindUsageRules.Any(x => x.GetType() == typeof(QuirksPartKindUsageRule)) || (context.Internals.Submissive.Pawn.GetQuirks() == null || context.Internals.Dominant.Pawn.GetQuirks() == null))
|
||||
return;
|
||||
|
||||
Log.Warning(____partKindUsageRules.Count().ToString());
|
||||
____partKindUsageRules.Add(new QuirksPartKindUsageRule());
|
||||
Log.Warning(____partKindUsageRules.Count().ToString());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
using HarmonyLib;
|
||||
using RimWorld;
|
||||
using rjwquirks.Modules.Shared.Events;
|
||||
using Verse;
|
||||
|
||||
namespace rjwquirks.HarmonyPatches
|
||||
{
|
||||
/// <summary>
|
||||
/// Patch to generate events on record changes
|
||||
/// </summary>
|
||||
[HarmonyPatch(typeof(Pawn_RecordsTracker))]
|
||||
public static class Patch_RecordsTracker_NotifyRecordChanged
|
||||
{
|
||||
[HarmonyPatch(nameof(Pawn_RecordsTracker.Increment))]
|
||||
[HarmonyPostfix]
|
||||
public static void IncrementPostfix(Pawn_RecordsTracker __instance, RecordDef def)
|
||||
{
|
||||
NotifyEvent(__instance.pawn, def);
|
||||
}
|
||||
|
||||
[HarmonyPatch(nameof(Pawn_RecordsTracker.AddTo))]
|
||||
[HarmonyPostfix]
|
||||
public static void AddToPostfix(Pawn_RecordsTracker __instance, RecordDef def)
|
||||
{
|
||||
NotifyEvent(__instance.pawn, def);
|
||||
}
|
||||
|
||||
private static void NotifyEvent(Pawn pawn, RecordDef def) => RjwEventManager.NotifyEvent(new RjwEvent(RjwEventDefOf.RecordChanged, pawn.Named(RjwEventArgNames.Pawn), def.Named(RjwEventArgNames.Record)));
|
||||
}
|
||||
}
|
64
RJW-Quirks/HarmonyPatches/Patch_SexAppraiser.cs
Normal file
64
RJW-Quirks/HarmonyPatches/Patch_SexAppraiser.cs
Normal file
|
@ -0,0 +1,64 @@
|
|||
using HarmonyLib;
|
||||
using rjw;
|
||||
using rjwquirks.Modules.Quirks;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Verse;
|
||||
|
||||
namespace rjwquirks.HarmonyPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(SexAppraiser))]
|
||||
public class Patch_SexAppraiser
|
||||
{
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(nameof(SexAppraiser.GetMinSizePreference))]
|
||||
public static void AdjustMinSize(Pawn pawn, ref float __result)
|
||||
{
|
||||
if (pawn.GetQuirks() != null)
|
||||
pawn.GetQuirks().ApplyValueModifiers("wouldFuckAnimalBodySizeMin", ref __result);
|
||||
}
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(nameof(SexAppraiser.GetMaxSizePreference))]
|
||||
public static void AdjustMaxSize(Pawn pawn, ref float __result)
|
||||
{
|
||||
if (pawn.GetQuirks() != null)
|
||||
pawn.GetQuirks().ApplyValueModifiers("wouldFuckAnimalBodySizeMax", ref __result);
|
||||
}
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(nameof(SexAppraiser.GetMinSizePreference))]
|
||||
public static void AdjustWildnessModifier(Pawn pawn, ref float __result)
|
||||
{
|
||||
if (pawn.GetQuirks() != null)
|
||||
pawn.GetQuirks().ApplyValueModifiers("wouldFuckAnimalWildnessModifier", ref __result);
|
||||
}
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch("GetOpinionFactor")]
|
||||
public static void AdjustOpinionFactor(Pawn fucker, Pawn fucked, ref float __result)
|
||||
{
|
||||
if (fucker.GetQuirks() != null)
|
||||
fucker.GetQuirks().ApplySexAppraisalModifiers(fucked, "opinionFactor", ref __result);
|
||||
}
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch("GetBodyFactor")]
|
||||
public static void AdjustBodyFactor(Pawn fucker, Pawn fucked, ref float __result)
|
||||
{
|
||||
if (fucker.GetQuirks() != null)
|
||||
fucker.GetQuirks().ApplySexAppraisalModifiers(fucked, "bodyFactor", ref __result);
|
||||
}
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch("GetAgeFactor")]
|
||||
public static void AdjustAgeFactor(Pawn fucker, Pawn fucked, int p_age, ref float __result)
|
||||
{
|
||||
if (fucker.GetQuirks() != null)
|
||||
fucker.GetQuirks().ApplySexAppraisalModifiers(fucked, "ageFactor", ref __result);
|
||||
}
|
||||
}
|
||||
}
|
146
RJW-Quirks/HarmonyPatches/Patch_SexUtility.cs
Normal file
146
RJW-Quirks/HarmonyPatches/Patch_SexUtility.cs
Normal file
|
@ -0,0 +1,146 @@
|
|||
using HarmonyLib;
|
||||
using RimWorld;
|
||||
using rjw;
|
||||
using rjwquirks.Modules.Quirks;
|
||||
using rjwquirks.Modules.Shared.Events;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Reflection.Emit;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Verse;
|
||||
|
||||
namespace rjwquirks.HarmonyPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(SexUtility))]
|
||||
public class Patch_SexUtility
|
||||
{
|
||||
// Increases cum filth generated by pawn
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(nameof(SexUtility.CumOutputModifier))]
|
||||
public static void FilthAdder(Pawn pawn, ref float __result)
|
||||
{
|
||||
if(pawn.GetQuirks() != null)
|
||||
pawn.GetQuirks().ApplyValueModifiers("cumFilthAmount", ref __result);
|
||||
}
|
||||
|
||||
// Change how much the pawn wants to clean post sex
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch(nameof(SexUtility.ConsiderCleaning))]
|
||||
static IEnumerable<CodeInstruction> ConsiderCleanup(IEnumerable<CodeInstruction> instructions)
|
||||
{
|
||||
FieldInfo PawnNeeds = AccessTools.Field(typeof(Pawn), nameof(Pawn.needs));
|
||||
MethodInfo Cleanup = AccessTools.Method(typeof(Patch_SexUtility), nameof(CleanupChanceAdjuster));
|
||||
|
||||
bool found = false;
|
||||
|
||||
foreach (CodeInstruction i in instructions)
|
||||
{
|
||||
if (found)
|
||||
{
|
||||
yield return i;
|
||||
yield return new CodeInstruction(OpCodes.Ldloc_0);
|
||||
yield return new CodeInstruction(OpCodes.Ldarg_0);
|
||||
yield return new CodeInstruction(OpCodes.Call, Cleanup);
|
||||
found = false;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (i.opcode == OpCodes.Ldfld && i.operand as FieldInfo == PawnNeeds)
|
||||
found = true;
|
||||
|
||||
yield return i;
|
||||
}
|
||||
}
|
||||
|
||||
public static void CleanupChanceAdjuster(float chance, Pawn pawn)
|
||||
{
|
||||
pawn.GetQuirks().ApplyValueModifiers("cleanAfterFapChance", ref chance);
|
||||
}
|
||||
|
||||
// Change satisfaction from sex
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(nameof(SexUtility.GetExtraSatisfaction))]
|
||||
public static void Satisfaction(SexProps props, ref float __result)
|
||||
{
|
||||
var quirkCount = props.pawn.GetQuirks().GetSatisfiedBySex(props).Count();
|
||||
|
||||
if (quirkCount > 0)
|
||||
{
|
||||
__result += props.pawn.GetQuirks().GetSatisfiedBySex(props).Count() * 0.20f;
|
||||
RjwEventManager.NotifyEvent(new RjwEvent(RjwEventDefOf.Orgasm, props.Named(RjwEventArgNames.SexProps), __result.Named(RjwEventArgNames.Satisfaction)));
|
||||
}
|
||||
}
|
||||
|
||||
// Change ticks to next lovin
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch(nameof(SexUtility.GenerateMinTicksToNextLovin))]
|
||||
public static IEnumerable<CodeInstruction> ChangeTicksToNextLovin(IEnumerable<CodeInstruction> instructions)
|
||||
{
|
||||
MethodInfo SexDrive = AccessTools.Method(typeof(xxx), nameof(xxx.get_sex_drive));
|
||||
MethodInfo AdjustTicks = AccessTools.Method(typeof(Patch_SexUtility), nameof(AdjustTicksToNextLovin));
|
||||
bool found = false;
|
||||
|
||||
foreach (var i in instructions)
|
||||
{
|
||||
if (found)
|
||||
{
|
||||
yield return i;
|
||||
yield return new CodeInstruction(OpCodes.Ldloc_0);
|
||||
yield return new CodeInstruction(OpCodes.Ldarg_0);
|
||||
yield return new CodeInstruction(OpCodes.Call, AdjustTicks);
|
||||
found = false;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (i.opcode == OpCodes.Call && i.operand as MethodInfo == SexDrive)
|
||||
found = true;
|
||||
|
||||
yield return i;
|
||||
}
|
||||
}
|
||||
|
||||
public static void AdjustTicksToNextLovin(float ticks, Pawn pawn)
|
||||
{
|
||||
if (pawn.GetQuirks() != null)
|
||||
{
|
||||
pawn.GetQuirks().ApplyValueModifiers("ticksToNextLovin", ref ticks);
|
||||
}
|
||||
}
|
||||
|
||||
// Rest adjustments
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch(nameof(SexUtility.reduce_rest))]
|
||||
public static IEnumerable<CodeInstruction> AdjustRest(IEnumerable<CodeInstruction> instructions)
|
||||
{
|
||||
MethodInfo Adjustment = AccessTools.Method(typeof(Patch_SexUtility), nameof(AdjustRestFromQuirk));
|
||||
bool found = false;
|
||||
bool completed = false;
|
||||
|
||||
foreach (CodeInstruction i in instructions)
|
||||
{
|
||||
if (found && !completed)
|
||||
{
|
||||
yield return new CodeInstruction(OpCodes.Ldarg_0);
|
||||
yield return new CodeInstruction(OpCodes.Ldarg_1);
|
||||
yield return new CodeInstruction(OpCodes.Call, Adjustment);
|
||||
completed = true;
|
||||
found = false;
|
||||
}
|
||||
|
||||
if (i.opcode == OpCodes.Dup)
|
||||
found = true;
|
||||
|
||||
yield return i;
|
||||
}
|
||||
}
|
||||
|
||||
public static void AdjustRestFromQuirk(Pawn pawn, float x)
|
||||
{
|
||||
if(pawn.GetQuirks() != null)
|
||||
pawn.GetQuirks().ApplyValueModifiers("reduceRest", ref x);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue