Changed from rerouting the job to another for joininbed to simply patching joininbed, code tidying

This commit is contained in:
c0ffee 2021-07-24 13:52:33 -07:00
parent 8177b95bc8
commit 702964a8c2
24 changed files with 143 additions and 774 deletions

View File

@ -1,17 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Defs>
<JobDef>
<defName>JoinInBedAnimation</defName>
<driverClass>Rimworld_Animations.JobDriver_SexCasualForAnimation</driverClass>
<reportString>joining someone in bed.</reportString>
<casualInterruptible>false</casualInterruptible>
</JobDef>
<JobDef>
<defName>GettinLovedAnimation</defName>
<driverClass>Rimworld_Animations.JobDriver_SexBaseRecieverLovedForAnimation</driverClass>
<reportString>lovin'.</reportString>
<casualInterruptible>false</casualInterruptible>
</JobDef>
</Defs>

View File

@ -82,31 +82,27 @@
<Compile Include="Source\Comps\CompProperties_ThingAnimator.cs" />
<Compile Include="Source\Comps\CompThingAnimator.cs" />
<Compile Include="Source\Defs\AnimationDef.cs" />
<Compile Include="Source\JobDrivers\JobDriver_SexBaseRecieverLovedForAnimation.cs" />
<Compile Include="Source\JobDrivers\JobDriver_SexCasualForAnimation.cs" />
<Compile Include="Source\MainTabWindows\WorldComponent_UpdateMainTab.cs" />
<Compile Include="Source\MainTabWindows\MainTabWindow_OffsetConfigure.cs" />
<Compile Include="Source\MainTabWindows\OffsetMainButtonDefOf.cs" />
<Compile Include="Source\Patches\HarmonyPatch_AlienRace.cs" />
<Compile Include="Source\Patches\HarmonyPatch_CSL.cs" />
<Compile Include="Source\Patches\HarmonyPatch_DontShaveYourHead.cs" />
<Compile Include="Source\Patches\HarmonyPatch_FacialAnimation.cs" />
<Compile Include="Source\Patches\HarmonyPatch_HatsDisplaySelection.cs" />
<Compile Include="Source\Patches\HarmonyPatch_HeadHair.cs" />
<Compile Include="Source\Patches\HarmonyPatch_PawnRenderer.cs" />
<Compile Include="Source\Patches\HarmonyPatch_PawnRotation.cs" />
<Compile Include="Source\Patches\HarmonyPatch_Pawn_DrawTracker.cs" />
<Compile Include="Source\Patches\HarmonyPatch_SetPawnAnimatable.cs" />
<Compile Include="Source\Patches\HarmonyPatch_ShowHairWithHats.cs" />
<Compile Include="Source\Patches\OtherModPatches\HarmonyPatch_AlienRace.cs" />
<Compile Include="Source\Patches\OtherModPatches\HarmonyPatch_CSL.cs" />
<Compile Include="Source\Patches\OtherModPatches\HarmonyPatch_DontShaveYourHead.cs" />
<Compile Include="Source\Patches\OtherModPatches\HarmonyPatch_FacialAnimation.cs" />
<Compile Include="Source\Patches\OtherModPatches\HarmonyPatch_HatsDisplaySelection.cs" />
<Compile Include="Source\Patches\RimworldPatches\HarmonyPatch_HeadHair.cs" />
<Compile Include="Source\Patches\RimworldPatches\HarmonyPatch_PawnRenderer.cs" />
<Compile Include="Source\Patches\RimworldPatches\HarmonyPatch_PawnRotation.cs" />
<Compile Include="Source\Patches\RimworldPatches\HarmonyPatch_Pawn_DrawTracker.cs" />
<Compile Include="Source\Patches\RimworldPatches\HarmonyPatch_SetPawnAnimatable.cs" />
<Compile Include="Source\Patches\OtherModPatches\HarmonyPatch_ShowHairWithHats.cs" />
<Compile Include="Source\Patches\Harmony_PatchAll.cs" />
<Compile Include="Source\Patches\rjwPatches\HarmonyPatch_DoLovinAnimationPatch.cs" />
<Compile Include="Source\Patches\rjwPatches\HarmonyPatch_DrawSemen.cs" />
<Compile Include="Source\Patches\rjwPatches\HarmonyPatch_JobDriver_SexBaseInitiator.cs" />
<Compile Include="Source\Patches\rjwPatches\HarmonyPatch_JoinInBedGiveJob.cs" />
<Compile Include="Source\Patches\rjwPatches\HarmonyPatch_PlayAnimJoinInBedRMB.cs" />
<Compile Include="Source\Patches\rjwPatches\HarmonyPatch_PlaySexSounds.cs" />
<Compile Include="Source\Patches\rjwPatches\HarmonyPatch_SexTick.cs" />
<Compile Include="Source\Patches\rjwPatches\HarmonyPatch_WorkGiverSex.cs" />
<Compile Include="Source\Patches\RJWPatches\JobDrivers\HarmonyPatch_JobDriver_JoinInBed.cs" />
<Compile Include="Source\Patches\RJWPatches\JobDrivers\HarmonyPatch_JobDriver_SexBaseInitiator.cs" />
<Compile Include="Source\Patches\RJWPatches\HarmonyPatch_PlaySexSounds.cs" />
<Compile Include="Source\Patches\RJWPatches\HarmonyPatch_SexTick.cs" />
<Compile Include="Source\Patches\RJWPatches\HarmonyPatch_WorkGiverSex.cs" />
<Compile Include="Source\Patches\RJWPatches\JobDrivers\HarmonyPatch_JobDriver_SexBaseReceiverLoved.cs" />
<Compile Include="Source\Settings\AnimationSettings.cs" />
</ItemGroup>
<ItemGroup>
@ -120,13 +116,14 @@
<Content Include="Defs\AnimationDefs\Animations_Multi.xml" />
<Content Include="Defs\AnimationDefs\Animations_vanilla.xml" />
<Content Include="Defs\AnimationDefs\Animations_Vanilla2.xml" />
<Content Include="Defs\JobDefs\Jobs_SexForAnim.xml" />
<Content Include="Defs\MainTabDefs\MainButtonDef.xml" />
<Content Include="Defs\SoundDefs\Sounds_Sex.xml" />
<Content Include="LoadFolders.xml" />
</ItemGroup>
<ItemGroup>
<Folder Include="1.3\Assemblies\" />
<Folder Include="Defs\JobDefs\" />
<Folder Include="Source\JobDrivers\" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View File

