better location finding + mirroring

This commit is contained in:
c0ffee 2022-01-25 12:34:53 -08:00
parent 015a64928a
commit ac5d37bdaf
4 changed files with 78 additions and 14 deletions

View file

@ -20,33 +20,42 @@ namespace Patch_SexToysMasturbation
if(__instance is JobDriver_MasturbateWithToy masturbateJobDriver)
{
Log.Message("Rerolling animations...");
Pawn pawn = masturbateJobDriver.pawn;
Thing sexToy = masturbateJobDriver.dildo;
RerollAnimationsForSexToy(pawn, sexToy);
RerollAnimationsForSexToy(pawn, sexToy, masturbateJobDriver.Bed);
}
}
public static void RerollAnimationsForSexToy(Pawn pawn, Thing thing)
public static void RerollAnimationsForSexToy(Pawn pawn, Thing thing, Thing bed)
{
CompSexToy sextoy = thing.TryGetComp<CompSexToy>();
SexToyAnimationDef anim = AnimSexToyUtility.tryFindAnimation(sextoy, pawn);
if (anim != null)
{
Log.Message("Playing anim " + anim.defName);
pawn.TryGetComp<CompBodyAnimator>().setAnchor(pawn.Position);
thing.TryGetComp<CompThingAnimator>().setAnchor(pawn.Position);
if(bed != null)
{
pawn.TryGetComp<CompBodyAnimator>().setAnchor(bed);
thing.TryGetComp<CompThingAnimator>().setAnchor(bed);
}
else
{
pawn.TryGetComp<CompBodyAnimator>().setAnchor(pawn.Position);
thing.TryGetComp<CompThingAnimator>().setAnchor(pawn.Position);
}
pawn.TryGetComp<CompBodyAnimator>().StartAnimation(anim, new List<Pawn> { pawn }, 0);
thing.TryGetComp<CompThingAnimator>().StartAnimation(anim, pawn);
bool mirror = GenTicks.TicksGame % 2 == 0;
pawn.TryGetComp<CompBodyAnimator>().StartAnimation(anim, new List<Pawn> { pawn }, 0, mirror);
thing.TryGetComp<CompThingAnimator>().StartAnimation(anim, pawn, mirror);
(pawn.jobs.curDriver as JobDriver_Sex).ticks_left = anim.animationTimeTicks;
(pawn.jobs.curDriver as JobDriver_Sex).sex_ticks = anim.animationTimeTicks;