mirror of
https://gitgud.io/c0ffeeeeeeee/rimworld-animations.git
synced 2024-08-15 00:43:45 +00:00
88 lines
2.5 KiB
C#
88 lines
2.5 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
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;
|
|
|
|
}
|
|
|
|
if(!AnimationSettings.PlayAnimForNonsexualActs && NonSexualAct(__instance))
|
|
{
|
|
return;
|
|
}
|
|
|
|
Pawn pawn = __instance.pawn;
|
|
Pawn partner = __instance.Target as Pawn;
|
|
Building_Bed bed = __instance.Bed;
|
|
|
|
if (partner?.jobs?.curDriver is JobDriver_SexBaseReciever partnerSexBaseReceiver) {
|
|
|
|
Pawn Target = __instance.Target as Pawn;
|
|
|
|
bool quickie = (__instance is JobDriver_SexQuick) && AnimationSettings.fastAnimForQuickie;
|
|
|
|
int preAnimDuration = __instance.duration;
|
|
|
|
|
|
List<Pawn> participants = partnerSexBaseReceiver.parteners.Append(partner).ToList();
|
|
|
|
GroupAnimationDef groupAnimation = AnimationUtility.FindGroupAnimation(participants, out int reorder);
|
|
if (groupAnimation != null)
|
|
{
|
|
AnimationUtility.StartGroupAnimation(participants, groupAnimation, reorder, partner);
|
|
int animTicks = AnimationUtility.GetAnimationLength(pawn);
|
|
|
|
foreach(Pawn participant in participants)
|
|
{
|
|
(participant.jobs.curDriver as JobDriver_Sex).ticks_left = animTicks;
|
|
(participant.jobs.curDriver as JobDriver_Sex).sex_ticks = animTicks;
|
|
(participant.jobs.curDriver as JobDriver_Sex).orgasmStartTick = animTicks;
|
|
(participant.jobs.curDriver as JobDriver_Sex).duration = animTicks;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
static IEnumerable<String> NonSexActRulePackDefNames = new String[]
|
|
{
|
|
"MutualHandholdingRP",
|
|
"MutualMakeoutRP",
|
|
};
|
|
|
|
public static bool NonSexualAct(JobDriver_SexBaseInitiator sexBaseInitiator)
|
|
{
|
|
if(NonSexActRulePackDefNames.Contains(sexBaseInitiator.Sexprops.rulePack))
|
|
{
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
[HarmonyPatch(typeof(JobDriver_SexBaseInitiator), "End")]
|
|
static class HarmonyPatch_JobDriver_SexBaseInitiator_End {
|
|
|
|
public static void Prefix(ref JobDriver_SexBaseInitiator __instance)
|
|
{
|
|
|
|
AnimationUtility.StopGroupAnimation(__instance.pawn);
|
|
}
|
|
}
|
|
}
|