mirror of
https://gitgud.io/c0ffeeeeeeee/rimworld-animations.git
synced 2026-06-19 20:05:50 +00:00
66 lines
2 KiB
C#
66 lines
2 KiB
C#
using HarmonyLib;
|
|
using rjw;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using UnityEngine;
|
|
using Verse;
|
|
|
|
namespace Rimworld_Animations
|
|
{
|
|
|
|
[HarmonyPatch(typeof(JobDriver_Sex), "setup_ticks")]
|
|
public class HarmonyPatch_JobDriver_Sex
|
|
{
|
|
public static void Postfix(JobDriver_Sex __instance)
|
|
{
|
|
if (!RJWAnimationSettings.hearts)
|
|
{
|
|
__instance.ticks_between_hearts = int.MaxValue;
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
[HarmonyPatch(typeof(JobDriver_Sex), "SexTick")]
|
|
public class HarmonyPatch_JobDriver_Sex2
|
|
{
|
|
public static void Postfix(JobDriver_Sex __instance, Pawn pawn, Thing target)
|
|
{
|
|
//if neverending sex and pawn doesn't have an animation,
|
|
if (__instance.neverendingsex
|
|
&& !pawn.TryGetComp<CompExtendedAnimator>().IsAnimating)
|
|
{
|
|
|
|
//start a new animation for all the pawns paired with receiver job driver
|
|
List<Pawn> participants;
|
|
if (target is Pawn receiverPawn)
|
|
{
|
|
participants = (receiverPawn?.jobs?.curDriver as JobDriver_SexBaseReciever)?.parteners;
|
|
if (!participants.NullOrEmpty() && !participants.Contains(receiverPawn))
|
|
{
|
|
participants = participants.Append(receiverPawn).ToList();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
participants = new List<Pawn> { pawn };
|
|
}
|
|
|
|
|
|
GroupAnimationDef animation = AnimationUtility.FindGroupAnimation(participants, out List<Pawn> participantsOrdered);
|
|
if (animation != null)
|
|
{
|
|
Thing anchor = (Thing)__instance.Bed ?? pawn;
|
|
AnimationUtility.StartGroupAnimation(participantsOrdered, animation, anchor);
|
|
}
|
|
|
|
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
}
|