rjw-toys-and-masturbation/Source/ThingComps/CompSexToy.cs

63 lines
1.9 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) => CasualSex_Helper.FindSexLocation(p);
public CompProperties_SexToy Props => (CompProperties_SexToy)props;
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 {
Building_Bed bed = pawn.ownership?.OwnedBed;
if (bed != null && (WanderUtility.InSameRoom(bed.Position, parent.Position, pawn.Map) || RJWPreferenceSettings.FapInBed && pawn.jobs.curDriver is JobDriver_LayDown)) {
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";
}
}
}