Add project files.

This commit is contained in:
c0ffeeeeeeee 2020-11-05 14:09:05 -08:00
parent d2dbc71d94
commit 39924e2af5
17 changed files with 487 additions and 0 deletions

View file

@ -0,0 +1,21 @@
using RimWorld;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Verse;
namespace RJW_ToysAndMasturbation {
[DefOf]
public static class MasturbateToyDefOf {
public static JobDef MasturbateWithToy;
static MasturbateToyDefOf() {
DefOfHelper.EnsureInitializedInCtor(typeof(JobDefOf));
}
}
}

View file

@ -0,0 +1,77 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Verse;
using RimWorld;
using rjw;
using Verse.AI;
namespace RJW_ToysAndMasturbation {
class JobDriver_MasturbateWithToy : JobDriver_SexBaseInitiator {
public IntVec3 cell => (IntVec3)job.GetTarget(iCell);
public override bool TryMakePreToilReservations(bool errorOnFailed) {
return ReservationUtility.Reserve(pawn, job.targetA, job, stackCount: 1, errorOnFailed: false);
}
public new void setup_ticks() {
base.setup_ticks();
duration = (int)(xxx.is_frustrated(base.pawn) ? (2500f * Rand.Range(0.2f, 0.7f)) : (2500f * Rand.Range(0.2f, 0.4f)));
}
protected override IEnumerable<Toil> MakeNewToils() {
setup_ticks();
ToilFailConditions.FailOn(this, () => pawn.Downed);
ToilFailConditions.FailOn(this, () => pawn.IsBurning());
ToilFailConditions.FailOn(this, () => pawn.IsFighting());
ToilFailConditions.FailOn(this, () => pawn.Drafted);
yield return Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.ClosestTouch).FailOnDespawnedNullOrForbidden(TargetIndex.A);
yield return Toils_Haul.StartCarryThing(TargetIndex.A);
if (!SexToyUtility.isRJWAnimationsLoaded || true /*True for now, anims come later; disable once created animations*/) {
//place down if anims isn't loaded
yield return Toils_Haul.CarryHauledThingToCell(TargetIndex.C);
yield return Toils_Haul.PlaceHauledThingInCell(TargetIndex.C, Toils_Goto.GotoCell(TargetIndex.C, PathEndMode.OnCell), storageMode: false);
}
yield return Toils_Goto.GotoCell(TargetIndex.C, PathEndMode.OnCell);
Toil masturbationToil = Toils_General.Wait(duration);
masturbationToil.handlingFacing = true;
masturbationToil.defaultCompleteMode = ToilCompleteMode.Never;
masturbationToil.initAction = delegate { Start(); };
masturbationToil.tickAction = delegate {
duration--;
if (Gen.IsHashIntervalTick(pawn, ticks_between_hearts)) {
ThrowMetaIcon(pawn.Position, pawn.Map, ThingDefOf.Mote_Heart);
}
SexTick(pawn, null);
SexUtility.reduce_rest(pawn);
if (duration <= 0) ReadyForNextToil();
};
masturbationToil.AddFinishAction(delegate { End(); });
yield return masturbationToil;
Toil AfterToil = new Toil();
AfterToil.initAction = delegate {
SexUtility.Aftersex(pawn);
if(SexUtility.ConsiderCleaning(pawn)) {
LocalTargetInfo filth = GridsUtility.GetFirstThing<Filth>(pawn.PositionHeld, pawn.Map);
Job cleanup = JobMaker.MakeJob(JobDefOf.Clean);
cleanup.AddQueuedTarget(TargetIndex.A, filth);
pawn.jobs.jobQueue.EnqueueFirst(cleanup);
}
};
yield return AfterToil;
}
}
}

View file

@ -0,0 +1,40 @@
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) => (new JobGiver_Masturbate()).FindFapLocation(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 ((SexUtility.ReadyForLovin(pawn) && (!xxx.is_whore(pawn) || pawn.IsPrisoner || xxx.is_slave(pawn))) || xxx.is_frustrated(pawn)) {
if (RJWPreferenceSettings.FapInBed && pawn.jobs.curDriver is JobDriver_LayDown) {
Building_Bed bed = ((JobDriver_LayDown)pawn.jobs.curDriver).Bed;
if (bed != null) {
return JobMaker.MakeJob(xxx.Masturbate, null, bed, bed.Position);
}
}
else if (RJWPreferenceSettings.FapEverywhere && (xxx.is_frustrated(pawn) || xxx.has_quirk(pawn, "Exhibitionist"))) {
return JobMaker.MakeJob(xxx.Masturbate, null, null, FapLocation(pawn));
}
}
return null;
}
}
}

View file

@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using RimWorld;
using Verse;
namespace RJW_ToysAndMasturbation {
public class CompProperties_SexToy : CompProperties {
public CompProperties_SexToy() {
compClass = typeof(CompSexToy);
}
}
}

View file

@ -0,0 +1,59 @@
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 "Use sex toy";
}
}
}

View file

@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Verse;
namespace RJW_ToysAndMasturbation {
[StaticConstructorOnStartup]
public static class SexToyUtility {
public static bool isRJWAnimationsLoaded = false;
static SexToyUtility() {
if(LoadedModManager.RunningMods.Any((ModContentPack x) => x.Name == "Rimworld-Animations")) {
isRJWAnimationsLoaded = true;
}
}
}
}