@ -1,89 +0,0 @@
using System.Collections.Generic;
using RimWorld;
using Verse;
using Verse.AI;
using System;
using rjw;
namespace Rimworld_Animations {
public class JobDriver_SexBaseRecieverLovedForAnimation : JobDriver_SexBaseReciever {
public readonly TargetIndex ipartner = TargetIndex.A;
public readonly TargetIndex ibed = TargetIndex.B;
public override bool TryMakePreToilReservations(bool errorOnFailed) {
return base.TryMakePreToilReservations(errorOnFailed);
}
protected override IEnumerable<Toil> MakeNewToils() {
setup_ticks();
float partner_ability = xxx.get_sex_ability(Partner);
// More/less hearts based on partner ability.
if (partner_ability < 0.8f)
ticks_between_thrusts += 100;
else if (partner_ability > 2.0f)
ticks_between_thrusts -= 25;
// More/less hearts based on opinion.
if (pawn.relations.OpinionOf(Partner) < 0)
ticks_between_hearts += 50;
else if (pawn.relations.OpinionOf(Partner) > 60)
ticks_between_hearts -= 25;
parteners.Add(Partner);// add job starter, so this wont fail, before Initiator starts his job
//--Log.Message("[RJW]JobDriver_GettinLoved::MakeNewToils is called");
this.FailOnDespawnedOrNull(ipartner);
this.FailOn(() => !Partner.health.capacities.CanBeAwake);
this.FailOn(() => pawn.Drafted);
this.KeepLyingDown(ibed);
yield return Toils_Reserve.Reserve(ipartner, 1, 0);
yield return Toils_Reserve.Reserve(ibed, Bed.SleepingSlotsCount, 0);
Toil get_loved = new Toil();
get_loved.FailOn(() => {
for (int i = 0; i < parteners.Count; i++)
{
if (parteners[i].CurJobDef != DefDatabase<JobDef>.GetNamed("JoinInBedAnimation", true))
{
return true;
}
}
return false;
});
get_loved.defaultCompleteMode = ToilCompleteMode.Never;
get_loved.socialMode = RandomSocialMode.Off;
get_loved.handlingFacing = true;
get_loved.AddPreTickAction(delegate {
if (pawn.IsHashIntervalTick(ticks_between_hearts))
FleckMaker.ThrowMetaIcon(pawn.Position, pawn.Map, FleckDefOf.Heart);
});
get_loved.AddEndCondition(() =>
{
if (parteners.Count <= 0)
{
return JobCondition.Succeeded;
}
return JobCondition.Ongoing;
});
get_loved.AddFinishAction(delegate {
if (xxx.is_human(pawn))
pawn.Drawer.renderer.graphics.ResolveApparelGraphics();
});
yield return get_loved;
}
}
}

