mirror of
https://gitgud.io/c0ffeeeeeeee/coffees-rjw-ideology-addons.git
synced 2024-08-14 23:57:38 +00:00
Induce lactation
This commit is contained in:
parent
616d83ba08
commit
f21812a3eb
11 changed files with 382 additions and 0 deletions
79
CRIALactation/Source/JobDrivers/JobDriver_MassageBreasts.cs
Normal file
79
CRIALactation/Source/JobDrivers/JobDriver_MassageBreasts.cs
Normal file
|
@ -0,0 +1,79 @@
|
|||
using Milk;
|
||||
using rjw;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Verse;
|
||||
using RimWorld;
|
||||
using Verse.AI;
|
||||
|
||||
namespace CRIALactation
|
||||
{
|
||||
public class JobDriver_MassageBreasts : JobDriver
|
||||
{
|
||||
private readonly float WorkTotal = 300f;
|
||||
|
||||
public override bool TryMakePreToilReservations(bool errorOnFailed)
|
||||
{
|
||||
LocalTargetInfo Target = job.GetTarget(TargetIndex.A);
|
||||
return pawn.Reserve(Target, job, 1, -1, null, errorOnFailed);
|
||||
}
|
||||
|
||||
protected override IEnumerable<Toil> MakeNewToils()
|
||||
{
|
||||
this.FailOnDespawnedNullOrForbidden(TargetIndex.A);
|
||||
yield return Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.Touch);
|
||||
Toil massage = new Toil();
|
||||
massage.FailOnDespawnedOrNull(TargetIndex.A);
|
||||
massage.FailOnAggroMentalStateAndHostile(TargetIndex.A);
|
||||
massage.initAction = delegate
|
||||
{
|
||||
Pawn p = job.GetTarget(TargetIndex.A).Thing as Pawn;
|
||||
pawn.pather.StopDead();
|
||||
PawnUtility.ForceWait(p, 15000, null, true);
|
||||
};
|
||||
massage.tickAction = delegate ()
|
||||
{
|
||||
pawn.skills.Learn(SkillDefOf.Animals, 0.13f, false);
|
||||
massageProgress += pawn.GetStatValue(StatDefOf.AnimalGatherSpeed, true);
|
||||
|
||||
};
|
||||
massage.AddEndCondition(delegate
|
||||
{
|
||||
Pawn p = job.GetTarget(TargetIndex.A).Thing as Pawn;
|
||||
if (massageProgress >= WorkTotal)
|
||||
{
|
||||
p.TryGetComp<CompInduceLactation>().MassageBreasts();
|
||||
return JobCondition.Succeeded;
|
||||
}
|
||||
|
||||
if (!(p.TryGetComp<CompInduceLactation>().isActive && p.TryGetComp<CompInduceLactation>().CanMassage))
|
||||
{
|
||||
return JobCondition.Incompletable;
|
||||
}
|
||||
|
||||
return JobCondition.Ongoing;
|
||||
|
||||
});
|
||||
|
||||
massage.AddFinishAction(delegate {
|
||||
Pawn pawn = this.job.GetTarget(TargetIndex.A).Thing as Pawn;
|
||||
if (pawn != null && pawn.CurJobDef == JobDefOf.Wait_MaintainPosture)
|
||||
{
|
||||
pawn.jobs.EndCurrentJob(JobCondition.InterruptForced, true, true);
|
||||
}
|
||||
});
|
||||
massage.defaultCompleteMode = ToilCompleteMode.Never;
|
||||
|
||||
massage.WithProgressBar(TargetIndex.A, () => massageProgress / WorkTotal);
|
||||
massage.activeSkill = (() => SkillDefOf.Animals);
|
||||
yield return massage;
|
||||
yield break;
|
||||
|
||||
}
|
||||
|
||||
float massageProgress = 0f;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue