rjw-toys-and-masturbation/Source/ThingComps/CompSexToy.cs
2020-11-05 14:52:02 -08:00

59 lines
1.8 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Verse;
using RimWorld;
using Verse.AI;
using rjw;
namespace RJW_ToysAndMasturbation {
public class CompSexToy : ThingComp {
public static IntVec3 FapLocation(Pawn p) => (new JobGiver_Masturbate()).FindFapLocation(p);
public override IEnumerable<FloatMenuOption> CompFloatMenuOptions(Pawn pawn) {
if (!pawn.CanReach(parent, PathEndMode.Touch, Danger.Deadly)) {
yield return new FloatMenuOption(FloatMenuOptionLabel(pawn) + " (" + "NoPath".Translate() + ")", null);
}
else if (!pawn.CanReserve(parent)) {
yield return new FloatMenuOption(FloatMenuOptionLabel(pawn) + " (" + "Reserved".Translate() + ")", null);
}
else if (!pawn.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation)) {
yield return new FloatMenuOption(FloatMenuOptionLabel(pawn) + " (" + "Incapable".Translate() + ")", null);
}
else if (!xxx.can_be_fucked(pawn) && !xxx.can_fuck(pawn)) {
yield return new FloatMenuOption(FloatMenuOptionLabel(pawn) + " (" + "Incapable".Translate() + ")", null);
}
else {
yield return new FloatMenuOption(FloatMenuOptionLabel(pawn), delegate {
if (RJWPreferenceSettings.FapInBed && pawn.jobs.curDriver is JobDriver_LayDown) {
Building_Bed bed = ((JobDriver_LayDown)pawn.jobs.curDriver).Bed;
if (bed != null) {
Job j = JobMaker.MakeJob(MasturbateToyDefOf.MasturbateWithToy, parent, bed, bed.Position);
j.count = 1;
pawn.jobs.TryTakeOrderedJob(j);
}
}
else {
Job j = JobMaker.MakeJob(MasturbateToyDefOf.MasturbateWithToy, parent, null, FapLocation(pawn));
j.count = 1;
pawn.jobs.TryTakeOrderedJob(j);
}
});
}
}
private string FloatMenuOptionLabel(Pawn pawn) {
return "Masturbate with toy";
}
}
}