View File

@ -1,93 +0,0 @@
using RimWorld;
using rjw;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Verse;
using Verse.AI;
namespace Rimworld_Animations {
class JobDriver_SexCasualForAnimation : JobDriver_SexBaseInitiator {
public readonly TargetIndex ipartner = TargetIndex.A;
public readonly TargetIndex ibed = TargetIndex.B;
public override bool TryMakePreToilReservations(bool errorOnFailed) {
return pawn.Reserve(Target, job, xxx.max_rapists_per_prisoner, 0, null, errorOnFailed);
}
protected override IEnumerable<Toil> MakeNewToils() {
setup_ticks();
this.FailOnDespawnedOrNull(ipartner);
this.FailOnDespawnedOrNull(ibed);
this.FailOn(() => !Partner.health.capacities.CanBeAwake);
yield return Toils_Reserve.Reserve(ipartner, xxx.max_rapists_per_prisoner, 0, null);
Toil goToPawnInBed = Toils_Goto.GotoThing(ipartner, PathEndMode.OnCell);
goToPawnInBed.FailOn(() => !RestUtility.InBed(Partner) && Partner.CurJobDef != DefDatabase<JobDef>.GetNamed("GettinLovedAnimation") && !xxx.in_same_bed(Partner, pawn));
yield return goToPawnInBed;
Toil startPartnerSex = new Toil();
startPartnerSex.initAction = delegate {
if(Partner.CurJobDef != DefDatabase<JobDef>.GetNamed("GettinLovedAnimation")) // allows threesomes
{
Job gettinLovedJob = JobMaker.MakeJob(DefDatabase<JobDef>.GetNamed("GettinLovedAnimation"), pawn, Bed); // new gettin loved toil that wakes up the pawn goes here
Partner.jobs.jobQueue.EnqueueFirst(gettinLovedJob);
Partner.jobs.EndCurrentJob(JobCondition.InterruptForced);
}
};
yield return startPartnerSex;
Toil sexToil = new Toil();
sexToil.FailOn(() => (Partner.CurJobDef == null) || Partner.CurJobDef != DefDatabase<JobDef>.GetNamed("GettinLovedAnimation", true)); //partner jobdriver is not sexbaserecieverlovedforanim
sexToil.socialMode = RandomSocialMode.Off;
sexToil.defaultCompleteMode = ToilCompleteMode.Never;
sexToil.handlingFacing = true;
sexToil.initAction = delegate {
usedCondom = (CondomUtility.TryUseCondom(base.pawn) || CondomUtility.TryUseCondom(Partner));
Start();
};
sexToil.AddPreTickAction(delegate {
if(!Partner.TryGetComp<CompBodyAnimator>().isAnimating)
{
pawn.TryGetComp<CompBodyAnimator>().isAnimating = false;
}
if(Gen.IsHashIntervalTick(pawn, ticks_between_hearts)) {
FleckMaker.ThrowMetaIcon(pawn.Position, pawn.Map, FleckDefOf.Heart);
}
SexTick(pawn, Partner);
SexUtility.reduce_rest(Partner);
SexUtility.reduce_rest(pawn, 2);
if (ticks_left <= 0)
ReadyForNextToil();
});
sexToil.AddFinishAction(delegate {
End();
});
yield return sexToil;
Toil finish = new Toil();
finish.initAction = delegate {
SexUtility.ProcessSex(pawn, Partner, usedCondom, isRape, isCoreLovin: false, isWhoring, sexType);
};
finish.defaultCompleteMode = ToilCompleteMode.Instant;
yield return finish;
}
}
}

View File

