mirror of
https://gitgud.io/c0ffeeeeeeee/rimworld-animations.git
synced 2024-08-15 00:43:45 +00:00
Changed from rerouting the job to another for joininbed to simply patching joininbed, code tidying
This commit is contained in:
parent
8177b95bc8
commit
702964a8c2
24 changed files with 143 additions and 774 deletions
|
@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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>) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}*/
|
|
@ -1,190 +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;
|
||||
|
||||
namespace Rimworld_Animations {
|
||||
|
||||
[HarmonyPatch(typeof(JobDriver_SexBaseInitiator), "Start")]
|
||||
static class HarmonyPatch_JobDriver_SexBaseInitiator_Start {
|
||||
public static void Postfix(ref JobDriver_SexBaseInitiator __instance) {
|
||||
/*
|
||||
These particular jobs need special code
|
||||
don't play anim for now
|
||||
*/
|
||||
if(__instance is JobDriver_Masturbate || __instance is JobDriver_ViolateCorpse) {
|
||||
return;
|
||||
}
|
||||
|
||||
Pawn pawn = __instance.pawn;
|
||||
|
||||
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;
|
||||
int AnimationTimeTicks = 0;
|
||||
|
||||
|
||||
if (bed != null) {
|
||||
RerollAnimations(Target, out AnimationTimeTicks, bed as Thing, __instance.sexType, quickie, sexProps: __instance.Sexprops);
|
||||
}
|
||||
else {
|
||||
RerollAnimations(Target, out AnimationTimeTicks, sexType: __instance.sexType, fastAnimForQuickie: quickie, sexProps: __instance.Sexprops);
|
||||
}
|
||||
|
||||
|
||||
//Modify Orgasm ticks to only orgasm as many times as RJW stock orgasm allows
|
||||
if(AnimationTimeTicks != 0)
|
||||
{
|
||||
__instance.orgasmstick = preAnimDuration * __instance.orgasmstick / AnimationTimeTicks;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static void RerollAnimations(Pawn pawn, out int AnimationTimeTicks, Thing bed = null, xxx.rjwSextype sexType = xxx.rjwSextype.None, bool fastAnimForQuickie = false, rjw.SexProps sexProps = null) {
|
||||
|
||||
AnimationTimeTicks = 0;
|
||||
|
||||
if(pawn == null || !(pawn.jobs?.curDriver is JobDriver_SexBaseReciever)) {
|
||||
Log.Error("Error: Tried to reroll animations when pawn isn't sexing");
|
||||
return;
|
||||
}
|
||||
|
||||
List<Pawn> pawnsToAnimate = (pawn.jobs.curDriver as JobDriver_SexBaseReciever).parteners.ToList();
|
||||
|
||||
if (!pawnsToAnimate.Contains(pawn)) {
|
||||
pawnsToAnimate = pawnsToAnimate.Append(pawn).ToList();
|
||||
}
|
||||
|
||||
for(int i = 0; i < pawnsToAnimate.Count; i++) {
|
||||
|
||||
if(pawnsToAnimate[i].TryGetComp<CompBodyAnimator>() == null) {
|
||||
Log.Error("Error: " + pawnsToAnimate[i].Name + " of race " + pawnsToAnimate[i].def.defName + " does not have CompBodyAnimator attached!");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
AnimationDef anim = AnimationUtility.tryFindAnimation(ref pawnsToAnimate, sexType, sexProps);
|
||||
|
||||
if (anim != null) {
|
||||
|
||||
bool mirror = GenTicks.TicksGame % 2 == 0;
|
||||
|
||||
IntVec3 pos = pawn.Position;
|
||||
|
||||
for (int i = 0; i < anim.actors.Count; i++)
|
||||
{
|
||||
pawnsToAnimate[i].TryGetComp<CompBodyAnimator>().isAnimating = false;
|
||||
}
|
||||
|
||||
for (int i = 0; i < pawnsToAnimate.Count; i++) {
|
||||
|
||||
if (bed != null)
|
||||
pawnsToAnimate[i].TryGetComp<CompBodyAnimator>().setAnchor(bed);
|
||||
else {
|
||||
|
||||
pawnsToAnimate[i].TryGetComp<CompBodyAnimator>().setAnchor(pos);
|
||||
}
|
||||
|
||||
bool shiver = pawnsToAnimate[i].jobs.curDriver is JobDriver_SexBaseRecieverRaped;
|
||||
pawnsToAnimate[i].TryGetComp<CompBodyAnimator>().StartAnimation(anim, pawnsToAnimate, i, mirror, shiver, fastAnimForQuickie);
|
||||
|
||||
int animTicks = anim.animationTimeTicks - (fastAnimForQuickie ? anim.animationStages[0].playTimeTicks : 0);
|
||||
(pawnsToAnimate[i].jobs.curDriver as JobDriver_Sex).ticks_left = animTicks;
|
||||
(pawnsToAnimate[i].jobs.curDriver as JobDriver_Sex).sex_ticks = animTicks;
|
||||
(pawnsToAnimate[i].jobs.curDriver as JobDriver_Sex).duration = animTicks;
|
||||
|
||||
|
||||
AnimationTimeTicks = animTicks;
|
||||
|
||||
if(!AnimationSettings.hearts) {
|
||||
(pawnsToAnimate[i].jobs.curDriver as JobDriver_Sex).ticks_between_hearts = Int32.MaxValue;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else {
|
||||
Log.Message("No animation found");
|
||||
|
||||
/*
|
||||
|
||||
//if pawn isn't already animating,
|
||||
if (!pawn.TryGetComp<CompBodyAnimator>().isAnimating) {
|
||||
(pawn.jobs.curDriver as JobDriver_SexBaseReciever).increase_time(duration);
|
||||
//they'll just do the thrusting anim
|
||||
}
|
||||
|
||||
*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(JobDriver_SexBaseInitiator), "End")]
|
||||
static class HarmonyPatch_JobDriver_SexBaseInitiator_End {
|
||||
|
||||
public static void Postfix(ref JobDriver_SexBaseInitiator __instance) {
|
||||
|
||||
if ((__instance.Target as Pawn)?.jobs?.curDriver is JobDriver_SexBaseReciever) {
|
||||
if (__instance.pawn.TryGetComp<CompBodyAnimator>().isAnimating) {
|
||||
|
||||
List<Pawn> parteners = ((__instance.Target as Pawn)?.jobs.curDriver as JobDriver_SexBaseReciever).parteners;
|
||||
|
||||
for (int i = 0; i < parteners.Count; i++) {
|
||||
|
||||
//prevents pawns who started a new anim from stopping their new anim
|
||||
if (!((parteners[i].jobs.curDriver as JobDriver_SexBaseInitiator) != null && (parteners[i].jobs.curDriver as JobDriver_SexBaseInitiator).Target != __instance.pawn))
|
||||
parteners[i].TryGetComp<CompBodyAnimator>().isAnimating = false;
|
||||
|
||||
}
|
||||
|
||||
__instance.Target.TryGetComp<CompBodyAnimator>().isAnimating = false;
|
||||
|
||||
if (xxx.is_human((__instance.Target as Pawn))) {
|
||||
(__instance.Target as Pawn)?.Drawer.renderer.graphics.ResolveApparelGraphics();
|
||||
PortraitsCache.SetDirty((__instance.Target as Pawn));
|
||||
}
|
||||
}
|
||||
|
||||
((__instance.Target as Pawn)?.jobs.curDriver as JobDriver_SexBaseReciever).parteners.Remove(__instance.pawn);
|
||||
|
||||
}
|
||||
|
||||
if (xxx.is_human(__instance.pawn)) {
|
||||
__instance.pawn.Drawer.renderer.graphics.ResolveApparelGraphics();
|
||||
PortraitsCache.SetDirty(__instance.pawn);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue