111 lines
3.7 KiB
C#
111 lines
3.7 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using RimWorld;
|
|
using rjw;
|
|
using Verse;
|
|
using Verse.AI;
|
|
|
|
namespace RJW_ToysAndMasturbation {
|
|
class JobGiver_MasturbateWithToy : ThinkNode_JobGiver {
|
|
|
|
public static IntVec3 FapLocation(Pawn p) => CasualSex_Helper.FindSexLocation(p);
|
|
|
|
protected override Job TryGiveJob(Pawn pawn) {
|
|
|
|
if (pawn.Drafted) {
|
|
return null;
|
|
}
|
|
if (!xxx.can_be_fucked(pawn) && !xxx.can_fuck(pawn)) {
|
|
return null;
|
|
}
|
|
|
|
if(findSexToyOnMap(pawn, out Thing sexToy)) {
|
|
if ((SexUtility.ReadyForLovin(pawn) && (!xxx.is_whore(pawn) || pawn.IsPrisoner || xxx.is_slave(pawn))) || xxx.is_frustrated(pawn)) {
|
|
|
|
IntVec3 fapLocation = FapLocation(pawn);
|
|
|
|
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, sexToy, bed, bed.Position);
|
|
j.count = 1;
|
|
return j;
|
|
|
|
}
|
|
}
|
|
else if (RJWPreferenceSettings.FapEverywhere && (xxx.is_frustrated(pawn) || xxx.has_quirk(pawn, "Exhibitionist"))
|
|
&& ReachabilityUtility.CanReach(pawn, fapLocation, PathEndMode.OnCell, Danger.Some)) {
|
|
Job j = JobMaker.MakeJob(MasturbateToyDefOf.MasturbateWithToy, sexToy, null, fapLocation);
|
|
j.count = 1;
|
|
return j;
|
|
}
|
|
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
public static bool findSexToyOnMap(Pawn p, out Thing sexToy) {
|
|
|
|
sexToy = null;
|
|
|
|
Predicate<Thing> validator = delegate (Thing t) {
|
|
if(t.TryGetComp<CompSexToy>() == null) {
|
|
return false;
|
|
}
|
|
//homo check
|
|
if (t.TryGetComp<CompSexToy>().Props.primaryGender == p.gender ||
|
|
(t.TryGetComp<CompSexToy>().Props.primaryGender == Gender.Male && xxx.can_fuck(p) && (RJWPreferenceSettings.FeMalesex == RJWPreferenceSettings.AllowedSex.All || RJWPreferenceSettings.FeMalesex == RJWPreferenceSettings.AllowedSex.Homo)) ||
|
|
(t.TryGetComp<CompSexToy>().Props.primaryGender == Gender.Female && xxx.can_be_fucked(p) && (RJWPreferenceSettings.Malesex == RJWPreferenceSettings.AllowedSex.All || RJWPreferenceSettings.Malesex == RJWPreferenceSettings.AllowedSex.Homo)))
|
|
{
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
};
|
|
|
|
Predicate<Thing> validatorForRoom = delegate (Thing t) {
|
|
if (t.TryGetComp<CompSexToy>() == null)
|
|
{
|
|
return false;
|
|
}
|
|
//homo check
|
|
if (t.TryGetComp<CompSexToy>().Props.primaryGender == p.gender ||
|
|
(t.TryGetComp<CompSexToy>().Props.primaryGender == Gender.Male && xxx.can_fuck(p) && (RJWPreferenceSettings.FeMalesex == RJWPreferenceSettings.AllowedSex.All || RJWPreferenceSettings.FeMalesex == RJWPreferenceSettings.AllowedSex.Homo)) ||
|
|
(t.TryGetComp<CompSexToy>().Props.primaryGender == Gender.Female && xxx.can_be_fucked(p) && (RJWPreferenceSettings.Malesex == RJWPreferenceSettings.AllowedSex.All || RJWPreferenceSettings.Malesex == RJWPreferenceSettings.AllowedSex.Homo))
|
|
&& t.GetRoom(RegionType.Set_All) == p.ownership.OwnedRoom)
|
|
{
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
};
|
|
|
|
if (p.ownership.OwnedRoom != null)
|
|
{
|
|
sexToy = GenClosest.ClosestThingReachable(p.Position, p.Map, ThingRequest.ForGroup(ThingRequestGroup.HaulableAlways), PathEndMode.OnCell, TraverseParms.For(p), validator: validatorForRoom, maxDistance: 100);
|
|
}
|
|
|
|
if(sexToy == null)
|
|
{
|
|
sexToy = GenClosest.ClosestThingReachable(p.Position, p.Map, ThingRequest.ForGroup(ThingRequestGroup.HaulableAlways), PathEndMode.OnCell, TraverseParms.For(p), validator: validator, maxDistance: 100);
|
|
}
|
|
|
|
|
|
if (sexToy != null)
|
|
return true;
|
|
|
|
return false;
|
|
}
|
|
|
|
}
|
|
}
|