@ -1,92 +0,0 @@
using HarmonyLib;
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;
using AlienRace;
namespace Rimworld_Animations {
[HarmonyPatch(typeof(AlienRace.HarmonyPatches), "DrawAddons")]
public static class HarmonyPatch_AlienRace {
public static void RenderHeadAddonInAnimation(Mesh mesh, Vector3 loc, Quaternion quat, Material mat, bool drawNow, Graphic graphic, AlienPartGenerator.BodyAddon bodyAddon, Vector3 v, float num, Vector3 headOffset, Pawn pawn, PawnRenderFlags renderFlags)
{
CompBodyAnimator pawnAnimator = pawn.TryGetComp<CompBodyAnimator>();
if (!renderFlags.FlagSet(PawnRenderFlags.Portrait) && pawnAnimator.isAnimating && (bodyAddon.drawnInBed || bodyAddon.alignWithHead))
{
Quaternion headQuatInAnimation = Quaternion.AngleAxis(pawnAnimator.headAngle, Vector3.up);
Rot4 headRotInAnimation = pawnAnimator.headFacing;
Vector3 headPositionInAnimation = pawnAnimator.getPawnHeadPosition() - pawn.Drawer.renderer.BaseHeadOffsetAt(pawnAnimator.headFacing).RotatedBy(angle: Mathf.Acos(f: Quaternion.Dot(a: Quaternion.identity, b: headQuatInAnimation)) * 2f * 57.29578f);
Log.Message(bodyAddon.path + " " + bodyAddon.inFrontOfBody.ToStringSafe());
headPositionInAnimation.y += bodyAddon.inFrontOfBody ? 1f : -1f;
GenDraw.DrawMeshNowOrLater(mesh: graphic.MeshAt(rot: headRotInAnimation), loc: headPositionInAnimation + (bodyAddon.alignWithHead ? headOffset : Vector3.zero) + v.RotatedBy(angle: Mathf.Acos(f: Quaternion.Dot(a: Quaternion.identity, b: headQuatInAnimation)) * 2f * 57.29578f),
quat: Quaternion.AngleAxis(angle: num, axis: Vector3.up) * headQuatInAnimation, mat: graphic.MatAt(rot: pawnAnimator.headFacing), drawNow: drawNow);
}
else
{
GenDraw.DrawMeshNowOrLater(mesh, loc, quat, mat, drawNow);
}
}
public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
{
List<CodeInstruction> ins = instructions.ToList();
for (int i = 0; i < ins.Count; i++)
{
Type[] type = new Type[] { typeof(Mesh), typeof(Vector3), typeof(Quaternion), typeof(Material), typeof(bool) };
if (ins[i].OperandIs(AccessTools.Method(typeof(GenDraw), "DrawMeshNowOrLater", type)))
{
yield return new CodeInstruction(OpCodes.Ldloc, (object)7); //graphic
yield return new CodeInstruction(OpCodes.Ldloc, (object)4); //bodyAddon
yield return new CodeInstruction(OpCodes.Ldloc, (object)5); //offsetVector/AddonOffset (v)
yield return new CodeInstruction(OpCodes.Ldloc, (object)6); //num
yield return new CodeInstruction(OpCodes.Ldarg, (object)2); //headOffset
yield return new CodeInstruction(OpCodes.Ldarg, (object)3); //pawn
yield return new CodeInstruction(OpCodes.Ldarg, (object)0); //renderflags
yield return new CodeInstruction(OpCodes.Call, AccessTools.DeclaredMethod(typeof(HarmonyPatch_AlienRace), "RenderHeadAddonInAnimation"));
}
else
{
yield return ins[i];
}
}
}
}
[HarmonyPatch(typeof(PawnGraphicSet), "ResolveApparelGraphics")]
public static class HarmonyPatch_ResolveApparelGraphics
{
public static bool Prefix(ref Pawn ___pawn)
{
if (___pawn.TryGetComp<CompBodyAnimator>() != null && ___pawn.TryGetComp<CompBodyAnimator>().isAnimating)
{
return false;
}
return true;
}
}
}

View File

