vanilla lovin does animation

This commit is contained in:
Platinum 2020-04-10 22:03:25 -07:00
parent b04afef7b1
commit 1e05e7a3dc
7 changed files with 77 additions and 6 deletions

View file

@ -38,7 +38,6 @@ namespace Rimworld_Animations {
Toil startPartnerSex = new Toil();
startPartnerSex.initAction = delegate {
Log.Message("Attempting to start job...");
Job gettinLovedJob = JobMaker.MakeJob(DefDatabase<JobDef>.GetNamed("GettinLovedAnimation"), pawn, Bed); // new gettin loved toil that wakes up the pawn goes here
Partner.jobs.jobQueue.EnqueueFirst(gettinLovedJob);

View file

@ -0,0 +1,28 @@
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) {
RestUtility.WakeUp(pawn);
Pawn partnerInMyBed = LovePartnerRelationUtility.GetPartnerInMyBed(pawn);
__result = JobMaker.MakeJob(DefDatabase<JobDef>.GetNamed("JoinInBedAnimation", true), partnerInMyBed, partnerInMyBed.CurrentBed());
}
}
}
}

View file

@ -107,6 +107,37 @@ namespace Rimworld_Animations {
public static void Postfix(ref JobDriver_SexBaseInitiator __instance) {
//Stolen from vanilla lovin
//to make sure vanilla lovin variables are set
if(__instance.pawn?.mindState?.canLovinTick != null) {
SimpleCurve LovinIntervalHoursFromAgeCurve = new SimpleCurve
{
new CurvePoint(16f, 1.5f),
new CurvePoint(22f, 1.5f),
new CurvePoint(30f, 4f),
new CurvePoint(50f, 12f),
new CurvePoint(75f, 36f)
};
int ticksToNextLovin;
if (DebugSettings.alwaysDoLovin) {
ticksToNextLovin = 100;
} else {
float centerX = LovinIntervalHoursFromAgeCurve.Evaluate(__instance.pawn.ageTracker.AgeBiologicalYearsFloat);
centerX = Rand.Gaussian(centerX, 0.3f);
if (centerX < 0.5f) {
centerX = 0.5f;
}
ticksToNextLovin = (int)(centerX * 2500f);
}
__instance.pawn.mindState.canLovinTick = Find.TickManager.TicksGame + ticksToNextLovin;
}
if (__instance.Target.jobs?.curDriver is JobDriver_SexBaseReciever) {
if (__instance.pawn.TryGetComp<CompBodyAnimator>().isAnimating) {