2021-03-06 13:32:33 +00:00
|
|
|
|
using System.Collections.Generic;
|
2021-06-10 12:06:05 +00:00
|
|
|
|
using RimWorld;
|
|
|
|
|
using Verse;
|
2021-02-13 09:45:22 +00:00
|
|
|
|
using Verse.AI;
|
|
|
|
|
|
|
|
|
|
namespace RJW_Menstruation
|
|
|
|
|
{
|
2021-03-06 13:32:33 +00:00
|
|
|
|
public class JobDriver_VaginaWashing : JobDriver
|
|
|
|
|
{
|
|
|
|
|
const int excretingTime = 300;//ticks - 120 = 2 real seconds, 3 in-game minutes
|
2021-02-13 09:45:22 +00:00
|
|
|
|
|
2021-03-06 13:32:33 +00:00
|
|
|
|
public override bool TryMakePreToilReservations(bool errorOnFailed)
|
|
|
|
|
{
|
|
|
|
|
return pawn.Reserve(pawn, job, 1, -1, null, errorOnFailed);
|
|
|
|
|
}
|
2021-02-13 09:45:22 +00:00
|
|
|
|
|
2021-03-06 13:32:33 +00:00
|
|
|
|
protected override IEnumerable<Toil> MakeNewToils()
|
|
|
|
|
{
|
2021-02-13 09:45:22 +00:00
|
|
|
|
|
2021-07-17 09:15:56 +00:00
|
|
|
|
HediffComp_Menstruation Comp = pawn.GetMenstruationComp();
|
2021-03-06 13:32:33 +00:00
|
|
|
|
this.FailOn(delegate
|
|
|
|
|
{
|
2021-07-10 14:51:56 +00:00
|
|
|
|
return !(Comp.TotalCumPercent > 0.001);
|
2021-03-06 13:32:33 +00:00
|
|
|
|
});
|
|
|
|
|
Toil excreting = Toils_General.Wait(excretingTime, TargetIndex.None);//duration of
|
2021-02-13 09:45:22 +00:00
|
|
|
|
|
2021-03-06 13:32:33 +00:00
|
|
|
|
excreting.WithProgressBarToilDelay(TargetIndex.A);
|
|
|
|
|
yield return excreting;
|
|
|
|
|
yield return new Toil()
|
|
|
|
|
{
|
|
|
|
|
initAction = delegate ()
|
|
|
|
|
{
|
2021-07-10 14:51:56 +00:00
|
|
|
|
Comp.CumOut(null, 0.5f);
|
|
|
|
|
if (Comp.TotalCumPercent > 0.001) JumpToToil(excreting);
|
2021-03-06 13:32:33 +00:00
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
//yield return excreting;
|
2021-06-10 12:06:05 +00:00
|
|
|
|
yield break;
|
2021-03-06 13:32:33 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2021-06-10 12:06:05 +00:00
|
|
|
|
|
2021-06-16 12:53:52 +00:00
|
|
|
|
public class JobDriver_MilkSelf : JobDriver
|
|
|
|
|
{
|
|
|
|
|
protected float progress = 0;
|
|
|
|
|
protected float MilkingTime
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return 250f * Fullness + 50f;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
protected virtual float Fullness
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return comp?.Fullness ?? 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private CompMilkable comp;
|
|
|
|
|
|
|
|
|
|
public override bool TryMakePreToilReservations(bool errorOnFailed)
|
|
|
|
|
{
|
|
|
|
|
return pawn.Reserve(pawn, job, 1, -1, null, errorOnFailed);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected virtual void PreMakeNewToils()
|
|
|
|
|
{
|
|
|
|
|
comp = pawn.GetComp<CompMilkable>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override IEnumerable<Toil> MakeNewToils()
|
|
|
|
|
{
|
|
|
|
|
PreMakeNewToils();
|
|
|
|
|
this.FailOnDespawnedNullOrForbidden(TargetIndex.A);
|
|
|
|
|
this.FailOnNotCasualInterruptible(TargetIndex.A);
|
|
|
|
|
Toil milking = new Toil();
|
|
|
|
|
milking.initAction = delegate ()
|
|
|
|
|
{
|
|
|
|
|
pawn.pather.StopDead();
|
|
|
|
|
};
|
|
|
|
|
milking.tickAction = MilkingTick;
|
|
|
|
|
milking.AddFinishAction(Finish);
|
|
|
|
|
milking.defaultCompleteMode = ToilCompleteMode.Never;
|
|
|
|
|
milking.WithProgressBar(TargetIndex.A, () => progress / MilkingTime);
|
|
|
|
|
yield return milking;
|
|
|
|
|
yield break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected void MilkingTick()
|
|
|
|
|
{
|
|
|
|
|
progress += pawn.GetStatValue(StatDefOf.AnimalGatherSpeed);
|
|
|
|
|
if (progress > MilkingTime)
|
|
|
|
|
{
|
|
|
|
|
Gathered();
|
|
|
|
|
pawn.jobs.EndCurrentJob(JobCondition.Succeeded);
|
|
|
|
|
}
|
|
|
|
|
PostTickAction();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected virtual void Gathered()
|
|
|
|
|
{
|
|
|
|
|
pawn.GetComp<CompMilkable>().Gathered(pawn);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected virtual void Finish()
|
|
|
|
|
{
|
|
|
|
|
if(pawn.CurJobDef == JobDefOf.Wait_MaintainPosture)
|
|
|
|
|
{
|
|
|
|
|
pawn.jobs.EndCurrentJob(JobCondition.InterruptForced);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected virtual void PostTickAction()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2021-06-10 12:06:05 +00:00
|
|
|
|
|
|
|
|
|
|
2021-02-13 09:45:22 +00:00
|
|
|
|
}
|