@ -1,87 +0,0 @@
/*
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using HarmonyLib;
using rjw;
using Verse;
using RimWorld;
using System.Reflection.Emit;
using System.Reflection;
using UnityEngine;
namespace Rimworld_Animations {
[StaticConstructorOnStartup]
public static class HarmonyPatch_CSL {
static HarmonyPatch_CSL() {
try {
((Action)(() => {
if (LoadedModManager.RunningModsListForReading.Any(x => x.Name == "Children, school and learning")) {
(new Harmony("rjw")).Patch(AccessTools.Method(AccessTools.TypeByName("Children.PawnRenderer_RenderPawnInternal_Patch"), "RenderPawnInternalScaled"),
prefix: new HarmonyMethod(AccessTools.Method(typeof(HarmonyPatch_CSL), "Prefix_CSL")),
transpiler: new HarmonyMethod(AccessTools.Method(typeof(HarmonyPatch_CSL), "Transpiler_CSL")));
}
}))();
}
catch (TypeLoadException ex) {
}
}
public static void Prefix_CSL(PawnRenderer __instance, Pawn pawn, ref Vector3 rootLoc, ref float angle, bool renderBody, ref Rot4 bodyFacing, ref Rot4 headFacing, RotDrawMode bodyDrawType, bool portrait, bool headStump, bool invisible) {
PawnGraphicSet graphics = __instance.graphics;
CompBodyAnimator bodyAnim = pawn.TryGetComp<CompBodyAnimator>();
if (!graphics.AllResolved) {
graphics.ResolveAllGraphics();
}
if (bodyAnim != null && bodyAnim.isAnimating && !portrait) {
bodyAnim.tickGraphics(graphics);
pawn.TryGetComp<CompBodyAnimator>().animatePawn(ref rootLoc, ref angle, ref bodyFacing, ref headFacing);
}
}
public static IEnumerable<CodeInstruction> Transpiler_CSL(IEnumerable<CodeInstruction> instructions) {
MethodInfo drawMeshNowOrLater = AccessTools.Method(typeof(GenDraw), "DrawMeshNowOrLater");
FieldInfo headGraphic = AccessTools.Field(typeof(PawnGraphicSet), "headGraphic");
List<CodeInstruction> codes = instructions.ToList();
bool forHead = true;
for (int i = 0; i < codes.Count(); i++) {
//Instead of calling drawmeshnoworlater, add pawn to the stack and call my special static method
if (codes[i].OperandIs(drawMeshNowOrLater) && forHead) {
yield return new CodeInstruction(OpCodes.Ldarg_0);
yield return new CodeInstruction(OpCodes.Ldfld, AccessTools.DeclaredField(typeof(PawnRenderer), "pawn"));
yield return new CodeInstruction(OpCodes.Ldarg_2);
yield return new CodeInstruction(OpCodes.Call, AccessTools.DeclaredMethod(typeof(AnimationUtility), nameof(AnimationUtility.RenderPawnHeadMeshInAnimation), new Type[] { typeof(Mesh), typeof(Vector3), typeof(Quaternion), typeof(Material), typeof(bool), typeof(Pawn), typeof(float) }));
}
//checking for if(graphics.headGraphic != null)
else if (codes[i].opcode == OpCodes.Ldfld && codes[i].OperandIs(headGraphic)) {
forHead = true;
yield return codes[i];
}
//checking for if(renderbody)
else if (codes[i].opcode == OpCodes.Ldarg_3) {
forHead = false;
yield return codes[i];
}
else {
yield return codes[i];
}
}
}
}
}*/

View File

@ -1,29 +0,0 @@
using HarmonyLib;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Verse;
namespace Rimworld_Animations {
class HarmonyPatch_DontShaveYourHead {
[StaticConstructorOnStartup]
public static class Patch_DontShaveYourHead {
static Patch_DontShaveYourHead() {
try {
((Action)(() =>
{
if (LoadedModManager.RunningModsListForReading.Any(x => x.Name == "Don't Shave Your Head 1.0")) {
(new Harmony("rjw")).Patch(AccessTools.Method(AccessTools.TypeByName("DontShaveYourHead.Harmony_PawnRenderer"), "DrawHairReroute"), //typeof(ShowHair.Patch_PawnRenderer_RenderPawnInternal), nameof(ShowHair.Patch_PawnRenderer_RenderPawnInternal.Postfix)),
transpiler: new HarmonyMethod(AccessTools.Method(typeof(Patch_ShowHairWithHats), "Transpiler")));
}
}))();
}
catch (TypeLoadException ex) { }
}
}
}
}

View File

@ -1,104 +0,0 @@
using HarmonyLib;
using RimWorld;
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 Rimworld_Animations {
[StaticConstructorOnStartup]
public static class Patch_FacialAnimation {
static Patch_FacialAnimation() {
try {
((Action)(() => {
if (LoadedModManager.RunningModsListForReading.Any(x => x.Name == "[NL] Facial Animation - WIP")) {
(new Harmony("rjw")).Patch(AccessTools.Method(AccessTools.TypeByName("FacialAnimation.DrawFaceGraphicsComp"), "DrawGraphics"),
prefix: new HarmonyMethod(AccessTools.Method(typeof(Patch_FacialAnimation), "Prefix")));
}
}))();
}
catch (TypeLoadException ex) {
}
}
public static bool Prefix(ref Pawn ___pawn, ref Rot4 headFacing, ref Vector3 headOrigin, ref Quaternion quaternion, ref bool portrait) {
CompBodyAnimator bodyAnim = ___pawn.TryGetComp<CompBodyAnimator>();
if (bodyAnim != null && bodyAnim.isAnimating && !portrait) {
headFacing = bodyAnim.headFacing;
headOrigin = new Vector3(bodyAnim.getPawnHeadPosition().x, headOrigin.y, bodyAnim.getPawnHeadPosition().z);
quaternion = Quaternion.AngleAxis(bodyAnim.headAngle, Vector3.up);
}
return true;
}
/*
public static List<string> rjwLovinDefNames = new List<string>{
"Lovin",
"Quickie",
"GettingQuickie",
"JoinInBed",
"JoinInBedAnimation",
"GettinLovedAnimation",
"GettinLoved",
"GettinLicked",
"GettinSucked",
"GettinRaped",
"ViolateCorpse",
"RJW_Masturbate",
"GettinBred",
"Breed",
"RJW_Mate",
"Bestiality",
"BestialityForFemale",
"StruggleInBondageGear",
"WhoreIsServingVisitors",
"UseFM"
};
public static List<string> rjwRapeDefNames = new List<string> {
"RapeComfortPawn",
"RandomRape",
"RapeEnemy"
};
public static bool Prefix_IsSameA(JobDef job, string ___jobDef, ref bool __result) {
if(___jobDef != null && ___jobDef == "Lovin" && job?.defName != null && rjwLovinDefNames.Contains(job?.defName)) {
__result = true;
return false;
}
else if (___jobDef != null && ___jobDef == "Wait_Combat" && job?.defName != null && rjwRapeDefNames.Contains(job?.defName)) {
__result = true;
return false;
}
return true;
}
public static bool Prefix_IsSameB(string jobName, string ___jobDef, ref bool __result) {
if (___jobDef != null && ___jobDef == "Lovin" && jobName != null && rjwLovinDefNames.Contains(jobName)) {
__result = true;
return false;
}
if (___jobDef != null && ___jobDef == "Wait_Combat" && jobName != null && rjwRapeDefNames.Contains(jobName)) {
__result = true;
return false;
}
return true;
}
*/
}
}

View File

@ -1,28 +0,0 @@
using HarmonyLib;
using Verse;
using RimWorld;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Rimworld_Animations
{
[HarmonyPatch(typeof(PawnUtility), "GetPosture")]
public static class HarmonyPatch_SetPawnLaying
{
public static bool Prefix(Pawn p, ref PawnPosture __result)
{
if(p.TryGetComp<CompBodyAnimator>().isAnimating)
{
__result = PawnPosture.LayingOnGroundNormal;
return false;
}
return true;
}
}
}

View File

@ -1,51 +0,0 @@
using HarmonyLib;
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 Rimworld_Animations {
[StaticConstructorOnStartup]
public static class Patch_ShowHairWithHats {
static Patch_ShowHairWithHats() {
try {
((Action)(() =>
{
if (LoadedModManager.RunningModsListForReading.Any(x => x.Name == "[KV] Show Hair With Hats or Hide All Hats - 1.1")) {
(new Harmony("rjw")).Patch(AccessTools.Method(AccessTools.TypeByName("ShowHair.Patch_PawnRenderer_RenderPawnInternal"), "Postfix"), //typeof(ShowHair.Patch_PawnRenderer_RenderPawnInternal), nameof(ShowHair.Patch_PawnRenderer_RenderPawnInternal.Postfix)),
transpiler: new HarmonyMethod(AccessTools.Method(typeof(Patch_ShowHairWithHats), "Transpiler")));
}
}))();
}
catch (TypeLoadException ex) { }
}
public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) {
MethodInfo drawMeshNowOrLater = AccessTools.Method(typeof(GenDraw), "DrawMeshNowOrLater");
List<CodeInstruction> codes = instructions.ToList();
for (int i = 0; i < codes.Count(); i++) {
//Instead of calling drawmeshnoworlater, add pawn to the stack and call my special static method
if (codes[i].OperandIs(drawMeshNowOrLater)) {
yield return new CodeInstruction(OpCodes.Ldarg_0);
yield return new CodeInstruction(OpCodes.Ldfld, AccessTools.DeclaredField(typeof(PawnRenderer), "pawn"));
yield return new CodeInstruction(OpCodes.Call, AccessTools.DeclaredMethod(typeof(AnimationUtility), nameof(AnimationUtility.RenderPawnHeadMeshInAnimation), new Type[] { typeof(Mesh), typeof(Vector3), typeof(Quaternion), typeof(Material), typeof(bool), typeof(Pawn) }));
}
else {
yield return codes[i];
}
}
}
}
}

