2020-04-09 00:43:01 +00:00
|
|
|
|
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) {
|
|
|
|
|
|
2020-04-19 01:52:59 +00:00
|
|
|
|
/*
|
|
|
|
|
These particular jobs need special code
|
|
|
|
|
don't play anim for now
|
|
|
|
|
*/
|
|
|
|
|
if(__instance is JobDriver_Masturbate_Bed || __instance is JobDriver_Masturbate_Quick || __instance is JobDriver_ViolateCorpse) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-09 00:43:01 +00:00
|
|
|
|
if(__instance is JobDriver_JoinInBed) {
|
2020-07-18 17:47:23 +00:00
|
|
|
|
Log.Warning("Playing regular RJW joininbed jobdriver, if it animates properly ignore this warning");
|
2020-04-09 00:43:01 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
2020-04-19 01:52:59 +00:00
|
|
|
|
else if (__instance is JobDriver_SexCasualForAnimation) {
|
2020-04-09 00:43:01 +00:00
|
|
|
|
bed = (__instance as JobDriver_SexCasualForAnimation).Bed;
|
|
|
|
|
}
|
2020-04-19 01:52:59 +00:00
|
|
|
|
else if (__instance is JobDriver_Masturbate_Bed)
|
|
|
|
|
bed = (__instance as JobDriver_Masturbate_Bed).Bed;
|
2020-04-26 15:03:57 +00:00
|
|
|
|
else if (__instance is JobDriver_Rape)
|
|
|
|
|
bed = (__instance?.Partner?.jobs?.curDriver as JobDriver_Sex)?.Bed;
|
2020-04-19 01:52:59 +00:00
|
|
|
|
|
|
|
|
|
if ((__instance.Target as Pawn)?.jobs?.curDriver is JobDriver_SexBaseReciever) {
|
2020-04-09 00:43:01 +00:00
|
|
|
|
|
2020-04-19 01:52:59 +00:00
|
|
|
|
Pawn Target = __instance.Target as Pawn;
|
2020-04-09 00:43:01 +00:00
|
|
|
|
|
|
|
|
|
if (!(Target.jobs.curDriver as JobDriver_SexBaseReciever).parteners.Contains(pawn)) {
|
|
|
|
|
(Target.jobs.curDriver as JobDriver_SexBaseReciever).parteners.Add(pawn);
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-05 20:31:42 +00:00
|
|
|
|
bool quickie = (__instance is JobDriver_SexQuick) && AnimationSettings.fastAnimForQuickie;
|
|
|
|
|
|
2020-04-09 00:43:01 +00:00
|
|
|
|
if (bed != null) {
|
2020-07-14 19:12:09 +00:00
|
|
|
|
RerollAnimations(Target, __instance.duration, bed as Thing, __instance.sexType, quickie, sexProps: __instance.Sexprops);
|
2020-04-09 00:43:01 +00:00
|
|
|
|
}
|
|
|
|
|
else {
|
2020-07-14 19:12:09 +00:00
|
|
|
|
RerollAnimations(Target, __instance.duration, sexType: __instance.sexType, fastAnimForQuickie: quickie, sexProps: __instance.Sexprops);
|
2020-04-09 00:43:01 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-14 19:12:09 +00:00
|
|
|
|
public static void RerollAnimations(Pawn pawn, int duration, Thing bed = null, xxx.rjwSextype sexType = xxx.rjwSextype.None, bool fastAnimForQuickie = false, rjw.SexProps sexProps = null) {
|
2020-04-09 00:43:01 +00:00
|
|
|
|
|
|
|
|
|
if(pawn == null || !(pawn.jobs?.curDriver is JobDriver_SexBaseReciever)) {
|
|
|
|
|
Log.Message("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();
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-14 19:12:09 +00:00
|
|
|
|
AnimationDef anim = AnimationUtility.tryFindAnimation(ref pawnsToAnimate, sexType, sexProps);
|
2020-04-09 00:43:01 +00:00
|
|
|
|
|
|
|
|
|
if (anim != null) {
|
|
|
|
|
|
|
|
|
|
bool mirror = GenTicks.TicksGame % 2 == 0;
|
2020-04-10 00:03:56 +00:00
|
|
|
|
|
2020-04-18 17:22:05 +00:00
|
|
|
|
Log.Message("Now playing " + anim.defName + (mirror ? " mirrored" : ""));
|
|
|
|
|
|
2020-04-10 00:03:56 +00:00
|
|
|
|
IntVec3 pos = pawn.Position;
|
|
|
|
|
|
2020-04-09 00:43:01 +00:00
|
|
|
|
for (int i = 0; i < pawnsToAnimate.Count; i++) {
|
|
|
|
|
|
|
|
|
|
if (bed != null)
|
|
|
|
|
pawnsToAnimate[i].TryGetComp<CompBodyAnimator>().setAnchor(bed);
|
2020-04-10 00:03:56 +00:00
|
|
|
|
else {
|
|
|
|
|
|
|
|
|
|
pawnsToAnimate[i].TryGetComp<CompBodyAnimator>().setAnchor(pos);
|
|
|
|
|
}
|
2020-04-09 00:43:01 +00:00
|
|
|
|
|
2020-04-21 04:59:09 +00:00
|
|
|
|
bool shiver = pawnsToAnimate[i].jobs.curDriver is JobDriver_SexBaseRecieverRaped;
|
2020-05-05 20:31:42 +00:00
|
|
|
|
pawnsToAnimate[i].TryGetComp<CompBodyAnimator>().StartAnimation(anim, i, mirror, shiver, fastAnimForQuickie);
|
2020-04-09 00:43:01 +00:00
|
|
|
|
(pawnsToAnimate[i].jobs.curDriver as JobDriver_Sex).ticks_left = anim.animationTimeTicks;
|
|
|
|
|
(pawnsToAnimate[i].jobs.curDriver as JobDriver_Sex).ticksLeftThisToil = anim.animationTimeTicks;
|
|
|
|
|
(pawnsToAnimate[i].jobs.curDriver as JobDriver_Sex).duration = anim.animationTimeTicks;
|
|
|
|
|
(pawnsToAnimate[i].jobs.curDriver as JobDriver_Sex).ticks_remaining = anim.animationTimeTicks;
|
2020-04-22 19:35:03 +00:00
|
|
|
|
if(!AnimationSettings.hearts) {
|
|
|
|
|
(pawnsToAnimate[i].jobs.curDriver as JobDriver_Sex).ticks_between_hearts = Int32.MaxValue;
|
|
|
|
|
}
|
2020-04-09 00:43:01 +00:00
|
|
|
|
|
2020-05-05 20:31:42 +00:00
|
|
|
|
}
|
2020-04-09 00:43:01 +00:00
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
Log.Message("Anim not 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) {
|
|
|
|
|
|
2020-04-18 15:24:09 +00:00
|
|
|
|
if ((__instance.Target as Pawn)?.jobs?.curDriver is JobDriver_SexBaseReciever) {
|
2020-04-09 00:43:01 +00:00
|
|
|
|
if (__instance.pawn.TryGetComp<CompBodyAnimator>().isAnimating) {
|
|
|
|
|
|
2020-04-18 15:24:09 +00:00
|
|
|
|
List<Pawn> parteners = ((__instance.Target as Pawn)?.jobs.curDriver as JobDriver_SexBaseReciever).parteners;
|
2020-04-09 00:43:01 +00:00
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
2020-04-18 15:24:09 +00:00
|
|
|
|
if (xxx.is_human((__instance.Target as Pawn))) {
|
|
|
|
|
(__instance.Target as Pawn)?.Drawer.renderer.graphics.ResolveApparelGraphics();
|
|
|
|
|
PortraitsCache.SetDirty((__instance.Target as Pawn));
|
2020-04-09 00:43:01 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-18 15:24:09 +00:00
|
|
|
|
((__instance.Target as Pawn)?.jobs.curDriver as JobDriver_SexBaseReciever).parteners.Remove(__instance.pawn);
|
2020-04-09 00:43:01 +00:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (xxx.is_human(__instance.pawn)) {
|
|
|
|
|
__instance.pawn.Drawer.renderer.graphics.ResolveApparelGraphics();
|
|
|
|
|
PortraitsCache.SetDirty(__instance.pawn);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|