View File

@ -0,0 +1,84 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using HarmonyLib;
using RimWorld;
using Verse;
using rjw;
using System.Reflection.Emit;
using Verse.AI;
namespace Rimworld_Animations
{
[HarmonyPatch(typeof(xxx), "in_same_bed")]
public static class HarmonyPatch_JobDriver_InSameBedPatch
{
public static bool Prefix(Pawn partner, ref bool __result)
{
if(partner != null && partner.CurJobDef == xxx.casual_sex)
{
__result = true;
return false;
}
return true;
}
}
[HarmonyPatch(typeof(JobDriver_JoinInBed), "MakeNewToils")]
public static class HarmonyPatch_JobDriver_JoinInBed
{
public static void Postfix(JobDriver_JoinInBed __instance, ref IEnumerable<Toil> __result)
{
var toils = __result.ToList();
Toil goToPawnInBed = Toils_Goto.GotoThing(__instance.iTarget, PathEndMode.OnCell);
goToPawnInBed.FailOn(() => !RestUtility.InBed(__instance.Partner) && __instance.Partner.CurJobDef != xxx.gettin_loved && !xxx.in_same_bed(__instance.Partner, __instance.pawn));
toils[1] = goToPawnInBed;
Toil startPartnerSex = new Toil();
startPartnerSex.initAction = delegate {
if (!(__instance.Partner.jobs.curDriver is JobDriver_SexBaseReciever)) // allows threesomes
{
Job gettinLovedJob = JobMaker.MakeJob(xxx.gettin_loved, __instance.pawn, __instance.Bed); // new gettin loved toil that wakes up the pawn goes here
__instance.Partner.jobs.jobQueue.EnqueueFirst(gettinLovedJob);
__instance.Partner.jobs.EndCurrentJob(JobCondition.InterruptForced);
}
};
toils[2] = startPartnerSex;
toils[3].AddPreTickAction(() =>
{
if (!__instance.Partner.TryGetComp<CompBodyAnimator>().isAnimating)
{
__instance.pawn.TryGetComp<CompBodyAnimator>().isAnimating = false;
}
});
__result = toils.AsEnumerable();
}
}
}

View File

@ -25,30 +25,10 @@ namespace Rimworld_Animations {
Building_Bed bed = __instance.Bed;
/*
if (__instance is JobDriver_BestialityForFemale)
bed = (__instance as JobDriver_BestialityForFemale).Bed;
else if (__instance is JobDriver_WhoreIsServingVisitors) {
bed = (__instance as JobDriver_WhoreIsServingVisitors).Bed;
}
else if (__instance is JobDriver_SexCasualForAnimation) {
bed = (__instance as JobDriver_SexCasualForAnimation).Bed;
}
else if (__instance is JobDriver_Masturbate)
bed = (__instance as JobDriver_Masturbate).Bed;
else if (__instance is JobDriver_Rape)
bed = (__instance?.Partner?.jobs?.curDriver as JobDriver_Sex)?.Bed;
*/
if ((__instance.Target as Pawn)?.jobs?.curDriver is JobDriver_SexBaseReciever) {
Pawn Target = __instance.Target as Pawn;
if (!(Target.jobs.curDriver as JobDriver_SexBaseReciever).parteners.Contains(pawn)) {
(Target.jobs.curDriver as JobDriver_SexBaseReciever).parteners.Add(pawn);
}
bool quickie = (__instance is JobDriver_SexQuick) && AnimationSettings.fastAnimForQuickie;
int preAnimDuration = __instance.duration;

View File

@ -0,0 +1,40 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using HarmonyLib;
using RimWorld;
using Verse;
using rjw;
using System.Reflection.Emit;
namespace Rimworld_Animations
{
[HarmonyPatch(typeof(JobDriver_SexBaseRecieverLoved), "MakeSexToil")]
public static class HarmonyPatch_JobDriver_SexBaseReceiverLoved
{
public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> codeInstructions)
{
var ins = codeInstructions.ToList();
for(int i = 0; i < ins.Count; i++)
{
if(i + 13 < ins.Count && ins[i + 13].opcode == OpCodes.Call && ins[i + 13].OperandIs(AccessTools.DeclaredMethod(typeof(Toils_LayDown), "LayDown"))) {
ins.RemoveRange(i, 14);
}
else
{
yield return ins[i];
}
}
}
}
}

View File

@ -1,26 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using HarmonyLib;
using RimWorld;
using Verse;
using rjw;
using Verse.AI;
namespace Rimworld_Animations {
[HarmonyPatch(typeof(JobGiver_DoLovin), "TryGiveJob")]
public static class HarmonyPatch_DoLovinAnimationPatch {
public static void Postfix(ref Pawn pawn, ref Job __result) {
if(__result != null) {
Pawn partnerInMyBed = LovePartnerRelationUtility.GetPartnerInMyBed(pawn);
RestUtility.WakeUp(pawn);
__result = JobMaker.MakeJob(DefDatabase<JobDef>.GetNamed("JoinInBedAnimation", true), partnerInMyBed, partnerInMyBed.CurrentBed());
}
}
}
}

View File

@ -1,22 +0,0 @@
/*
* Todo: Ask to make SemenSplatch and DrawSemen public
*
*
* using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using rjw;
using HarmonyLib;
namespace Rimworld_Animations {
[HarmonyPatch("DrawSemen")]
public static class HarmonyPatch_DrawSemen {
public static void Prefix(ref Dictionary<string, SemenSplatch>) {
}
}
}*/

View File

@ -1,68 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using rjw;
using Verse;
using Verse.AI;
using RimWorld;
using HarmonyLib;
namespace Rimworld_Animations {
[HarmonyPatch(typeof(JobGiver_JoinInBed), "TryGiveJob")]
public static class HarmonyPatch_JoinInBedGiveJob {
public static bool Prefix(ref Job __result, ref Pawn pawn) {
__result = null;
if (!RJWHookupSettings.HookupsEnabled)
return false;
if (pawn.Drafted)
return false;
if (!SexUtility.ReadyForHookup(pawn))
return false;
// We increase the time right away to prevent the fairly expensive check from happening too frequently
SexUtility.IncreaseTicksToNextHookup(pawn);
// If the pawn is a whore, or recently had sex, skip the job unless they're really horny
if (!xxx.is_frustrated(pawn) && (xxx.is_whore(pawn) || !SexUtility.ReadyForLovin(pawn)))
return false;
// This check attempts to keep groups leaving the map, like guests or traders, from turning around to hook up
if (pawn.mindState?.duty?.def == DutyDefOf.TravelOrLeave) {
// TODO: Some guest pawns keep the TravelOrLeave duty the whole time, I think the ones assigned to guard the pack animals.
// That's probably ok, though it wasn't the intention.
if (RJWSettings.DebugLogJoinInBed) ModLog.Message($"JoinInBed.TryGiveJob:({xxx.get_pawnname(pawn)}): has TravelOrLeave, no time for lovin [ANIM JOBGIVER]!");
return false;
}
if ((pawn.CurJob == null || pawn.CurJob.def == JobDefOf.LayDown) && CasualSex_Helper.CanHaveSex(pawn)) {
//--Log.Message(" finding partner");
Pawn partner = CasualSex_Helper.find_partner(pawn, pawn.Map, bedsex: true);
//--Log.Message(" checking partner");
if (partner == null)
return false;
// Can never be null, since find checks for bed.
Building_Bed bed = partner.CurrentBed();
// Interrupt current job.
if (pawn.CurJob != null && pawn.jobs.curDriver != null)
pawn.jobs.curDriver.EndJobWith(JobCondition.InterruptForced);
__result = JobMaker.MakeJob(DefDatabase<JobDef>.GetNamed("JoinInBedAnimation", true), partner, bed);
return false;
}
return false;
}
}
}

View File

@ -1,26 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using RimWorld;
using Verse.AI;
using rjw;
using HarmonyLib;
using Verse;
namespace Rimworld_Animations {
[HarmonyPatch(typeof(Pawn_JobTracker), "TryTakeOrderedJob")]
class HarmonyPatch_PlayAnimJoinInBedRMB {
public static void Prefix(ref Job job) {
if(job.def == xxx.casual_sex) {
if (AnimationSettings.debugMode || RJWSettings.DevMode)
Log.Message("Replacing vanilla RJW JoinInBed JobDriver for animation JobDriver");
job = new Job(DefDatabase<JobDef>.GetNamed("JoinInBedAnimation", true), job.targetA, job.targetB, job.targetC);
}
}
}
}