code stringlengths 0 56.1M | repo_name stringlengths 3 57 | path stringlengths 2 176 | language stringclasses 672 values | license stringclasses 8 values | size int64 0 56.8M |
|---|---|---|---|---|---|
using Verse;
using RimWorld;
namespace rjw
{
public class Hediff_ArtificialSexPart : Hediff_AddedPart, ISexPartHediff
{
public override bool ShouldRemove => false;
public HediffDef_SexPart Def => def as HediffDef_SexPart;
public HediffWithComps AsHediff => this;
public override string LabelBase => def.label;
/// <summary>
/// stack hediff in health tab?
/// </summary>
public override int UIGroupKey
{
get
{
return loadID;
}
}
/// <summary>
/// do not merge same rjw parts into one
/// </summary>
public override bool TryMergeWith(Hediff other)
{
return false;
}
}
}
| Korth95/rjw | 1.5/Source/Hediffs/Hediff_ArtificialSexPart.cs | C# | mit | 626 |
using RimWorld;
using System.Collections.Generic;
using System.Linq;
using Verse;
namespace rjw
{
public class Cocoon : HediffWithComps
{
public int tickNext;
public override void PostMake()
{
Severity = 1.0f;
SetNextTick();
}
public override void ExposeData()
{
base.ExposeData();
Scribe_Values.Look(ref tickNext, "tickNext", 1000, true);
}
public override void Tick()
{
if (Find.TickManager.TicksGame >= tickNext)
{
//Log.Message("Cocoon::Tick() " + base.xxx.get_pawnname(pawn));
HealWounds();
SatisfyHunger();
SatisfyThirst();
SetNextTick();
}
}
public void HealWounds()
{
IEnumerable<Hediff> enumerable = from hd in pawn.health.hediffSet.hediffs
where !hd.IsTended() && hd.TendableNow()
select hd;
if (enumerable != null)
{
foreach (Hediff item in enumerable)
{
HediffWithComps val = item as HediffWithComps;
if (val != null)
if (val.Bleeding)
{
//Log.Message("TrySealWounds " + xxx.get_pawnname(pawn) + ", Bleeding " + item.Label);
//HediffComp_TendDuration val2 = HediffUtility.TryGetComp<HediffComp_TendDuration>(val);
val.Heal(0.5f);
//val2.tendQuality = 1f;
//val2.tendTicksLeft = 10000;
//pawn.health.Notify_HediffChanged(item);
}
// tend infections
// tend lifeThreatening chronic
else if ((!val.def.chronic && val.def.lethalSeverity > 0f) || (val.CurStage?.lifeThreatening ?? false))
{
//Log.Message("TryHeal " + xxx.get_pawnname(pawn) + ", infection(?) " + item.Label);
HediffComp_TendDuration val2 = HediffUtility.TryGetComp<HediffComp_TendDuration>(val);
val2.tendQuality = 1f;
val2.tendTicksLeft = 10000;
pawn.health.Notify_HediffChanged(item);
}
}
}
}
public void SatisfyHunger()
{
Need_Food need = pawn.needs.TryGetNeed<Need_Food>();
if (need == null)
{
return;
}
//pawn.PositionHeld.IsInPrisonCell(pawn.Map)
//Log.Message("Cocoon::SatisfyHunger() " + xxx.get_pawnname(pawn) + " IsInPrisonCell " + pawn.PositionHeld.IsInPrisonCell(pawn.Map));
//Log.Message("Cocoon::SatisfyHunger() " + xxx.get_pawnname(pawn) + " GetRoom " + pawn.PositionHeld.GetRoom(pawn.Map));
//Log.Message("Cocoon::SatisfyHunger() " + xxx.get_pawnname(pawn) + " GetRoom " + pawn.PositionHeld.GetZone(pawn.Map));
if (need.CurLevel < 0.15f)
{
//Log.Message("Cocoon::SatisfyHunger() " + xxx.get_pawnname(pawn) + " need to eat");
float nutrition_amount = need.MaxLevel / 5f;
pawn.needs.food.CurLevel += nutrition_amount;
}
}
public void SatisfyThirst()
{
if (!xxx.DubsBadHygieneIsActive)
return;
Need need = pawn.needs.AllNeeds.Find(x => x.def == xxx.DBHThirst);
if (need == null)
{
return;
}
if (need.CurLevel < 0.15f)
{
//Log.Message("Cocoon::SatisfyThirst() " + xxx.get_pawnname(pawn) + " need to drink");
float nutrition_amount = need.MaxLevel / 5f;
pawn.needs.TryGetNeed(need.def).CurLevel += nutrition_amount;
}
}
public void SetNextTick()
{
//make actual tick every 16.6 sec
tickNext = Find.TickManager.TicksGame + 1000;
//Log.Message("Cocoon::SetNextTick() " + tickNext);
}
}
}
| Korth95/rjw | 1.5/Source/Hediffs/Hediff_Cocoon.cs | C# | mit | 3,255 |
using Verse;
using RimWorld;
namespace rjw
{
public class Hediff_NaturalSexPart : HediffWithComps, ISexPartHediff
{
public override bool ShouldRemove => false;
public HediffDef_SexPart Def => def as HediffDef_SexPart;
public HediffWithComps AsHediff => this;
public override string LabelBase
{
get
{
/*
* make patch to make/save capmods?
if (CapMods.Count < 5)
{
PawnCapacityModifier pawnCapacityModifier = new PawnCapacityModifier();
pawnCapacityModifier.capacity = PawnCapacityDefOf.Moving;
pawnCapacityModifier.offset += 0.5f;
CapMods.Add(pawnCapacityModifier);
}
*/
//name/kind
return def.label;
}
}
/// <summary>
/// stack hediff in health tab?
/// </summary>
public override int UIGroupKey
{
get
{
return loadID;
}
}
/// <summary>
/// do not merge same rjw parts into one
/// </summary>
public override bool TryMergeWith(Hediff other)
{
return false;
}
}
}
| Korth95/rjw | 1.5/Source/Hediffs/Hediff_NaturalSexPart.cs | C# | mit | 987 |
using System.Linq;
using Verse;
namespace rjw
{
public class Hediff_PartsSizeChangerPC : HediffWithComps
{
public override void PostAdd(DamageInfo? dinfo)
{
if (Part != null)
{
foreach (var sexPart in pawn.health.hediffSet.hediffs.Where(x => x.Part == Part).OfType<ISexPartHediff>().ToList())
{
HediffComp_SexPart partComp = sexPart.GetPartComp();
if (partComp != null)
{
//Log.Message(" Hediff_PartsSizeChanger: " + hed.Label);
//Log.Message(" Hediff_PartsSizeChanger: " + hed.Severity);
//Log.Message(" Hediff_PartsSizeChanger: " + CompHediff.SizeBase);
//Log.Message(" Hediff_PartsSizeChanger: " + "-----");
//Log.Message(" Hediff_PartsSizeChanger: " + this.Label);
//Log.Message(" Hediff_PartsSizeChanger: " + this.Severity);
partComp.UpdateSeverity(CurStage.minSeverity);
//Log.Message(" Hediff_PartsSizeChanger: " + "-----");
//Log.Message(" Hediff_PartsSizeChanger: " + hed.Label);
//Log.Message(" Hediff_PartsSizeChanger: " + hed.Severity);
//Log.Message(" Hediff_PartsSizeChanger: " + CompHediff.SizeBase);
}
}
}
pawn.health.RemoveHediff(this);
}
}
public class Hediff_PartsSizeChangerCE : HediffWithComps
{
public override void PostAdd(DamageInfo? dinfo)
{
if (Part != null)
{
foreach (var sexPart in pawn.health.hediffSet.hediffs.Where(x => x.Part == Part).OfType<ISexPartHediff>().ToList())
{
HediffComp_SexPart partComp = sexPart.GetPartComp();
if (partComp != null)
{
partComp.UpdateSeverity(def.initialSeverity);
}
}
}
pawn.health.RemoveHediff(this);
}
}
} | Korth95/rjw | 1.5/Source/Hediffs/Hediff_PartsSizeChanger.cs | C# | mit | 1,666 |
using Verse;
//Hediff worker for pawns' "lay down and submit" button
namespace rjw
{
public class Hediff_Submitting: HediffWithComps
{
public override bool ShouldRemove {
get
{
Pawn daddy = pawn.CarriedBy;
if (daddy != null && daddy.Faction == pawn.Faction)
{
return true;
}
else
return base.ShouldRemove;
}
}
}
}
| Korth95/rjw | 1.5/Source/Hediffs/Hediff_Submitting.cs | C# | mit | 364 |
using Verse;
using RimWorld;
using rjw.Modules.Interactions.Objects.Parts;
namespace rjw
{
// Would be nice to call this just 'ISexPart', but ILewdablePart already exists and represents something similar but different.
public interface ISexPartHediff
{
HediffDef_SexPart Def { get; }
T GetComp<T>() where T : HediffComp;
HediffWithComps AsHediff { get; }
}
public static class ISexPartHediffExtensions
{
public static HediffComp_SexPart GetPartComp(this ISexPartHediff partHediff) => partHediff.GetComp<HediffComp_SexPart>();
public static Pawn GetOwner(this ISexPartHediff part) => part.AsHediff.pawn;
}
} | Korth95/rjw | 1.5/Source/Hediffs/ISexPartHediff.cs | C# | mit | 628 |
using System.Collections.Generic;
using Verse;
namespace rjw
{
public class PartAdder
{
public float chance = 0f;
public string rjwPart;
public List<string> bodyParts;
}
}
| Korth95/rjw | 1.5/Source/Hediffs/PartAdder.cs | C# | mit | 185 |
using Verse;
using RimWorld;
using System;
using System.Collections.Generic;
using System.Linq;
namespace rjw;
public static class PartSizeCalculator
{
public static bool TryGetLength(Hediff hediff, out float size)
{
return TryGetMeasurementFromCurve(hediff, GetSizeConfig(hediff)?.lengths, true, out size);
}
public static bool TryGetLength(HediffDef def, float baseSize, out float size)
{
return TryGetMeasurementFromCurve(def, baseSize, 1f, GetSizeConfig(def)?.lengths, out size);
}
public static bool TryGetGirth(Hediff hediff, out float size)
{
return TryGetMeasurementFromCurve(hediff, GetSizeConfig(hediff)?.girths, true, out size);
}
public static bool TryGetGirth(HediffDef def, float baseSize, out float size)
{
return TryGetMeasurementFromCurve(def, baseSize, 1f, GetSizeConfig(def)?.girths, out size);
}
public static bool TryGetCupSize(Hediff hediff, out float size)
{
// Cup size is already "scaled" because the same breast volume has a smaller cup size on a larger band size.
return TryGetMeasurementFromCurve(hediff, GetSizeConfig(hediff)?.cupSizes, false, out size);
}
public static bool TryGetCupSize(HediffDef def, float baseSize, out float size)
{
return TryGetMeasurementFromCurve(def, baseSize, 1f, GetSizeConfig(def)?.cupSizes, out size);
}
public static float GetBandSize(Hediff hediff)
{
var size = GetUnderbustSize(hediff);
size /= BraSizeConfigDef.Instance.bandSizeInterval;
size = (float)Math.Round(size, MidpointRounding.AwayFromZero);
size *= BraSizeConfigDef.Instance.bandSizeInterval;
return size;
}
public static float GetUnderbustSize(Hediff hediff)
{
return BraSizeConfigDef.Instance.bandSizeBase * GetScale(hediff);
}
static float GetScale(Hediff hediff)
{
if (!hediff.TryGetComp<HediffComp_SexPart>(out var comp))
{
// Added as a Option for Modders to change Size above max-severity.
if (comp.bodySizeOverride >= 0.001)
return comp.bodySizeOverride;
}
return hediff.pawn.BodySize;
}
public static bool TryGetOverbustSize(Hediff hediff, out float size)
{
if (!TryGetCupSize(hediff, out var cupSize))
{
size = 0f;
return false;
}
// Cup size is rounded up, so to do the math backwards subtract .9
size = GetUnderbustSize(hediff) + ((cupSize - .9f) * BraSizeConfigDef.Instance.cupSizeInterval);
return true;
}
static bool TryGetMeasurementFromCurve(
Hediff hediff,
List<float> stageSizes,
bool shouldScale,
out float measurement)
{
var scaleFactor = shouldScale ? GetScale(hediff) : 1.0f;
if (!hediff.TryGetComp<HediffComp_SexPart>(out var comp))
{
measurement = 0;
return false;
}
return TryGetMeasurementFromCurve(hediff.def, comp.Size, scaleFactor, stageSizes, out measurement);
}
static bool TryGetMeasurementFromCurve(HediffDef hediffDef, float baseSize, float scale, List<float> stageSizes, out float measurement)
{
if (hediffDef is not HediffDef_SexPart || stageSizes.NullOrEmpty())
{
measurement = 0f;
return false;
}
var curve = new SimpleCurve(hediffDef.stages.Zip(stageSizes, (stage, stageSize) => new CurvePoint(stage.minSeverity, stageSize)));
measurement = curve.Evaluate(baseSize) * scale;
return true;
}
public static bool TryGetPenisWeight(Hediff hediff, out float weight)
{
if (!TryGetLength(hediff, out float length) ||
!TryGetGirth(hediff, out float girth))
{
weight = 0f;
return false;
}
var density = GetSizeConfig(hediff).density;
if (density == null)
{
weight = 0f;
return false;
}
var r = girth / (2.0 * Math.PI);
var volume = r * r * Math.PI * length;
weight = (float)(volume * density.Value / 1000f);
return true;
}
public static bool TryGetBreastWeight(Hediff hediff, out float weight)
{
if (!TryGetCupSize(hediff, out float rawSize))
{
weight = 0f;
return false;
}
var density = GetSizeConfig(hediff).density;
if (density == null)
{
weight = 0f;
return false;
}
// Up a band size and down a cup size is about the same volume.
var extraBandSize = BraSizeConfigDef.Instance.bandSizeBase * (1.0f - GetScale(hediff));
var extraCupSizes = extraBandSize / BraSizeConfigDef.Instance.bandSizeInterval;
var size = rawSize + extraCupSizes;
var pounds = 0.765f
+ 0.415f * size
+ -0.0168f * size * size
+ 2.47E-03f * size * size * size;
var kg = Math.Max(0, pounds * 0.45359237f);
weight = kg * density.Value;
return true;
}
private static PartSizeConfigDef GetSizeConfig(Hediff hediff)
{
return GetSizeConfig(hediff.def);
}
private static PartSizeConfigDef GetSizeConfig(HediffDef def)
{
return (def as HediffDef_SexPart)?.sizeProfile;
}
} | Korth95/rjw | 1.5/Source/Hediffs/PartSizeCalculator.cs | C# | mit | 4,660 |
using Verse;
using RimWorld;
using System.Collections.Generic;
namespace rjw;
public class PartSizeConfigDef : Def
{
public bool bodysizescale = false; // rescales parts sizes based on bodysize of initial owner race
/// <summary>
/// Human standard would be 1.0. Null for no weight display.
/// </summary>
public float? density = null;
public List<float> lengths;
public List<float> girths;
public List<float> cupSizes;
} | Korth95/rjw | 1.5/Source/Hediffs/PartSizeConfigDef.cs | C# | mit | 443 |
using Verse;
using RimWorld;
using System.Collections.Generic;
using System.Linq;
using rjw.Modules.Interactions.Enums;
using rjw.Modules.Interactions.Objects.Parts;
namespace rjw;
public class SexFluidDef : Def
{
public ThingDef filth;
public ThingDef consumable;
public float consumableFluidRatio = 1;
public bool ingestThroughAnyOrifice;
public bool alwaysProduceFilth;
public float baseNutrition;
public float baseNutritionCost = 1;
public bool quenchesThirst = true;
public List<string> tags = [];
public List<SexFluidIngestionDoer> ingestionDoers;
public override IEnumerable<string> ConfigErrors()
{
foreach (string err in base.ConfigErrors())
{
yield return err;
}
if (filth != null && filth.filth == null)
{
yield return $"{nameof(filth)} must be a ThingDef with a <filth> field.";
}
if (consumable != null && baseNutrition != 0)
{
yield return $"{nameof(consumable)} is set, so {nameof(baseNutrition)} is meaningless.";
}
}
public override void ResolveReferences()
{
base.ResolveReferences();
if (consumable != null)
{
descriptionHyperlinks ??= new();
descriptionHyperlinks.AddDistinct(consumable);
}
}
} | Korth95/rjw | 1.5/Source/Hediffs/SexFluidDef.cs | C# | mit | 1,187 |
using Verse;
namespace rjw;
public abstract class SexFluidIngestionDoer
{
public abstract void Ingested(Pawn pawn, SexFluidDef fluid, float amount, ISexPartHediff fromPart, ISexPartHediff toPart = null);
} | Korth95/rjw | 1.5/Source/Hediffs/SexFluidIngestionDoer.cs | C# | mit | 208 |
using System;
using System.Collections.Generic;
using System.Linq;
using Verse;
namespace rjw
{
public class InteractionExtension : DefModExtension
{
/// <summary>
/// </summary>
public string RMBLabel = ""; // rmb menu
public string rjwSextype = ""; // xxx.rjwSextype
public List<string> rulepack_defs = new List<string>(); //rulepack(s) for this interaction
}
}
| Korth95/rjw | 1.5/Source/Interactions/InteractionExtension.cs | C# | mit | 382 |
using System.Collections.Generic;
using System.Text;
using RimWorld;
using Verse;
namespace rjw
{
internal class InteractionWorker_AnalSexAttempt : InteractionWorker
{
//initiator - rapist
//recipient - victim
public static bool AttemptAnalSex(Pawn initiator, Pawn recipient)
{
//--Log.Message(xxx.get_pawnname(initiator) + " is attempting to anally rape " + xxx.get_pawnname(recipient));
return true;
}
public override float RandomSelectionWeight(Pawn initiator, Pawn recipient)
{
// this interaction is triggered by the jobdriver
if (initiator == null || recipient == null)
return 0.0f;
return 0.0f; // base.RandomSelectionWeight(initiator, recipient);
}
public override void Interacted(Pawn initiator, Pawn recipient, List<RulePackDef> extraSentencePacks, out string letterText, out string letterLabel, out LetterDef letterDef, out LookTargets lookTargets)
{
//add something fancy here later?
letterText = null;
letterLabel = null;
letterDef = null;
lookTargets = recipient;
//Find.LetterStack.ReceiveLetter("Rape attempt", "A wandering nymph has decided to join your colony.", LetterDefOf.NegativeEvent, recipient);
if (initiator == null || recipient == null)
return;
//--ModLog.Message(" InteractionWorker_AnalRapeAttempt::Interacted( " + xxx.get_pawnname(initiator) + ", " + xxx.get_pawnname(recipient) + " ) called");
AttemptAnalSex(initiator, recipient);
}
}
internal class InteractionWorker_VaginalSexAttempt : InteractionWorker
{
//initiator - rapist
//recipient - victim
public static bool AttemptAnalSex(Pawn initiator, Pawn recipient)
{
//--Log.Message(xxx.get_pawnname(initiator) + " is attempting to anally rape " + xxx.get_pawnname(recipient));
return false;
}
public override float RandomSelectionWeight(Pawn initiator, Pawn recipient)
{
// this interaction is triggered by the jobdriver
if (initiator == null || recipient == null)
return 0.0f;
return 0.0f; // base.RandomSelectionWeight(initiator, recipient);
}
public override void Interacted(Pawn initiator, Pawn recipient, List<RulePackDef> extraSentencePacks, out string letterText, out string letterLabel, out LetterDef letterDef, out LookTargets lookTargets)
{
//add something fancy here later?
letterText = null;
letterLabel = null;
letterDef = null;
lookTargets = recipient;
//Find.LetterStack.ReceiveLetter("Rape attempt", "A wandering nymph has decided to join your colony.", LetterDefOf.NegativeEvent, recipient);
if (initiator == null || recipient == null)
return;
//--ModLog.Message(" InteractionWorker_AnalRapeAttempt::Interacted( " + xxx.get_pawnname(initiator) + ", " + xxx.get_pawnname(recipient) + " ) called");
AttemptAnalSex(initiator, recipient);
}
}
internal class InteractionWorker_OtherSexAttempt : InteractionWorker
{
//initiator - rapist
//recipient - victim
public static bool AttemptAnalSex(Pawn initiator, Pawn recipient)
{
//--Log.Message(xxx.get_pawnname(initiator) + " is attempting to anally rape " + xxx.get_pawnname(recipient));
return false;
}
public override float RandomSelectionWeight(Pawn initiator, Pawn recipient)
{
// this interaction is triggered by the jobdriver
if (initiator == null || recipient == null)
return 0.0f;
return 0.0f; // base.RandomSelectionWeight(initiator, recipient);
}
public override void Interacted(Pawn initiator, Pawn recipient, List<RulePackDef> extraSentencePacks, out string letterText, out string letterLabel, out LetterDef letterDef, out LookTargets lookTargets)
{
//add something fancy here later?
letterText = null;
letterLabel = null;
letterDef = null;
lookTargets = recipient;
//Find.LetterStack.ReceiveLetter("Rape attempt", "A wandering nymph has decided to join your colony.", LetterDefOf.NegativeEvent, recipient);
if (initiator == null || recipient == null)
return;
//--ModLog.Message(" InteractionWorker_AnalRapeAttempt::Interacted( " + xxx.get_pawnname(initiator) + ", " + xxx.get_pawnname(recipient) + " ) called");
AttemptAnalSex(initiator, recipient);
}
}
} | Korth95/rjw | 1.5/Source/Interactions/InteractionWorker_SexAttempt.cs | C# | mit | 4,156 |
using RimWorld;
using System.Collections.Generic;
using UnityEngine;
using Verse;
using Verse.AI;
namespace rjw;
//biotech JobDriver_ControlMech
public class JobDriver_HackMechPregnancy : JobDriver
{
private const TargetIndex MechInd = TargetIndex.A;
private Pawn Mech => (Pawn)job.GetTarget(TargetIndex.A).Thing;
private int MechControlTime => Mathf.RoundToInt(Mech.GetStatValue(StatDefOf.ControlTakingTime) * 60f);
public override bool TryMakePreToilReservations(bool errorOnFailed)
{
return pawn.Reserve(Mech, job, 1, -1, null, errorOnFailed);
}
protected override IEnumerable<Toil> MakeNewToils()
{
if (ModsConfig.BiotechActive)
{
this.FailOnDestroyedNullOrForbidden(TargetIndex.A);
yield return Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.Touch);
yield return Toils_General.WaitWith(TargetIndex.A, MechControlTime, useProgressBar: true, maintainPosture: true, maintainSleep: false, TargetIndex.A).WithEffect(EffecterDefOf.ControlMech, TargetIndex.A);
Toil toil = ToilMaker.MakeToil("MakeNewToils");
toil.initAction = delegate
{
Hediff_MechanoidPregnancy pregnancy = (Hediff_MechanoidPregnancy)Mech.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("RJW_pregnancy_mech"));
pregnancy.Hack();
};
toil.PlaySoundAtEnd(SoundDefOf.ControlMech_Complete);
yield return toil;
}
}
}
| Korth95/rjw | 1.5/Source/JobDrivers/JobDriver_AbortMechPregnancy.cs | C# | mit | 1,342 |
using System.Collections.Generic;
using RimWorld;
using Verse;
using Verse.AI;
using Multiplayer.API;
namespace rjw
{
public class JobDriver_BestialityForFemale : JobDriver_SexBaseInitiator
{
public IntVec3 SleepSpot => Bed.SleepPosOfAssignedPawn(pawn);
public override bool TryMakePreToilReservations(bool errorOnFailed)
{
return pawn.Reserve(Target, job, 1, 0, null, errorOnFailed);
}
[SyncMethod]
protected override IEnumerable<Toil> MakeNewToils()
{
setup_ticks();
var PartnerJob = xxx.gettin_loved;
this.FailOnDespawnedOrNull(iTarget);
this.FailOnDespawnedNullOrForbidden(iBed);
this.FailOn(() => !pawn.CanReserveAndReach(Partner, PathEndMode.Touch, Danger.Deadly));
this.FailOn(() => pawn.Drafted);
this.FailOn(() => Partner.IsFighting());
this.FailOn(() => !Partner.CanReach(SleepSpot, PathEndMode.Touch, Danger.Deadly)); //changed to SleepSpot as partner will only move to bed
yield return Toils_Reserve.Reserve(iTarget, 1, 0);
yield return Toils_Goto.GotoThing(iTarget, PathEndMode.Touch);
var gotoBed = new Toil();
gotoBed.defaultCompleteMode = ToilCompleteMode.PatherArrival;
gotoBed.initAction = delegate
{
pawn.pather.StartPath(SleepSpot, PathEndMode.OnCell);
Partner.jobs.StopAll();
Job job = JobMaker.MakeJob(JobDefOf.GotoMindControlled, SleepSpot);
Partner.jobs.StartJob(job, JobCondition.InterruptForced);
};
gotoBed.FailOnDespawnedOrNull(iBed); //Changed from FailOnBedNoLongerUsable(iBed) due to pawn unable to use not owned bed.
gotoBed.AddFailCondition(() => Partner.Downed);
yield return gotoBed;
var waitInBed = new Toil();
waitInBed.defaultCompleteMode = ToilCompleteMode.Delay;
waitInBed.initAction = delegate
{
ticksLeftThisToil = 5000;
};
waitInBed.tickAction = delegate
{
pawn.GainComfortFromCellIfPossible();
if (IsInOrByBed(Bed, Partner) && pawn.PositionHeld == Partner.PositionHeld)
{
ReadyForNextToil();
}
};
waitInBed.FailOn(() => pawn.GetRoom(RegionType.Set_Passable) == null);
yield return waitInBed;
var StartPartnerJob = new Toil();
StartPartnerJob.defaultCompleteMode = ToilCompleteMode.Instant;
StartPartnerJob.socialMode = RandomSocialMode.Off;
StartPartnerJob.initAction = delegate
{
var gettin_loved = JobMaker.MakeJob(PartnerJob, pawn, Bed);
Partner.jobs.StartJob(gettin_loved, JobCondition.InterruptForced);
};
yield return StartPartnerJob;
var SexToil = new Toil();
SexToil.defaultCompleteMode = ToilCompleteMode.Never;
SexToil.socialMode = RandomSocialMode.Off;
SexToil.handlingFacing = true;
SexToil.initAction = delegate
{
Start();
// TODO: replace this quick n dirty way
CondomUtility.GetCondomFromRoom(pawn);
// Try to use whore's condom first, then client's
Sexprops.usedCondom = CondomUtility.TryUseCondom(pawn) || CondomUtility.TryUseCondom(Partner);
if (Sexprops.usedCondom)
{
var receiverDriver = Partner?.jobs?.curDriver as JobDriver_SexBaseReciever;
if (receiverDriver is not null && receiverDriver.Sexprops != null)
receiverDriver.Sexprops.usedCondom = true;
}
};
SexToil.FailOn(() => Partner.Dead);
SexToil.FailOn(() => Partner.CurJob?.def != PartnerJob);
SexToil.AddPreTickAction(delegate
{
if (pawn.IsHashIntervalTick(ticks_between_hearts))
if (xxx.is_zoophile(pawn))
ThrowMetaIconF(pawn.Position, pawn.Map, FleckDefOf.Heart);
else
ThrowMetaIconF(pawn.Position, pawn.Map, xxx.mote_noheart);
SexTick(pawn, Partner);
SexUtility.reduce_rest(Partner, 2);
SexUtility.reduce_rest(pawn, 1);
if (ticks_left <= 0)
ReadyForNextToil();
});
SexToil.AddFinishAction(End);
yield return SexToil;
yield return new Toil
{
initAction = () => SexUtility.ProcessSex(Sexprops),
defaultCompleteMode = ToilCompleteMode.Instant
};
}
}
}
| Korth95/rjw | 1.5/Source/JobDrivers/JobDriver_BestialityForFemale.cs | C# | mit | 3,923 |
using System.Collections.Generic;
using System.Linq;
using RimWorld;
using Verse;
using Verse.AI;
using Multiplayer.API;
namespace rjw
{
public class JobDriver_BestialityForMale : JobDriver_Rape
{
public override bool TryMakePreToilReservations(bool errorOnFailed)
{
return pawn.Reserve(Target, job, 1, 0, null, errorOnFailed);
}
[SyncMethod]
protected override IEnumerable<Toil> MakeNewToils()
{
//--ModLog.Message(" JobDriver_BestialityForMale::MakeNewToils() called");
setup_ticks();
var PartnerJob = xxx.gettin_bred;
//this.FailOn (() => (!Partner.health.capacities.CanBeAwake) || (!comfort_prisoners.is_designated (Partner)));
// Fail if someone else reserves the prisoner before the pawn arrives or colonist can't reach animal
this.FailOn(() => !pawn.CanReserveAndReach(Partner, PathEndMode.Touch, Danger.Deadly));
this.FailOn(() => Partner.HostileTo(pawn));
this.FailOnDespawnedNullOrForbidden(iTarget);
this.FailOn(() => pawn.Drafted);
yield return Toils_Reserve.Reserve(iTarget, 1, 0);
//ModLog.Message(" JobDriver_BestialityForMale::MakeNewToils() - moving towards animal");
yield return Toils_Goto.GotoThing(iTarget, PathEndMode.Touch);
yield return Toils_Interpersonal.WaitToBeAbleToInteract(pawn);
yield return Toils_Interpersonal.GotoInteractablePosition(iTarget);
if (xxx.is_kind(pawn)
|| (xxx.CTIsActive && xxx.has_traits(pawn) && pawn.story.traits.HasTrait(xxx.RCT_AnimalLover)))
{
yield return TalkToAnimal(pawn, Partner);
yield return TalkToAnimal(pawn, Partner);
}
if (Rand.Chance(0.6f))
yield return TalkToAnimal(pawn, Partner);
yield return Toils_Goto.GotoThing(iTarget, PathEndMode.OnCell);
SexUtility.RapeTargetAlert(pawn, Partner);
Toil StartPartnerJob = new Toil();
StartPartnerJob.defaultCompleteMode = ToilCompleteMode.Instant;
StartPartnerJob.socialMode = RandomSocialMode.Off;
StartPartnerJob.initAction = delegate
{
//--ModLog.Message(" JobDriver_BestialityForMale::MakeNewToils() - Setting animal job driver");
var dri = Partner.jobs.curDriver as JobDriver_SexBaseRecieverRaped;
if (dri == null)
{
//wild animals may flee or attack
if (pawn.Faction != Partner.Faction && Partner.RaceProps.wildness > Rand.Range(0.22f, 1.0f)
&& !(pawn.TicksPerMoveCardinal < (Partner.TicksPerMoveCardinal / 2) && !Partner.Downed && xxx.is_not_dying(Partner)))
{
Partner.jobs.StopAll(); // Wake up animal if sleeping.
float aggro = Partner.kindDef.RaceProps.manhunterOnTameFailChance;
if (Partner.kindDef.RaceProps.predator)
aggro += 0.2f;
else
aggro -= 0.1f;
//wild animals may attack
if (Rand.Chance(aggro) && Partner.CanSee(pawn))
{
Partner.rotationTracker.FaceTarget(pawn);
LifeStageUtility.PlayNearestLifestageSound(Partner, (ls) => ls.soundAngry, null,null, 1.4f);
ThrowMetaIconF(Partner.Position, Partner.Map, FleckDefOf.IncapIcon);
ThrowMetaIcon(pawn.Position, pawn.Map, ThingDefOf.Mote_ColonistFleeing); //red '!'
Partner.mindState.mentalStateHandler.TryStartMentalState(MentalStateDefOf.Manhunter);
if (Partner.kindDef.RaceProps.herdAnimal && Rand.Chance(0.2f))
{ // 20% chance of turning the whole herd hostile...
List<Pawn> packmates = Partner.Map.mapPawns.AllPawnsSpawned.Where(x =>
x != Partner && x.def == Partner.def && x.Faction == Partner.Faction &&
x.Position.InHorDistOf(Partner.Position, 24f) && x.CanSee(Partner)).ToList();
foreach (Pawn packmate in packmates)
{
packmate.mindState.mentalStateHandler.TryStartMentalState(MentalStateDefOf.Manhunter);
}
}
Messages.Message(pawn.Name.ToStringShort + " is being attacked by " + xxx.get_pawnname(Partner) + ".", pawn, MessageTypeDefOf.ThreatSmall);
}
//wild animals may flee
else
{
ThrowMetaIcon(Partner.Position, Partner.Map, ThingDefOf.Mote_ColonistFleeing);
LifeStageUtility.PlayNearestLifestageSound(Partner, (ls) => ls.soundCall, g => g.soundCall, null);
Partner.mindState.StartFleeingBecauseOfPawnAction(pawn);
Partner.mindState.mentalStateHandler.TryStartMentalState(MentalStateDefOf.PanicFlee);
}
pawn.jobs.EndCurrentJob(JobCondition.Incompletable);
}
else
{
Job gettin_bred = JobMaker.MakeJob(PartnerJob, pawn, Partner);
Partner.jobs.StartJob(gettin_bred, JobCondition.InterruptForced, null, true);
}
}
};
yield return StartPartnerJob;
Toil SexToil = new Toil();
SexToil.defaultCompleteMode = ToilCompleteMode.Never;
SexToil.defaultDuration = duration;
SexToil.handlingFacing = true;
SexToil.FailOn(() => Partner.CurJob?.def != PartnerJob);
SexToil.initAction = delegate
{
Partner.pather.StopDead();
Partner.jobs.curDriver.asleep = false;
Start();
};
SexToil.tickAction = delegate
{
if (pawn.IsHashIntervalTick(ticks_between_hearts))
if (xxx.is_zoophile(pawn))
ThrowMetaIconF(pawn.Position, pawn.Map, FleckDefOf.Heart);
else
ThrowMetaIconF(pawn.Position, pawn.Map, xxx.mote_noheart);
SexTick(pawn, Partner);
//no hitting wild animals, and getting rect by their Manhunter
/*
if (pawn.IsHashIntervalTick (ticks_between_hits))
roll_to_hit (pawn, Partner);
*/
SexUtility.reduce_rest(Partner, 1);
SexUtility.reduce_rest(pawn, 2);
if (ticks_left <= 0)
ReadyForNextToil();
};
SexToil.AddFinishAction(delegate
{
End();
});
yield return SexToil;
yield return new Toil
{
initAction = delegate
{
//ModLog.Message(" JobDriver_BestialityForMale::MakeNewToils() - creating aftersex toil");
SexUtility.ProcessSex(Sexprops);
},
defaultCompleteMode = ToilCompleteMode.Instant
};
}
[SyncMethod]
private Toil TalkToAnimal(Pawn pawn, Pawn animal)
{
Toil toil = new Toil();
toil.initAction = delegate
{
pawn.interactions.TryInteractWith(animal, SexUtility.AnimalSexChat);
};
//Rand.PopState();
//Rand.PushState(RJW_Multiplayer.PredictableSeed());
toil.defaultCompleteMode = ToilCompleteMode.Delay;
toil.defaultDuration = Rand.Range(120, 220);
return toil;
}
}
}
| Korth95/rjw | 1.5/Source/JobDrivers/JobDriver_BestialityForMale.cs | C# | mit | 6,282 |
using System.Collections.Generic;
using RimWorld;
using Verse;
using Verse.AI;
using Multiplayer.API;
namespace rjw
{
/// <summary>
/// This is the driver for animals mounting breeders.
/// </summary>
public class JobDriver_Breeding : JobDriver_Rape
{
public override bool TryMakePreToilReservations(bool errorOnFailed)
{
return pawn.Reserve(Target, job, BreederHelper.max_animals_at_once, 0);
}
[SyncMethod]
protected override IEnumerable<Toil> MakeNewToils()
{
setup_ticks();
var PartnerJob = xxx.gettin_raped;
//--Log.Message("JobDriver_Breeding::MakeNewToils() - setting fail conditions");
this.FailOnDespawnedNullOrForbidden(iTarget);
this.FailOn(() => !pawn.CanReserve(Partner, BreederHelper.max_animals_at_once, 0)); // Fail if someone else reserves the target before the animal arrives.
this.FailOn(() => !pawn.CanReach(Partner, PathEndMode.Touch, Danger.Some)); // Fail if animal cannot reach target.
this.FailOn(() => pawn.Drafted);
// Path to target
yield return Toils_Goto.GotoThing(iTarget, PathEndMode.OnCell);
//if (!(pawn.IsDesignatedBreedingAnimal() && Partner.IsDesignatedBreeding()));
if (!(pawn.IsAnimal() && Partner.IsAnimal()))
SexUtility.RapeTargetAlert(pawn, Partner);
var StartPartnerJob = new Toil();
StartPartnerJob.defaultCompleteMode = ToilCompleteMode.Instant;
StartPartnerJob.socialMode = RandomSocialMode.Off;
StartPartnerJob.initAction = delegate
{
if (Partner.jobs.curDriver is JobDriver_SexBaseRecieverRaped) return;
var bed = Partner.CurrentBed();
Partner.jobs.StartJob(
JobMaker.MakeJob(PartnerJob, pawn),
lastJobEndCondition: JobCondition.InterruptForced
);
if (bed is not null)
if (Partner.jobs.curDriver is JobDriver_SexBaseRecieverRaped driver)
driver.Set_bed(bed);
};
yield return StartPartnerJob;
// Use happy heart instead of bad-touch heart when accepting of breeding.
var fleckDef = xxx.is_zoophile(pawn) || xxx.is_animal(pawn) ? FleckDefOf.Heart : xxx.mote_noheart;
// Breed target
var SexToil = new Toil();
SexToil.defaultCompleteMode = ToilCompleteMode.Never;
SexToil.defaultDuration = duration;
SexToil.handlingFacing = true;
SexToil.initAction = delegate
{
Partner.pather.StopDead();
Partner.jobs.curDriver.asleep = false;
Start();
};
SexToil.tickAction = delegate
{
if (pawn.IsHashIntervalTick(ticks_between_hearts))
ThrowMetaIconF(pawn.Position, pawn.Map, fleckDef);
SexTick(pawn, Partner);
if (!Partner.Dead)
SexUtility.reduce_rest(Partner, 1);
SexUtility.reduce_rest(pawn, 2);
if (ticks_left <= 0)
ReadyForNextToil();
};
SexToil.FailOn(() => Partner.CurJob?.def != PartnerJob);
SexToil.AddFinishAction(End);
yield return SexToil;
yield return new Toil
{
initAction = delegate
{
//Log.Message("JobDriver_Breeding::MakeNewToils() - Calling aftersex");
//// Trying to add some interactions and social logs
Sexprops.isRape = !(pawn.relations.DirectRelationExists(PawnRelationDefOf.Bond, Partner) ||
(xxx.is_animal(pawn) && (pawn.RaceProps.wildness - pawn.RaceProps.petness + 0.18f) > Rand.Range(0.36f, 1.8f)));
SexUtility.ProcessSex(Sexprops);
},
defaultCompleteMode = ToilCompleteMode.Instant
};
}
}
}
| Korth95/rjw | 1.5/Source/JobDrivers/JobDriver_Breeding.cs | C# | mit | 3,335 |
using RimWorld;
using System.Collections.Generic;
using UnityEngine;
using Verse;
using Verse.AI;
namespace rjw
{
//biotech JobDriver_ControlMech
public class JobDriver_HackMechPregnancy : JobDriver
{
private const TargetIndex MechInd = TargetIndex.A;
private Pawn Mech => (Pawn)job.GetTarget(TargetIndex.A).Thing;
private int MechControlTime => Mathf.RoundToInt(Mech.GetStatValue(StatDefOf.ControlTakingTime) * 60f);
public override bool TryMakePreToilReservations(bool errorOnFailed)
{
return pawn.Reserve(Mech, job, 1, -1, null, errorOnFailed);
}
protected override IEnumerable<Toil> MakeNewToils()
{
if (ModsConfig.BiotechActive)
{
this.FailOnDestroyedNullOrForbidden(TargetIndex.A);
yield return Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.Touch);
yield return Toils_General.WaitWith(TargetIndex.A, MechControlTime, useProgressBar: true, maintainPosture: true, maintainSleep: false, TargetIndex.A).WithEffect(EffecterDefOf.ControlMech, TargetIndex.A);
Toil toil = ToilMaker.MakeToil("MakeNewToils");
toil.initAction = delegate
{
Hediff_MechanoidPregnancy pregnancy = (Hediff_MechanoidPregnancy)Mech.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("RJW_pregnancy_mech"));
pregnancy.Hack();
};
toil.PlaySoundAtEnd(SoundDefOf.ControlMech_Complete);
yield return toil;
}
}
}
} | Korth95/rjw | 1.5/Source/JobDrivers/JobDriver_HackMechPregnancy.cs | C# | mit | 1,371 |
using System;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using RimWorld;
using Verse;
using Verse.AI;
namespace rjw
{
public class JobDriver_Knotted : JobDriver_Goto
{
/// <summary>
/// Number of ticks to smooth out the start and end transitions.
/// </summary>
const int TweenTicks = 10;
/// <summary>
/// The pawn's partner.
/// </summary>
public Pawn Partner => job.GetTarget(TargetIndex.A).Pawn;
/// <summary>
/// Set this to apply a positional offset to this pawn.
/// </summary>
private Vector3 forcedBodyOffset = Vector3.zero;
public override Vector3 ForcedBodyOffset => forcedBodyOffset;
protected override IEnumerable<Toil> MakeNewToils()
{
if (job.def.waitAfterArriving <= 0)
yield break;
var waiter = Toils_General.Wait(job.def.waitAfterArriving);
// TODO: Deal with clothing better. If the pawn was fucking without
// clothes, they should still be drawn nude. Since tying is a separate
// job and we don't know if this was something like an animal "breeding"
// someone in their clothing, it isn't straightforward to tell when
// they should remain nude. This is probably a sign this should not
// have been a separate job but actually an extra toil of sex jobs.
// Just in case. Animals may only pant, whine, or tug during a tie...
if (xxx.is_animal(pawn))
waiter.socialMode = RandomSocialMode.Off;
// We should have a partner set. If we don't, use fallback behavior
// of just waiting (which is how knotting used to work), with none
// of the partner related enhancements.
if (Partner is not Pawn partner)
{
ModLog.Warning($"Knotting job for {xxx.get_pawnname(pawn)} did not receive a partner.");
yield return waiter;
yield break;
}
this.FailOnDespawnedOrNull(TargetIndex.A);
this.FailOnDowned(TargetIndex.A);
// Detect when the tie breaks early. This can happen for a number of
// reasons, but I often saw it when an animal starts being trained
// during the tie.
this.FailOn(() => !IsCouplingValid());
// If another mod patches this method, they can use it to add more
// complex animation or positioning to the waiter.
AddAnimation(waiter);
yield return waiter;
}
/// <summary>
/// <para>Applies some special animaion handling during the tie.</para>
/// <para>Animation systems can patch this to attach their own actions to
/// enable more complex animation.</para>
/// </summary>
/// <param name="waiter">The wait toil.</param>
void AddAnimation(Toil waiter)
{
if (Partner is not Pawn partner) return;
// Only if the tie involves an animal will we turn the tie butt-to-butt.
// Human-likes with knots will just hold their partner close. <3
if (!InvolvesAnimal()) return;
var initTicks = waiter.defaultDuration;
var remTicks = initTicks;
waiter.handlingFacing = true;
waiter.AddPreTickAction(delegate ()
{
pawn.rotationTracker.Face(partner.DrawPos);
pawn.Rotation = pawn.Rotation.Opposite;
var newOffset = GetOffset();
if (newOffset == Vector3.zero) return;
// Tween the offset at the start and end.
// Can't really smooth it out for an interrupted tie, though.
var tweenTicks = Math.Min(TweenTicks, Math.Min(initTicks - remTicks, remTicks));
var curTween = (float)tweenTicks / TweenTicks;
forcedBodyOffset = newOffset * curTween;
remTicks -= 1;
});
}
/// <summary>
/// Gets an offset for the current pawn to improve the visuals.
/// </summary>
/// <returns>An offset to apply.</returns>
public Vector3 GetOffset()
{
// Must be an animal.
if (!xxx.is_animal(pawn))
return Vector3.zero;
// Partner must exist and be human.
if (Partner is not Pawn partner || xxx.is_animal(partner))
return Vector3.zero;
// Only applicable for east or west facings.
if (pawn.Rotation != Rot4.East && pawn.Rotation != Rot4.West)
return Vector3.zero;
// Nudge the animal for a better lineup.
var offset = partner.BodySize * 0.15f;
var sign = pawn.Rotation == Rot4.West ? -1f : 1f;
return new Vector3(sign * offset, 0f, -0.2f);
}
/// <summary>
/// Whether this tie involves at least one animal.
/// </summary>
/// <returns>Whether the partner and/or pawn is an animal.</returns>
public bool InvolvesAnimal() => xxx.is_animal(pawn) || xxx.is_animal(Partner);
/// <summary>
/// <para>Makes sure that the designated partner is still coupled to this pawn.</para>
/// <para>For hardiness, this actually checks the partner pawn to see if they're
/// using either `JobDriver_Sex` or `JobDriver_Knotted`, and the partner is still
/// this pawn.</para>
/// </summary>
/// <returns>Whether the coupling is valid.</returns>
public bool IsCouplingValid()
{
if (Partner is not Pawn partner) return false;
var result = partner.jobs.curDriver switch
{
JobDriver_Knotted knottedDriver => knottedDriver.Partner == pawn,
JobDriver_Sex sexDriver => sexDriver.Partner == pawn,
_ => false
};
if (result) return true;
// It's possible our partner is queued to tie, but between jobs.
if (partner.jobs.jobQueue.FirstOrDefault()?.job is not { } job) return false;
if (job.def != xxx.knotted) return false;
return job.AnyTargetIs(pawn);
}
}
}
| Korth95/rjw | 1.5/Source/JobDrivers/JobDriver_Knotted.cs | C# | mit | 5,321 |
using System.Collections.Generic;
using RimWorld;
using Verse;
using Verse.AI;
using Multiplayer.API;
namespace rjw
{
public class JobDriver_Masturbate : JobDriver_SexBaseInitiator
{
public override bool TryMakePreToilReservations(bool errorOnFailed)
{
return true; // No reservations needed.
}
public virtual IntVec3 cell => (IntVec3)job.GetTarget(iCell);
[SyncMethod]
protected override void SetupDurationTicks()
{
// Faster fapping when frustrated.
duration = (int)(xxx.is_frustrated(pawn) ? 2500.0f * Rand.Range(0.2f, 0.7f) : 2500.0f * Rand.Range(0.2f, 0.4f));
ticks_left = duration;
}
protected override void SetupOrgasmTicks()
{
orgasmstick = 180;
sex_ticks = duration;
orgasmStartTick = sex_ticks;
}
protected override IEnumerable<Toil> MakeNewToils()
{
setup_ticks();
//this.FailOn(() => PawnUtility.PlayerForcedJobNowOrSoon(pawn));
this.FailOn(() => pawn.health.Downed);
this.FailOn(() => pawn.IsBurning());
this.FailOn(() => pawn.IsFighting());
this.FailOn(() => pawn.Drafted);
Toil findfapspot = new Toil
{
initAction = delegate
{
pawn.pather.StartPath(cell, PathEndMode.OnCell);
},
defaultCompleteMode = ToilCompleteMode.PatherArrival
};
yield return findfapspot;
//ModLog.Message(" Making new toil for QuickFap.");
Toil SexToil = Toils_General.Wait(duration);
SexToil.handlingFacing = true;
SexToil.initAction = delegate
{
Start();
};
SexToil.tickAction = delegate
{
if (pawn.IsHashIntervalTick(ticks_between_hearts))
ThrowMetaIconF(pawn.Position, pawn.Map, FleckDefOf.Heart);
SexTick(pawn, null);
SexUtility.reduce_rest(pawn, 1);
if (ticks_left <= 0)
ReadyForNextToil();
};
SexToil.AddFinishAction(delegate
{
End();
});
yield return SexToil;
yield return new Toil
{
initAction = delegate
{
SexUtility.Aftersex(Sexprops);
if (!SexUtility.ConsiderCleaning(pawn)) return;
LocalTargetInfo own_cum = pawn.PositionHeld.GetFirstThing<Filth>(pawn.Map);
Job clean = JobMaker.MakeJob(JobDefOf.Clean);
clean.AddQueuedTarget(TargetIndex.A, own_cum);
pawn.jobs.jobQueue.EnqueueFirst(clean);
},
defaultCompleteMode = ToilCompleteMode.Instant
};
}
}
}
| Korth95/rjw | 1.5/Source/JobDrivers/JobDriver_Masturbate.cs | C# | mit | 2,294 |
using System.Collections.Generic;
using RimWorld;
using Verse;
using Verse.AI;
using Multiplayer.API;
namespace rjw
{
/// <summary>
/// This is the driver for animals mating.
/// </summary>
public class JobDriver_Mating : JobDriver_Rape
{
public override bool TryMakePreToilReservations(bool errorOnFailed)
{
return pawn.Reserve(Target, job, BreederHelper.max_animals_at_once, 0, null, errorOnFailed);
}
[SyncMethod]
protected override IEnumerable<Toil> MakeNewToils()
{
setup_ticks();
var partnerJob = xxx.gettin_loved;
//--Log.Message("JobDriver_Mating::MakeNewToils() - setting fail conditions");
this.FailOnDespawnedNullOrForbidden(iTarget);
this.FailOn(() => !pawn.CanReserve(Partner, BreederHelper.max_animals_at_once, 0)); // Fail if someone else reserves the target before the animal arrives.
this.FailOn(() => !pawn.CanReach(Partner, PathEndMode.Touch, Danger.Some)); // Fail if animal cannot reach target.
this.FailOn(() => pawn.Drafted);
// Path to target
yield return Toils_Goto.GotoThing(iTarget, PathEndMode.OnCell);
var startPartnerJob = new Toil();
startPartnerJob.defaultCompleteMode = ToilCompleteMode.Instant;
startPartnerJob.socialMode = RandomSocialMode.Off;
startPartnerJob.initAction = delegate
{
if (Partner.jobs.curDriver is JobDriver_SexBaseRecieverLoved) return;
var bed = Partner.CurrentBed();
Partner.jobs.StartJob(
JobMaker.MakeJob(partnerJob, pawn),
JobCondition.InterruptForced
);
if (bed is not null)
if (Partner.jobs.curDriver is JobDriver_SexBaseRecieverLoved driver)
driver.Set_bed(bed);
};
yield return startPartnerJob;
// Mate target
var sexToil = new Toil();
sexToil.defaultCompleteMode = ToilCompleteMode.Never;
sexToil.defaultDuration = duration;
sexToil.handlingFacing = true;
sexToil.initAction = delegate
{
Partner.pather.StopDead();
Partner.jobs.curDriver.asleep = false;
Start();
if (xxx.is_human(Partner))
Sexprops.usedCondom = CondomUtility.TryUseCondom(Partner);
if (Sexprops.usedCondom)
{
var receiverDriver = Partner?.jobs?.curDriver as JobDriver_SexBaseReciever;
if (receiverDriver is not null && receiverDriver.Sexprops != null)
receiverDriver.Sexprops.usedCondom = true;
}
};
sexToil.tickAction = delegate
{
if (pawn.IsHashIntervalTick(ticks_between_hearts))
ThrowMetaIconF(pawn.Position, pawn.Map, FleckDefOf.Heart);
SexTick(pawn, Partner);
if (!Partner.Dead)
SexUtility.reduce_rest(Partner, 1);
SexUtility.reduce_rest(pawn, 2);
if (ticks_left <= 0)
ReadyForNextToil();
};
sexToil.FailOn(() => Partner.CurJob?.def != partnerJob);
sexToil.AddFinishAction(End);
yield return sexToil;
yield return new Toil
{
initAction = () => SexUtility.ProcessSex(Sexprops),
defaultCompleteMode = ToilCompleteMode.Instant
};
}
}
}
| Korth95/rjw | 1.5/Source/JobDrivers/JobDriver_Mating.cs | C# | mit | 2,935 |
using System;
using System.Collections.Generic;
using RimWorld;
using Verse;
using Verse.AI;
namespace rjw
{
public class JobDriver_Rape : JobDriver_SexBaseInitiator
{
public override bool TryMakePreToilReservations(bool errorOnFailed)
{
return pawn.Reserve(Target, job, xxx.max_rapists_per_prisoner, 0, null, errorOnFailed);
}
protected override IEnumerable<Toil> MakeNewToils()
{
if (RJWSettings.DebugRape) ModLog.Message("" + this.GetType().ToString() + "::MakeNewToils() called");
setup_ticks();
var PartnerJob = xxx.gettin_raped;
this.FailOnDespawnedNullOrForbidden(iTarget);
this.FailOn(() => !pawn.CanReserve(Partner, xxx.max_rapists_per_prisoner, 0)); // Fail if someone else reserves the prisoner before the pawn arrives
this.FailOn(() => pawn.IsFighting());
this.FailOn(() => Partner.IsFighting());
this.FailOn(() => pawn.Drafted);
yield return Toils_Goto.GotoThing(iTarget, PathEndMode.OnCell);
SexUtility.RapeTargetAlert(pawn, Partner);
var StartPartnerJob = new Toil();
StartPartnerJob.defaultCompleteMode = ToilCompleteMode.Instant;
StartPartnerJob.socialMode = RandomSocialMode.Off;
StartPartnerJob.initAction = delegate
{
if (Partner.jobs.curDriver is JobDriver_SexBaseRecieverRaped) return;
var bed = Partner.CurrentBed();
Partner.jobs.StartJob(
JobMaker.MakeJob(PartnerJob, pawn),
lastJobEndCondition: JobCondition.InterruptForced
);
if (bed is not null)
if (Partner.jobs.curDriver is JobDriver_SexBaseRecieverRaped driver)
driver.Set_bed(bed);
};
yield return StartPartnerJob;
var SexToil = new Toil();
SexToil.defaultCompleteMode = ToilCompleteMode.Never;
SexToil.defaultDuration = duration;
SexToil.handlingFacing = true;
SexToil.initAction = delegate
{
Partner.pather.StopDead();
Partner.jobs.curDriver.asleep = false;
if (RJWSettings.rape_stripping && (Partner.IsColonist || pawn.IsColonist))
Partner.Strip();
Start();
};
SexToil.tickAction = delegate
{
if (pawn.IsHashIntervalTick(ticks_between_hearts))
ThrowMetaIconF(pawn.Position, pawn.Map, FleckDefOf.Heart);
SexTick(pawn, Partner);
SexUtility.reduce_rest(Partner, 1);
SexUtility.reduce_rest(pawn, 2);
if (ticks_left <= 0)
ReadyForNextToil();
};
SexToil.FailOn(() => Partner.CurJob?.def != PartnerJob);
SexToil.AddFinishAction(End);
yield return SexToil;
yield return new Toil
{
initAction = () => SexUtility.ProcessSex(Sexprops),
defaultCompleteMode = ToilCompleteMode.Instant
};
}
}
}
| Korth95/rjw | 1.5/Source/JobDrivers/JobDriver_Rape.cs | C# | mit | 2,592 |
using System;
using System.Collections.Generic;
using RimWorld;
using Verse;
using Verse.AI;
namespace rjw
{
public class JobDriver_RapeComfortPawn : JobDriver_Rape
{
protected override IEnumerable<Toil> MakeNewToils()
{
if (RJWSettings.DebugRape) ModLog.Message("" + this.GetType().ToString() + "::MakeNewToils() called");
setup_ticks();
var PartnerJob = xxx.gettin_raped;
this.FailOnDespawnedNullOrForbidden(iTarget);
//this.FailOn(() => (!Partner.health.capacities.CanBeAwake) || (!comfort_prisoners.is_designated(Partner)));//this is wrong
this.FailOn(() => (!Partner.IsDesignatedComfort()));
this.FailOn(() => !pawn.CanReserve(Partner, xxx.max_rapists_per_prisoner, 0)); // Fail if someone else reserves the prisoner before the pawn arrives
this.FailOn(() => pawn.Drafted);
yield return Toils_Goto.GotoThing(iTarget, PathEndMode.OnCell);
SexUtility.RapeTargetAlert(pawn, Partner);
Toil StartPartnerJob = new Toil();
StartPartnerJob.defaultCompleteMode = ToilCompleteMode.Instant;
StartPartnerJob.socialMode = RandomSocialMode.Off;
StartPartnerJob.initAction = delegate
{
if (Partner.jobs.curDriver is JobDriver_SexBaseRecieverRaped) return;
var bed = Partner.CurrentBed();
Partner.jobs.StartJob(
JobMaker.MakeJob(PartnerJob, pawn),
lastJobEndCondition: JobCondition.InterruptForced
);
if (bed is not null)
if (Partner.jobs.curDriver is JobDriver_SexBaseRecieverRaped driver)
driver.Set_bed(bed);
};
yield return StartPartnerJob;
Toil SexToil = new Toil();
SexToil.defaultCompleteMode = ToilCompleteMode.Never;
SexToil.defaultDuration = duration;
SexToil.handlingFacing = true;
SexToil.initAction = delegate
{
Partner.pather.StopDead();
Partner.jobs.curDriver.asleep = false;
Start();
// Unlike normal rape try use comfort prisoner condom
CondomUtility.GetCondomFromRoom(Partner);
Sexprops.usedCondom = CondomUtility.TryUseCondom(Partner);
if (Sexprops.usedCondom)
{
var receiverDriver = Partner?.jobs?.curDriver as JobDriver_SexBaseReciever;
if (receiverDriver is not null && receiverDriver.Sexprops != null)
receiverDriver.Sexprops.usedCondom = true;
}
if (RJWSettings.DebugRape) ModLog.Message("JobDriver_RapeComfortPawn::MakeNewToils() - reserving prisoner");
//pawn.Reserve(Partner, xxx.max_rapists_per_prisoner, 0);
};
SexToil.tickAction = delegate
{
if (pawn.IsHashIntervalTick(ticks_between_hearts))
ThrowMetaIconF(pawn.Position, pawn.Map, FleckDefOf.Heart);
SexTick(pawn, Partner);
SexUtility.reduce_rest(Partner, 1);
SexUtility.reduce_rest(pawn, 2);
if (ticks_left <= 0)
ReadyForNextToil();
};
SexToil.FailOn(() => Partner.CurJob?.def != PartnerJob);
SexToil.AddFinishAction(End);
yield return SexToil;
yield return new Toil
{
initAction = delegate
{
// Trying to add some interactions and social logs
SexUtility.ProcessSex(Sexprops);
Partner.records.Increment(xxx.GetRapedAsComfortPawn);
},
defaultCompleteMode = ToilCompleteMode.Instant
};
}
}
}
| Korth95/rjw | 1.5/Source/JobDrivers/JobDriver_RapeComfortPawn.cs | C# | mit | 3,143 |
using System.Collections.Generic;
using RimWorld;
using Verse;
using Verse.AI;
using Verse.Sound;
namespace rjw
{
public class JobDriver_ViolateCorpse : JobDriver_Rape
{
public override bool TryMakePreToilReservations(bool errorOnFailed)
{
return pawn.Reserve(Target, job, 1, -1, null, errorOnFailed);
}
protected override IEnumerable<Toil> MakeNewToils()
{
if (RJWSettings.DebugRape) ModLog.Message(" JobDriver_ViolateCorpse::MakeNewToils() called");
setup_ticks();
this.FailOnDespawnedNullOrForbidden(iTarget);
this.FailOn(() => !pawn.CanReserve(Target, 1, 0)); // Fail if someone else reserves the prisoner before the pawn arrives
this.FailOn(() => pawn.IsFighting());
this.FailOn(() => pawn.Drafted);
this.FailOn(Target.IsBurning);
if (RJWSettings.DebugRape) ModLog.Message(" JobDriver_ViolateCorpse::MakeNewToils() - moving towards Target");
yield return Toils_Goto.GotoThing(iTarget, PathEndMode.OnCell);
var alert = RJWPreferenceSettings.rape_attempt_alert == RJWPreferenceSettings.RapeAlert.Disabled ?
MessageTypeDefOf.SilentInput : MessageTypeDefOf.NeutralEvent;
Messages.Message(xxx.get_pawnname(pawn) + " is trying to rape a corpse of " + xxx.get_pawnname(Partner), pawn, alert);
setup_ticks();// re-setup ticks on arrival
var SexToil = new Toil();
SexToil.defaultCompleteMode = ToilCompleteMode.Never;
SexToil.defaultDuration = duration;
SexToil.handlingFacing = true;
SexToil.initAction = delegate
{
if (RJWSettings.DebugRape) ModLog.Message(" JobDriver_ViolateCorpse::MakeNewToils() - stripping Target");
(Target as Corpse).Strip();
Start();
};
SexToil.tickAction = delegate
{
if (pawn.IsHashIntervalTick(ticks_between_hearts))
if (xxx.is_necrophiliac(pawn))
ThrowMetaIconF(pawn.Position, pawn.Map, FleckDefOf.Heart);
else
ThrowMetaIconF(pawn.Position, pawn.Map, xxx.mote_noheart);
//if (pawn.IsHashIntervalTick (ticks_between_hits))
// roll_to_hit (pawn, Target);
SexTick(pawn, Target);
SexUtility.reduce_rest(pawn, 2);
if (ticks_left <= 0)
ReadyForNextToil();
};
SexToil.AddFinishAction(delegate
{
End();
});
yield return SexToil;
yield return new Toil
{
initAction = delegate
{
if (RJWSettings.DebugRape) ModLog.Message(" JobDriver_ViolateCorpse::MakeNewToils() - creating aftersex toil");
SexUtility.ProcessSex(Sexprops);
},
defaultCompleteMode = ToilCompleteMode.Instant
};
}
}
} | Korth95/rjw | 1.5/Source/JobDrivers/JobDriver_RapeCorpse.cs | C# | mit | 2,510 |
using System;
using System.Collections.Generic;
using System.Linq;
using RimWorld;
using Verse;
using Verse.AI;
using Multiplayer.API;
namespace rjw
{
internal class JobDef_RapeEnemy : JobDef
{
public List<JobDef> interruptJobs;
public List<string> TargetDefNames = new List<string>();
public int priority = 0;
protected JobDriver_RapeEnemy instance
{
get
{
if (_tmpInstance == null)
{
_tmpInstance = (JobDriver_RapeEnemy)Activator.CreateInstance(driverClass);
}
return _tmpInstance;
}
}
private JobDriver_RapeEnemy _tmpInstance;
public override void ResolveReferences()
{
base.ResolveReferences();
interruptJobs = new List<JobDef> { null, JobDefOf.LayDown, JobDefOf.Wait_Wander, JobDefOf.GotoWander, JobDefOf.AttackMelee };
}
public virtual bool CanUseThisJobForPawn(Pawn rapist)
{
bool busy = !interruptJobs.Contains(rapist.CurJob?.def);
if (RJWSettings.DebugRape) ModLog.Message(" JobDef_RapeEnemy::CanUseThisJobForPawn( " + xxx.get_pawnname(rapist) + " ) - busy:" + busy + " with current job: " + rapist.CurJob?.def?.ToString());
if (busy) return false;
return instance.CanUseThisJobForPawn(rapist);// || TargetDefNames.Contains(rapist.def.defName);
}
public virtual Pawn FindVictim(Pawn rapist, Map m)
{
return instance.FindVictim(rapist, m);
}
}
public class JobDriver_RapeEnemy : JobDriver_Rape
{
//override can_rape mechanics
protected bool requireCanRape = true;
public virtual bool CanUseThisJobForPawn(Pawn rapist)
{
return xxx.is_human(rapist);
}
// this is probably useseless, maybe there be something in future
public virtual bool considerStillAliveEnemies => true;
[SyncMethod]
public virtual Pawn FindVictim(Pawn rapist, Map m)
{
if (RJWSettings.DebugRape) ModLog.Message($"{this.GetType().ToString()}::TryGiveJob({xxx.get_pawnname(rapist)}) map {m?.ToString()}");
if (rapist == null || m == null) return null;
if (RJWSettings.DebugRape) ModLog.Message($" can rape = {xxx.can_rape(rapist)}");
if (requireCanRape && !xxx.can_rape(rapist)) return null;
List<Pawn> validTargets = new List<Pawn>();
float min_fuckability = 0.10f; // Don't rape pawns with <10% fuckability
float avg_fuckability = 0f; // Average targets fuckability, choose target higher than that
var valid_targets = new Dictionary<Pawn, float>(); // Valid pawns and their fuckability
Pawn chosentarget = null; // Final target pawn
IEnumerable<Pawn> targets = m.mapPawns.AllPawnsSpawned.Where(x
=> !x.IsForbidden(rapist) && x != rapist && x.HostileTo(rapist)
&& IsValidTarget(rapist, x))
.ToList();
if (RJWSettings.DebugRape) ModLog.Message($" targets {targets.Count()}");
if (targets.Any(x => IsBlocking(rapist, x))) //If any of the targets is not downed and visible - don't proceed with rape (you have more pressing things to do).
{ //This is a bit whacky bearing in mind target selection. For example vulnerable pawns will block, but non-vulnearable will not
return null;
}
foreach (var target in targets)
{
if (!Pather_Utility.cells_to_target_rape(rapist, target.Position))
{
//if (RJWSettings.DebugRape) ModLog.Message($" {xxx.get_pawnname(target)} too far (cells) = {rapist.Position.DistanceToSquared(target.Position)}, skipping");
if (RJWSettings.DebugRape) ModLog.Message($" {xxx.get_pawnname(target)} too far (cells) = {rapist.Position.DistanceTo(target.Position)}, skipping");
continue;// too far
}
float fuc = GetFuckability(rapist, target);
if (fuc > min_fuckability)
{
if (Pather_Utility.can_path_to_target(rapist, target.Position))
valid_targets.Add(target, fuc);
else
if (RJWSettings.DebugRape) ModLog.Message($" {xxx.get_pawnname(target)} too far (path), skipping");
}
else
if (RJWSettings.DebugRape) ModLog.Message($" {xxx.get_pawnname(target)} fuckability too low = {fuc}, skipping");
}
if (RJWSettings.DebugRape) ModLog.Message($" fuckable targets {valid_targets.Count()}");
if (valid_targets.Any())
{
avg_fuckability = valid_targets.Average(x => x.Value);
if (RJWSettings.DebugRape) ModLog.Message($" avg_fuckability {avg_fuckability}");
// choose pawns to fuck with above average fuckability
var valid_targetsFiltered = valid_targets.Where(x => x.Value >= avg_fuckability);
if (RJWSettings.DebugRape) ModLog.Message($" targets above avg_fuckability {valid_targetsFiltered.Count()}");
if (valid_targetsFiltered.Any())
chosentarget = valid_targetsFiltered.RandomElement().Key;
}
return chosentarget;
}
bool IsBlocking(Pawn rapist, Pawn target)
{
return considerStillAliveEnemies && !target.Downed && rapist.CanSee(target);
}
bool IsValidTarget(Pawn rapist, Pawn target)
{
if (!RJWSettings.bestiality_enabled)
{
if (xxx.is_animal(target) && xxx.is_human(rapist))
{
//bestiality disabled, skip.
return false;
}
if (xxx.is_animal(rapist) && xxx.is_human(target))
{
//bestiality disabled, skip.
return false;
}
}
if (!RJWSettings.animal_on_animal_enabled)
if ((xxx.is_animal(target) && xxx.is_animal(rapist)))
{
//animal_on_animal disabled, skip.
return false;
}
if ((xxx.is_mechanoid(rapist) && xxx.is_animal(target)) || (xxx.is_animal(rapist) && xxx.is_mechanoid(target)))
return false; //no Mech on Animal action, ref JobDriver_RapeEnemyByMech::GetFuckability()
if (target.CurJob?.def == xxx.gettin_raped || target.CurJob?.def == xxx.gettin_loved)
{
//already having sex with someone, skip, give chance to other victims.
return false;
}
return Can_rape_Easily(target) &&
(xxx.is_human(target) || xxx.is_animal(target)) &&
rapist.CanReserveAndReach(target, PathEndMode.OnCell, Danger.Some, xxx.max_rapists_per_prisoner, 0);
}
public virtual float GetFuckability(Pawn rapist, Pawn target)
{
float fuckability = 0;
if (target.health.hediffSet.HasHediff(xxx.submitting)) // it's not about attractiveness anymore, it's about showing who's whos bitch
{
fuckability = 2 * SexAppraiser.would_fuck(rapist, target, invert_opinion: true, ignore_bleeding: true, ignore_gender: true);
}
else if (SexAppraiser.would_rape(rapist, target))
{
fuckability = SexAppraiser.would_fuck(rapist, target, invert_opinion: true, ignore_bleeding: true, ignore_gender: true);
}
if (RJWSettings.DebugRape) ModLog.Message($"JobDriver_RapeEnemy::GetFuckability({xxx.get_pawnname(rapist)}, {xxx.get_pawnname(target)})");
return fuckability;
}
protected bool Can_rape_Easily(Pawn pawn)
{
return xxx.can_get_raped(pawn) && !pawn.IsBurning();
}
}
}
| Korth95/rjw | 1.5/Source/JobDrivers/JobDriver_RapeEnemy.cs | C# | mit | 6,822 |
using RimWorld;
using Verse;
namespace rjw
{
internal class JobDriver_RapeEnemyByAnimal : JobDriver_RapeEnemy
{
public override bool CanUseThisJobForPawn(Pawn rapist)
{
if (rapist.CurJob != null && (rapist.CurJob.def != JobDefOf.LayDown || rapist.CurJob.def != JobDefOf.Wait_Wander || rapist.CurJob.def != JobDefOf.GotoWander))
return false;
return xxx.is_animal(rapist) && !xxx.is_insect(rapist);
}
}
} | Korth95/rjw | 1.5/Source/JobDrivers/JobDriver_RapeEnemyByAnimal.cs | C# | mit | 424 |
using RimWorld;
using Verse;
namespace rjw
{
internal class JobDriver_RapeEnemyByHumanlike : JobDriver_RapeEnemy
{
public override bool CanUseThisJobForPawn(Pawn rapist)
{
if (rapist.CurJob != null && (rapist.CurJob.def != JobDefOf.LayDown || rapist.CurJob.def != JobDefOf.Wait_Wander || rapist.CurJob.def != JobDefOf.GotoWander))
return false;
return xxx.is_human(rapist);
}
}
} | Korth95/rjw | 1.5/Source/JobDrivers/JobDriver_RapeEnemyByHumanlike.cs | C# | mit | 400 |
using System.Linq;
using RimWorld;
using Verse;
namespace rjw
{
internal class JobDriver_RapeEnemyByInsect : JobDriver_RapeEnemy
{
public override bool CanUseThisJobForPawn(Pawn rapist)
{
if (rapist.CurJob != null && (rapist.CurJob.def != JobDefOf.LayDown || rapist.CurJob.def != JobDefOf.Wait_Wander || rapist.CurJob.def != JobDefOf.GotoWander))
return false;
return xxx.is_insect(rapist);
}
public override float GetFuckability(Pawn rapist, Pawn target)
{
//Female plant Eggs to everyone.
//if (rapist.gender == Gender.Female) //Genital_Helper.has_ovipositorF(rapist);
//{
// //only rape when target dont have eggs yet
// //if ((from x in target.health.hediffSet.GetHediffs<Hediff_InsectEgg>() where (x.IsParent(rapist)) select x).Count() > 0)
// {
// return 1f;
// }
//}
////Male rape to everyone.
////Feritlize eggs to target with planted eggs.
//else //Genital_Helper.has_ovipositorM(rapist);
//{
// //only rape target when can fertilize
// //if ((from x in target.health.hediffSet.GetHediffs<Hediff_InsectEgg>() where (x.IsParent(rapist) && !x.fertilized) select x).Count() > 0)
// if ((from x in target.health.hediffSet.GetHediffs<Hediff_InsectEgg>() where x.IsParent(rapist) select x).Count() > 0)
// {
// return 1f;
// }
//}
return 1f;
}
}
} | Korth95/rjw | 1.5/Source/JobDrivers/JobDriver_RapeEnemyByInsect.cs | C# | mit | 1,343 |
using RimWorld;
using Verse;
namespace rjw
{
internal class JobDriver_RapeEnemyByMech : JobDriver_RapeEnemy
{
public override bool CanUseThisJobForPawn(Pawn rapist)
{
if (rapist.CurJob != null && (rapist.CurJob.def != JobDefOf.LayDown || rapist.CurJob.def != JobDefOf.Wait_Wander || rapist.CurJob.def != JobDefOf.GotoWander))
return false;
return xxx.is_mechanoid(rapist);
}
public override float GetFuckability(Pawn rapist, Pawn target)
{
//Plant stuff into humanlikes.
if (xxx.is_human(target))
return 1f;
else
return 0f;
}
}
} | Korth95/rjw | 1.5/Source/JobDrivers/JobDriver_RapeEnemyByMech.cs | C# | mit | 578 |
using RimWorld;
using Verse;
namespace rjw
{
internal class JobDriver_RapeEnemyToParasite : JobDriver_RapeEnemy
{
//not implemented
public JobDriver_RapeEnemyToParasite()
{
this.requireCanRape = false;
}
public override bool CanUseThisJobForPawn(Pawn rapist)
{
if (rapist.CurJob != null && (rapist.CurJob.def != JobDefOf.LayDown || rapist.CurJob.def != JobDefOf.Wait_Wander || rapist.CurJob.def != JobDefOf.GotoWander))
return false;
return false;
}
}
} | Korth95/rjw | 1.5/Source/JobDrivers/JobDriver_RapeEnemyToParasite.cs | C# | mit | 489 |
using System;
using System.Collections.Generic;
using RimWorld;
using Verse;
using Verse.AI;
using Verse.Sound;
namespace rjw
{
public class JobDriver_RandomRape : JobDriver_Rape
{
//Add some stuff. planning became bersek when failed to rape.
}
} | Korth95/rjw | 1.5/Source/JobDrivers/JobDriver_RapeRandom.cs | C# | mit | 256 |
using System.Collections.Generic;
using RimWorld;
using Verse;
using Verse.AI;
using Verse.Sound;
using Multiplayer.API;
using System.Linq;
using System;
namespace rjw
{
public abstract class JobDriver_Sex : JobDriver
{
public readonly TargetIndex iTarget = TargetIndex.A; //pawn or corpse
public readonly TargetIndex iBed = TargetIndex.B; //bed(maybe some furniture in future?)
public readonly TargetIndex iCell = TargetIndex.C; //cell/location to have sex at(fapping)
public float satisfaction = 1.0f;
public bool shouldreserve = true;
public int stackCount = 0;
public int ticks_between_hearts = 60;
public int ticks_between_hits = 60;
public int ticks_between_thrusts = 60;
public int ticks_left = 1000; //toil ticks
public int sex_ticks = 1000; //orgasm ticks
public int orgasms = 0;
// Sex ticks will decrease until it hits the orgasm tick, then orgasm happens and sex_ticks may be reset
// Sex continues for around 3 seconds
public int orgasmstick = 180; // ~3 sec
public int orgasmStartTick = 5000;
public int duration = 5000;
public bool face2face = false;
public bool isEndytophile = false;
public bool isAnimalOnAnimal = false;
public bool shouldGainFocus = false;
public bool shouldGainFocusP = false;
public bool isSuccubus = false;
public bool isSuccubusP = false;
//toggles
public bool beatings = false;// toggle on off, todo maybe?
public bool beatonce = false;
public bool neverendingsex = false;
public Thing Target // for reservation
{
get
{
if (job == null)
{
return null;
}
if (job.GetTarget(TargetIndex.A).Pawn != null)
return job.GetTarget(TargetIndex.A).Pawn;
return job.GetTarget(TargetIndex.A).Thing;
}
}
public Pawn Partner
{
get
{
if (PartnerPawn != null)
return PartnerPawn;
else if (Target is Pawn)
return job.GetTarget(TargetIndex.A).Pawn;
else if (Target is Corpse)
return (job.GetTarget(TargetIndex.A).Thing as Corpse).InnerPawn;
else
return null;
}
}
public Building_Bed Bed
{
get
{
if (pBed != null)
return pBed;
else if (job.GetTarget(TargetIndex.B).Thing is Building_Bed)
return job.GetTarget(TargetIndex.B).Thing as Building_Bed;
else
return null;
}
}
//not bed; chair, maybe something else in future
public Building Building
{
get
{
if (job.GetTarget(TargetIndex.B).Thing is Building && !(job.GetTarget(TargetIndex.B).Thing is Building_Bed))
return job.GetTarget(TargetIndex.B).Thing as Building;
else
return null;
}
}
public Pawn PartnerPawn = null;
public Building_Bed pBed = null;
public SexProps Sexprops = null;
[SyncMethod]
public void setup_ticks()
{
SetupDurationTicks();
SetupOrgasmTicks();
ticks_between_hearts = Rand.RangeInclusive(70, 130);
ticks_between_hits = Rand.Range(xxx.config.min_ticks_between_hits, xxx.config.max_ticks_between_hits);
if (xxx.is_bloodlust(pawn))
ticks_between_hits = (int)(ticks_between_hits * 0.75);
if (xxx.is_brawler(pawn))
ticks_between_hits = (int)(ticks_between_hits * 0.90);
ticks_between_thrusts = 120;
var EndConditions = this.ConditionsToAbortSex();
foreach (var condition in EndConditions)
{
this.AddFailCondition(condition);
}
}
public void Set_bed(Building_Bed newBed)
{
pBed = newBed;
}
public float OrgasmProgress {
get {
var orgasmDuration = orgasmStartTick - orgasmstick;
var ticksUntilOrgasm = sex_ticks - orgasmstick;
return 1f - (ticksUntilOrgasm / (float) orgasmDuration);
}
}
public override void ExposeData()
{
base.ExposeData();
Scribe_Values.Look(ref ticks_left, "ticks_left", 0, false);
Scribe_Values.Look(ref ticks_between_hearts, "ticks_between_hearts", 0, false);
Scribe_Values.Look(ref ticks_between_hits, "ticks_between_hits", 0, false);
Scribe_Values.Look(ref ticks_between_thrusts, "ticks_between_thrusts", 0, false);
Scribe_Values.Look(ref duration, "duration", 0, false);
Scribe_Values.Look(ref sex_ticks, "sex_ticks", 0, false);
Scribe_Values.Look(ref orgasms, "orgasms", 0, false);
Scribe_Values.Look(ref orgasmstick, "orgasmstick", 0, false);
Scribe_Values.Look(ref orgasmStartTick, "orgasmStartTick", 0, false);
Scribe_References.Look(ref pBed, "pBed");
Scribe_References.Look(ref PartnerPawn, "PartnerPawn");
Scribe_Deep.Look(ref Sexprops, "Sexprops", new SexProps[0]);
Scribe_Values.Look(ref beatings, "beatings");
Scribe_Values.Look(ref beatonce, "beatonce");
Scribe_Values.Look(ref neverendingsex, "neverendingsex");
Scribe_Values.Look(ref face2face, "face2face");
Scribe_Values.Look(ref isEndytophile, "isEndytophile");
Scribe_Values.Look(ref shouldGainFocus, "shouldGainFocus");
Scribe_Values.Look(ref shouldGainFocusP, "shouldGainFocusP");
Scribe_Values.Look(ref isSuccubus, "isSuccubus");
Scribe_Values.Look(ref isSuccubusP, "isSuccubusP");
}
public void SexTick(Pawn pawn, Thing target, bool pawnnude = true, bool partnernude = true)
{
ticks_left--;
sex_ticks--;
Orgasm();
var partner = target as Pawn;
if (partner != null)
{
if (partner.jobs?.curDriver is JobDriver_SexBaseReciever)//tick partner
{
((JobDriver_SexBaseReciever)partner.jobs.curDriver as JobDriver_SexBaseReciever).ticks_left--;
((JobDriver_SexBaseReciever)partner.jobs.curDriver as JobDriver_SexBaseReciever).sex_ticks--;
((JobDriver_SexBaseReciever)partner.jobs.curDriver as JobDriver_SexBaseReciever).Orgasm();
}
if (pawn.jobs?.curDriver is JobDriver_SexBaseInitiator)
{
var hit = false;
if (beatonce)
{
beatonce = false;
SexUtility.Sex_Beatings_Dohit(pawn, Partner, Sexprops.isRapist);
}
else if (pawn.IsHashIntervalTick(ticks_between_hits))
{
Roll_to_hit();
}
if (hit)
if (!isEndytophile)
{
SexUtility.DrawNude(pawn);
if (partner != null)
SexUtility.DrawNude(partner);
}
}
}
if (pawn.IsHashIntervalTick(ticks_between_thrusts))
{
ChangePsyfocus(pawn, partner);
Animate(pawn, partner);
PlaySexSound();
if (!Sexprops.isRape)
{
pawn.GainComfortFromCellIfPossible();
if (partner != null)
partner.GainComfortFromCellIfPossible();
}
}
}
/// <summary>
/// simple rjw thrust animation
/// </summary>
public void Animate(Pawn pawn, Thing target)
{
RotatePawns(pawn, Partner);
//attack/ride 1x2 cell cocksleeve/dildo?
//if (Building != null)
// target = Building;
if (target != null)
{
pawn.Drawer.Notify_MeleeAttackOn(target);
var partner = target as Pawn;
if (partner != null && !Sexprops.isRapist)
partner.Drawer.Notify_MeleeAttackOn(pawn);
//refresh DrawNude after beating and Notify_MeleeAttackOn
// Endytophiles prefer clothed sex, everyone else gets nude.
if (!isEndytophile)
{
SexUtility.DrawNude(pawn);
if (partner != null)
SexUtility.DrawNude(partner);
}
}
else
{
//refresh DrawNude after beating and Notify_MeleeAttackOn
// Endytophiles prefer clothed sex, everyone else gets nude.
if (!isEndytophile)
{
SexUtility.DrawNude(pawn);
}
}
}
/// <summary>
/// increase Psyfocus by having sex
/// </summary>
public void ChangePsyfocus(Pawn pawn, Thing target)
{
if (ModsConfig.RoyaltyActive)
{
if (pawn.jobs?.curDriver is JobDriver_ViolateCorpse)
if (xxx.is_necrophiliac(pawn) && MeditationFocusTypeAvailabilityCache.PawnCanUse(pawn, DefDatabase<MeditationFocusDef>.GetNamedSilentFail("Morbid")))
{
SexUtility.OffsetPsyfocus(pawn, 0.01f);
}
if (target != null)
{
var partner = target as Pawn;
if (partner != null)
{
if (shouldGainFocus)
SexUtility.OffsetPsyfocus(pawn, 0.01f);
if (shouldGainFocusP)
SexUtility.OffsetPsyfocus(partner, 0.01f);
if (isSuccubus)
SexUtility.OffsetPsyfocus(pawn, 0.01f);
if (isSuccubusP)
SexUtility.OffsetPsyfocus(partner, 0.01f);
}
}
}
}
/// <summary>
/// rotate pawns
/// </summary>
public void RotatePawns(Pawn pawn, Thing target)
{
if (Building != null)
{
if (face2face)
pawn.Rotation = Building.Rotation.Opposite;
else
pawn.Rotation = Building.Rotation;
return;
}
if (target == null) // solo
{
//pawn.Rotation = Rot4.South;
return;
}
if (target is not Pawn partner || partner.Dead) // necro
{
pawn.rotationTracker.Face(target.DrawPos);
return;
}
if (partner.jobs?.curDriver is JobDriver_SexBaseReciever receiverDriver)
if (receiverDriver.parteners.Count > 1)
return;
//maybe could do a hand check for monster girls but w/e
//bool partnerHasHands = Receiver.health.hediffSet.GetNotMissingParts().Any(part => part.IsInGroup(BodyPartGroupDefOf.RightHand) || part.IsInGroup(BodyPartGroupDefOf.LeftHand));
// most of animal sex is likely doggystyle.
if (isAnimalOnAnimal)
{
if (Sexprops.sexType == xxx.rjwSextype.Anal || Sexprops.sexType == xxx.rjwSextype.Vaginal || Sexprops.sexType == xxx.rjwSextype.DoublePenetration)
{
//>>
//Log.Message("animal doggy");
pawn.rotationTracker.Face(partner.DrawPos);
partner.Rotation = pawn.Rotation;
}
else
{
//><
//Log.Message("animal non doggy");
pawn.rotationTracker.Face(target.DrawPos);
partner.rotationTracker.Face(pawn.DrawPos);
}
}
else
{
if (this is JobDriver_BestialityForFemale)
{
if (Sexprops.sexType == xxx.rjwSextype.Anal || Sexprops.sexType == xxx.rjwSextype.Vaginal || Sexprops.sexType == xxx.rjwSextype.DoublePenetration)
{
//<<
//Log.Message("bestialityFF doggy");
partner.rotationTracker.Face(pawn.DrawPos);
pawn.Rotation = partner.Rotation;
}
else
{
//><
//Log.Message("bestialityFF non doggy");
pawn.rotationTracker.Face(target.DrawPos);
partner.rotationTracker.Face(pawn.DrawPos);
}
}
else if (partner.GetPosture() == PawnPosture.LayingInBed)
{
//x^
//Log.Message("loving/casualsex in bed");
// this could use better handling for cowgirl/reverse cowgirl and who pen who, if such would be implemented
//until then...
if (!face2face && Sexprops.sexType == xxx.rjwSextype.Anal ||
Sexprops.sexType == xxx.rjwSextype.Vaginal ||
Sexprops.sexType == xxx.rjwSextype.DoublePenetration ||
Sexprops.sexType == xxx.rjwSextype.Fisting)
//if (xxx.is_female(pawn) && xxx.is_female(partner))
{
// in bed loving face down
pawn.Rotation = partner.CurrentBed().Rotation.Opposite;
}
//else if (!(xxx.is_male(pawn) && xxx.is_male(partner)))
//{
// // in bed loving face down
// pawn.Rotation = partner.CurrentBed().Rotation.Opposite;
//}
else
{
// in bed loving, face up
pawn.Rotation = partner.CurrentBed().Rotation;
}
}
// 30% chance of face-to-face regardless, for variety.
else if (!face2face && (Sexprops.sexType == xxx.rjwSextype.Anal ||
Sexprops.sexType == xxx.rjwSextype.Vaginal ||
Sexprops.sexType == xxx.rjwSextype.DoublePenetration ||
Sexprops.sexType == xxx.rjwSextype.Fisting))
{
//>>
//Log.Message("doggy");
pawn.rotationTracker.Face(target.DrawPos);
partner.Rotation = pawn.Rotation;
}
// non doggystyle, or face-to-face regardless
else
{
//><
//Log.Message("non doggy");
pawn.rotationTracker.Face(target.DrawPos);
partner.rotationTracker.Face(pawn.DrawPos);
}
}
}
[SyncMethod]
public void Rollface2face(float chance = 0.3f)
{
Setface2face(Rand.Chance(chance));
}
public void Setface2face(bool chance)
{
face2face = chance;
}
public void Roll_to_hit()
{
if (beatings || (Sexprops.isRapist && RJWSettings.rape_beating))
SexUtility.Sex_Beatings(Sexprops);
}
public void ThrowMetaIcon(IntVec3 pos, Map map, ThingDef icon)
{
MoteMaker.MakeStaticMote(pos, map, icon);
}
public void ThrowMetaIconF(IntVec3 pos, Map map, FleckDef icon)
{
FleckMaker.ThrowMetaIcon(pos, map, icon);
}
public void PlaySexSound()
{
if (RJWSettings.sounds_enabled)
{
SoundInfo sound = new TargetInfo(pawn.Position, pawn.Map);
sound.volumeFactor = RJWSettings.sounds_sex_volume;
if(isAnimalOnAnimal)
sound.volumeFactor *= RJWSettings.sounds_animal_on_animal_volume;
SoundDef.Named("Sex").PlayOneShot(sound);
}
}
public void PlayCumSound()
{
if (RJWSettings.sounds_enabled)
{
SoundInfo sound = new TargetInfo(pawn.Position, pawn.Map);
sound.volumeFactor = RJWSettings.sounds_cum_volume;
if (isAnimalOnAnimal)
sound.volumeFactor *= RJWSettings.sounds_animal_on_animal_volume;
SoundDef.Named("Cum").PlayOneShot(sound);
}
}
public void PlaySexVoice(){}
public void PlayOrgasmVoice(){}
public void Orgasm()
{
if (sex_ticks > orgasmstick) //~3s at speed 1
{
return;
}
orgasms++;
// Sexprops are often passed to other mods for later evaluation of thoughts, memes, etc.
// the original orgasm counter is kept for stability
Sexprops.orgasms ++;
PlayCumSound();
PlayOrgasmVoice();
if (!Sexprops.usedCondom)
{
//apply cum to floor:
SexUtility.CumFilthGenerator(pawn);
if (Partner != null && !pawn.Dead && !Partner.Dead)
{
//TODO: someday unfuck this
PregnancyHelper.impregnate(Sexprops);
SexUtility.TransferFluids(Sexprops);
}
}
CalculateSatisfactionPerTick();
SexUtility.SatisfyPersonal(Sexprops, satisfaction);
SetupOrgasmTicks();
if (neverendingsex)
ticks_left = duration;
}
[SyncMethod]
protected virtual void SetupDurationTicks()
{
ticks_left = (int)(2000.0f * Rand.Range(0.50f, 0.90f));
duration = ticks_left;
}
[SyncMethod]
protected virtual void SetupOrgasmTicks()
{
float need;
if (xxx.is_human(pawn)) {
need = 1.0f + xxx.need_some_sex(pawn); //1-4
} else {
need = 1.0f;
}
orgasmstick = 180;
sex_ticks = (int)((duration / need) * Rand.Range(0.75f, 0.90f));
orgasmStartTick = sex_ticks;
}
public void CalculateSatisfactionPerTick()
{
satisfaction = 0.4f;
}
public static bool IsInOrByBed(Building_Bed b, Pawn p)
{
for (int i = 0; i < b.SleepingSlotsCount; i++)
{
if (b.GetSleepingSlotPos(i).InHorDistOf(p.Position, 1f))
{
return true;
}
}
return false;
}
public override bool TryMakePreToilReservations(bool errorOnFailed)
{
return true; // No reservations needed.
}
protected override IEnumerable<Toil> MakeNewToils()
{
return null;
}
/// <summary>
/// Provides a list of predicates to abort sex "peacefully",
/// i.E. they will not run later stages of SatisfyPersonal or TransferFluid.
/// Current Checks:
/// - Change in Genitalia amount (e.g. a genital got destroyed)
/// - The pawn was not dead, but now died
/// - The pawn was not downed, but is now downed
/// - The partners genital amount changed
/// - The partner was not dead, but now died
/// - The partner was not downed, but is now downed
/// </summary>
/// <returns></returns>
public List<Func<bool>> ConditionsToAbortSex()
{
var EndConditions = new List<Func<bool>>();
int pawnInitialGenitals = Genital_Helper.get_AllPartsHediffList(this.pawn).Count;
Func<bool> EndIfPawnGenitalsWentMissing =
() => {
int foundPawnGenitals = Genital_Helper.get_AllPartsHediffList(this.pawn).Count;
return foundPawnGenitals != pawnInitialGenitals;
};
EndConditions.Add(EndIfPawnGenitalsWentMissing);
bool pawnInitiallyDead = this.pawn.Dead;
Func<bool> EndIfPawnDied =
() =>!pawnInitiallyDead && pawn.Dead;
EndConditions.Add(EndIfPawnDied);
bool pawnInitiallyDowned = this.pawn.Downed;
Func<bool> EndIfPawnDowned =
() => !pawnInitiallyDowned && pawn.Downed;
EndConditions.Add(EndIfPawnDowned);
if (Partner != null)
{
int partnerInitialGenitals = Genital_Helper.get_AllPartsHediffList(this.Partner).Count;
Func<bool> EndIfPartnerGenitalsWentMissing =
() => {
int foundPartnerGenitals = Genital_Helper.get_AllPartsHediffList(this.Partner).Count;
return foundPartnerGenitals != partnerInitialGenitals ;
};
EndConditions.Add(EndIfPartnerGenitalsWentMissing);
bool partnerInitiallyDead = this.Partner.Dead;
Func<bool> EndIfPartnerDied =
() => !partnerInitiallyDead && pawn.Dead;
EndConditions.Add(EndIfPawnDied);
bool partnerInitiallyDowned = this.Partner.Downed;
Func<bool> EndIfPartnerDowned =
() => !partnerInitiallyDowned && Partner.Downed;
EndConditions.Add(EndIfPartnerDowned);
}
return EndConditions;
}
}
}
| Korth95/rjw | 1.5/Source/JobDrivers/JobDriver_Sex.cs | C# | mit | 16,957 |
using RimWorld;
using System.Linq;
using Verse;
using Verse.AI;
using System.Collections.Generic;
using rjw.Modules.Interactions.Enums;
using rjw.Modules.Interactions.Objects;
namespace rjw
{
public abstract class JobDriver_SexBaseInitiator : JobDriver_Sex
{
public void Start()
{
bool isWhoring = false;
bool isRape = false;
var receiverDriver = Partner?.jobs?.curDriver as JobDriver_SexBaseReciever;
isEndytophile = xxx.has_quirk(pawn, "Endytophile");
isAnimalOnAnimal = xxx.is_animal(pawn) && xxx.is_animal(Partner);
if (Partner == null || Partner == pawn)
{
// HERE COULD BE YOUR AD
}
else if (Partner.Dead)
{
isRape = true;
}
else if (receiverDriver is not null)
{
receiverDriver.parteners.AddDistinct(pawn);
//prevent downed Receiver standing up and interrupting rape
if (Partner.health.hediffSet.HasHediff(xxx.submitting))
Partner.health.AddHediff(xxx.submitting);
//(Target.jobs.curDriver as JobDriver_SexBaseReciever).parteners.Count; //TODO: add multipartner support so sex doesn't repeat, maybe, someday
isRape = Partner?.jobs?.curDriver is JobDriver_SexBaseRecieverRaped;
isWhoring = pawn?.CurJob?.def == xxx.whore_is_serving_visitors;
//toggles
NymphSucc();
RoMSucc();
NISucc();
}
if (Sexprops == null)
{
//Log.Message("rulePack1: " + Sexprops);
Sexprops = pawn.GetRMBSexPropsCache();
//Log.Message("rulePack2: " + Sexprops);
pawn.GetRJWPawnData().SexProps = null;
//Log.Message("rulePack3: " + Sexprops);
//Log.Message("rulePack4: " + pawn.GetRJWPawnData().SexProps);
if (Sexprops == null)
{
Sexprops = SexUtility.SelectSextype(pawn, Partner, isRape, isWhoring);
Sexprops.isRapist = isRape;
Sexprops.isWhoring = isWhoring;
}
var interaction = Modules.Interactions.Helpers.InteractionHelper.GetWithExtension(Sexprops.dictionaryKey);
Sexprops.isRevese = interaction.HasInteractionTag(InteractionTag.Reverse);
}
if (receiverDriver is not null && receiverDriver.parteners.Count == 1 && receiverDriver.Sexprops == null)
{
receiverDriver.Sexprops = new SexProps()
{
pawn = Partner,
partner = pawn,
sexType = Sexprops.sexType,
dictionaryKey = Sexprops.dictionaryKey,
usedCondom = Sexprops.usedCondom,
isRape = isRape,
isReceiver = true,
isRevese = Sexprops.isRevese
};
}
SexUtility.LogSextype(Sexprops.pawn, Sexprops.partner, Sexprops.rulePack, Sexprops.dictionaryKey);
if (RJWPreferenceSettings.sex_wear == RJWPreferenceSettings.Clothing.Clothed) return;
var comp = CompRJW.Comp(pawn);
if (comp != null)
{
comp.drawNude = true;
pawn.Drawer.renderer.SetAllGraphicsDirty();
}
Pawn partner = Partner;
if(partner != null)
{
comp = CompRJW.Comp(partner);
if (comp != null)
{
comp.drawNude = true;
partner.Drawer.renderer.SetAllGraphicsDirty();
}
}
}
//public void Change(xxx.rjwSextype sexType)
//{
// if (pawn.jobs?.curDriver is JobDriver_SexBaseInitiator)
// {
// (pawn.jobs.curDriver as JobDriver_SexBaseInitiator).increase_time(duration);
// Sexprops = SexUtility.SelectSextype(pawn, Partner, isRape, isWhoring, Partner);
// sexType = Sexprops.SexType;
// SexUtility.LogSextype(Sexprops.Giver, Sexprops.Reciever, Sexprops.RulePack, Sexprops.DictionaryKey);
// }
// if (Partner.jobs?.curDriver is JobDriver_SexBaseReciever)
// {
// (Partner.jobs.curDriver as JobDriver_SexBaseReciever).increase_time(duration);
// Sexprops = SexUtility.SelectSextype(pawn, Partner, isRape, isWhoring, Partner);
// sexType = Sexprops.SexType;
// SexUtility.LogSextype(Sexprops.Giver, Sexprops.Reciever, Sexprops.RulePack, Sexprops.DictionaryKey);
// }
// sexType = sexType
//}
public void End()
{
if (xxx.is_human(pawn))
{
var comp = CompRJW.Comp(pawn);
if (comp != null)
{
comp.drawNude = false;
pawn.Drawer.renderer.SetAllGraphicsDirty();
}
}
GlobalTextureAtlasManager.TryMarkPawnFrameSetDirty(pawn);
if (Partner?.jobs?.curDriver is JobDriver_SexBaseReciever receiverDriver)
{
if (receiverDriver.parteners.Count == 1 && !Sexprops.isCoreLovin)
{
var isPenetrative = Sexprops.sexType switch
{
xxx.rjwSextype.Anal => true,
xxx.rjwSextype.Vaginal => true,
xxx.rjwSextype.DoublePenetration => true,
_ => false
};
if (!isPenetrative) goto notKnotting;
// reverse interaction, check if penetrating partner can knot
var ableToKnot = Sexprops.isRevese ? canKnott(Partner) : canKnott(pawn);
if (!ableToKnot) goto notKnotting;
pawn.jobs.jobQueue.EnqueueFirst(JobMaker.MakeJob(xxx.knotted, Partner));
Partner.jobs.jobQueue.EnqueueFirst(JobMaker.MakeJob(xxx.knotted, pawn));
}
notKnotting:
receiverDriver.parteners.Remove(pawn);
}
}
public bool canKnott(Pawn pawn)
{
// In case of necro, dead pawns can never knot.
if (pawn.Dead) return false;
foreach (var part in pawn.GetGenitalsList().OfType<ISexPartHediff>())
if (part.Def.partTags.Contains("Knotted")) return true;
return false;
}
/// <summary>
/// non succubus focus gain
/// </summary>
public void NymphSucc()
{
if (MeditationFocusTypeAvailabilityCache.PawnCanUse(pawn, xxx.SexMeditationFocus))
{
shouldGainFocus = true;
SexUtility.OffsetPsyfocus(pawn, 0.01f);
}
else if (xxx.is_zoophile(pawn) && xxx.is_animal(Partner) && MeditationFocusTypeAvailabilityCache.PawnCanUse(pawn, MeditationFocusDefOf.Natural))
{
shouldGainFocus = true;
}
if (MeditationFocusTypeAvailabilityCache.PawnCanUse(Partner, xxx.SexMeditationFocus))
{
shouldGainFocusP = true;
}
else if (xxx.is_zoophile(Partner) && xxx.is_animal(pawn) && MeditationFocusTypeAvailabilityCache.PawnCanUse(Partner, MeditationFocusDefOf.Natural))
{
shouldGainFocusP = true;
}
}
/// <summary>
/// Rimworld of Magic succubus focus gain
/// </summary>
public void RoMSucc()
{
if (xxx.RoMIsActive)
{
if (xxx.has_traits(pawn))
if (pawn.story.traits.HasTrait(xxx.Succubus))
{
isSuccubus = true;
}
if (xxx.has_traits(Partner))
if (Partner.story.traits.HasTrait(xxx.Succubus))
{
isSuccubusP = true;
}
}
}
/// <summary>
/// Nightmare Incarnation succubus focus gain
/// </summary>
public void NISucc()
{
if (xxx.NightmareIncarnationIsActive)
{
if (xxx.has_traits(pawn))
foreach (var x in pawn.AllComps?.Where(x => x?.props?.ToStringSafe() == "NightmareIncarnation.CompProperties_SuccubusRace"))
{
isSuccubus = true;
break;
}
if (xxx.has_traits(Partner))
foreach (var x in Partner.AllComps?.Where(x => x?.props?.ToStringSafe() == "NightmareIncarnation.CompProperties_SuccubusRace"))
{
isSuccubusP = true;
break;
}
}
}
public override bool TryMakePreToilReservations(bool errorOnFailed)
{
//ModLog.Message("shouldreserve " + shouldreserve);
if (shouldreserve && Target != null)
return pawn.Reserve(Target, job, xxx.max_rapists_per_prisoner, stackCount, null, errorOnFailed);
else if (shouldreserve && Bed != null)
return pawn.Reserve(Bed, job, Bed.SleepingSlotsCount, 0, null, errorOnFailed);
else
return true; // No reservations needed.
//return this.pawn.Reserve(this.Partner, this.job, 1, 0, null) && this.pawn.Reserve(this.Bed, this.job, 1, 0, null);
}
}
} | Korth95/rjw | 1.5/Source/JobDrivers/JobDriver_SexBaseInitiator.cs | C# | mit | 7,525 |
using System;
using System.Collections.Generic;
using Verse;
using Verse.AI;
namespace rjw
{
public class JobDriver_SexBaseReciever : JobDriver_Sex
{
//give this poor driver some love other than (Partner.jobs?.curDriver is JobDriver_SexBaseReciever)
public List<Pawn> parteners = new();
public override void ExposeData()
{
base.ExposeData();
Scribe_Collections.Look(ref parteners, "parteners", LookMode.Reference);
}
/// <summary>
/// Adds a predicate that a partner must fulfill to be considered valid.
/// </summary>
/// <param name="predicate">The predicate.</param>
public void AddPartnerCondition(Predicate<Pawn> predicate) =>
this.FailOn(() => parteners.Count > 0 && !parteners.Any(predicate));
protected virtual void DoSetup()
{
setup_ticks();
// Add sex initiator, so this wont fail before they start their job.
parteners.AddDistinct(Partner);
// Handles ending the job when no partners remain.
AddEndCondition(() => parteners.Count <= 0 ? JobCondition.Succeeded : JobCondition.Ongoing);
// These make sure at least one partner is still valid. In a perfect world,
// the partners will properly remove themselves when they're no longer
// trying to screw this pawn ...but this is not a perfect world.
AddPartnerCondition(MustBeSpawned);
AddPartnerCondition(MustBeAwake);
AddPartnerCondition(MustNotBeDrafted);
AddPartnerCondition(MustBeMySexInitiator);
}
/// <summary>
/// Checks that the partner is actually spawned on this map.
/// </summary>
protected bool MustBeSpawned(Pawn partner) =>
partner.Spawned && partner.Map == pawn.Map;
/// <summary>
/// Checks that the partner is capable of being awake.
/// </summary>
protected bool MustBeAwake(Pawn partner) =>
partner.health.capacities.CanBeAwake;
/// <summary>
/// Checks that the partner is not drafted.
/// </summary>
protected bool MustNotBeDrafted(Pawn partner) =>
!partner.Drafted;
/// <summary>
/// Checks that the partner is still trying to fuck this driver's pawn.
/// </summary>
protected bool MustBeMySexInitiator(Pawn partner) =>
(partner.jobs.curDriver as JobDriver_SexBaseInitiator)?.Partner == pawn;
}
} | Korth95/rjw | 1.5/Source/JobDrivers/JobDriver_SexBaseReciever.cs | C# | mit | 2,210 |
using System.Collections.Generic;
using RimWorld;
using Verse;
using Verse.AI;
using System;
namespace rjw
{
public class JobDriver_SexBaseRecieverLoved : JobDriver_SexBaseReciever
{
protected override void DoSetup()
{
base.DoSetup();
// More/less hearts based on opinion.
try
{
if (pawn.relations.OpinionOf(Partner) < 0)
ticks_between_hearts += 50;
else if (pawn.relations.OpinionOf(Partner) > 60)
ticks_between_hearts -= 25;
}
catch
{
ModLog.Warning("Failed to resolve pawn relations, if on save load, this shouldn't matter too much.");
}
// For consensual sex, drafting the recipient will interrupt the job.
this.FailOn(() => pawn.Drafted);
}
protected override IEnumerable<Toil> MakeNewToils()
{
DoSetup();
// ModLog.Message("JobDriver_GettinLoved::MakeNewToils is called");
// ModLog.Message("" + Partner.CurJob.def);
if (Partner.CurJob.def == xxx.casual_sex) // sex in bed
{
this.KeepLyingDown(iBed);
yield return Toils_Reserve.Reserve(iTarget, 1, 0);
yield return Toils_Reserve.Reserve(iBed, Bed.SleepingSlotsCount, 0);
var get_loved = MakeSexToil();
get_loved.FailOn(() => Partner.CurJob?.def != xxx.casual_sex);
yield return get_loved;
}
else if (Partner.CurJob.def == xxx.quick_sex)
{
yield return Toils_Reserve.Reserve(iTarget, 1, 0);
var get_loved = MakeSexToil();
get_loved.handlingFacing = false;
yield return get_loved;
}
else if (Partner.CurJob.def == xxx.whore_is_serving_visitors)
{
this.FailOn(() => Partner.CurJob == null);
yield return Toils_Reserve.Reserve(iTarget, 1, 0);
var get_loved = MakeSexToil();
get_loved.FailOn(() => Partner.CurJob?.def != xxx.whore_is_serving_visitors);
yield return get_loved;
}
else if (Partner.CurJob.def == xxx.bestialityForFemale)
{
this.FailOn(() => Partner.CurJob == null);
yield return Toils_Reserve.Reserve(iTarget, 1, 0);
var get_loved = MakeSexToil();
get_loved.FailOn(() => Partner.CurJob?.def != xxx.bestialityForFemale);
yield return get_loved;
}
else if (Partner.CurJob.def == xxx.animalMate)
{
this.FailOn(() => Partner.CurJob == null);
yield return Toils_Reserve.Reserve(iTarget, 1, 0);
var get_loved = MakeSexToil();
get_loved.FailOn(() => Partner.CurJob?.def != xxx.animalMate);
yield return get_loved;
}
}
private Toil MakeSexToil()
{
// Any other consensual sex besides casual sex is in a bed.
var get_loved
= Partner.CurJob.def != xxx.casual_sex ? new Toil()
: Toils_LayDown.LayDown(iBed, true, false, false, false);
get_loved.defaultCompleteMode = ToilCompleteMode.Never;
get_loved.socialMode = RandomSocialMode.Off;
get_loved.handlingFacing = true;
get_loved.tickAction = () =>
{
if (pawn.IsHashIntervalTick(ticks_between_hearts))
ThrowMetaIconF(pawn.Position, pawn.Map, FleckDefOf.Heart);
};
get_loved.AddFinishAction(() =>
{
if (xxx.is_human(pawn))
{
var comp = CompRJW.Comp(pawn);
if (comp != null)
{
comp.drawNude = false;
pawn.Drawer.renderer.SetAllGraphicsDirty();
}
}
GlobalTextureAtlasManager.TryMarkPawnFrameSetDirty(pawn);
});
return get_loved;
}
}
// Used by the quickie job for some reason. Future expansion?
public class JobDriver_SexBaseRecieverQuickie : JobDriver_SexBaseRecieverLoved { }
} | Korth95/rjw | 1.5/Source/JobDrivers/JobDriver_SexBaseRecieverLoved.cs | C# | mit | 3,424 |
using System;
using System.Collections.Generic;
using RimWorld;
using Verse;
using Verse.AI;
namespace rjw
{
public class JobDriver_SexBaseRecieverRaped : JobDriver_SexBaseReciever
{
protected override IEnumerable<Toil> MakeNewToils()
{
DoSetup();
var get_raped = new Toil
{
defaultCompleteMode = ToilCompleteMode.Never,
handlingFacing = true,
socialMode = RandomSocialMode.Off,
initAction = () =>
{
pawn.pather.StopDead();
pawn.jobs.curDriver.asleep = false;
SexUtility.BeeingRapedAlert(Partner, pawn);
},
tickAction = () =>
{
if (parteners.Count <= 0) return;
if (!pawn.IsHashIntervalTick(ticks_between_hearts / parteners.Count)) return;
if (xxx.is_masochist(pawn) || xxx.is_psychopath(pawn))
ThrowMetaIconF(pawn.Position, pawn.Map, FleckDefOf.Heart);
else
ThrowMetaIconF(pawn.Position, pawn.Map, xxx.mote_noheart);
}
};
get_raped.AddFinishAction(() =>
{
if (xxx.is_human(pawn))
{
var comp = CompRJW.Comp(pawn);
if (comp != null)
{
comp.drawNude = false;
pawn.Drawer.renderer.SetAllGraphicsDirty();
}
}
GlobalTextureAtlasManager.TryMarkPawnFrameSetDirty(pawn);
if (Bed != null && pawn.Downed)
{
Job toBed = JobMaker.MakeJob(JobDefOf.Rescue, pawn, Bed);
toBed.count = 1;
Partner.jobs.jobQueue.EnqueueFirst(toBed);
//Log.Message(xxx.get_pawnname(Initiator) + ": job tobed:" + tobed);
}
else if (pawn.HostileTo(Partner) && !pawn.health.hediffSet.HasHediff(xxx.submitting))
{
pawn.health.AddHediff(xxx.submitting);
}
else if (RJWSettings.rape_beating)
pawn.stances.stunner.StunFor(600, pawn);
});
yield return get_raped;
}
}
} | Korth95/rjw | 1.5/Source/JobDrivers/JobDriver_SexBaseRecieverRaped.cs | C# | mit | 1,755 |
using System.Collections.Generic;
using RimWorld;
using Verse;
using Verse.AI;
namespace rjw
{
public class JobDriver_JoinInBed : JobDriver_SexBaseInitiator
{
public override bool TryMakePreToilReservations(bool errorOnFailed)
{
return pawn.Reserve(Target, job, xxx.max_rapists_per_prisoner, 0, null, errorOnFailed);
}
protected override IEnumerable<Toil> MakeNewToils()
{
//ModLog.Message("" + this.GetType().ToString() + "::MakeNewToils() called");
setup_ticks();
this.FailOnDespawnedOrNull(iTarget);
this.FailOnDespawnedOrNull(iBed);
this.FailOn(() => !Partner.health.capacities.CanBeAwake);
this.FailOn(() => !(Partner.InBed() || Bed_Utility.in_same_bed(Partner, pawn)));
this.FailOn(() => pawn.Drafted);
yield return Toils_Reserve.Reserve(iTarget, xxx.max_rapists_per_prisoner, 0);
yield return Toils_Goto.GotoThing(iTarget, PathEndMode.OnCell);
Toil StartPartnerJob = new Toil();
StartPartnerJob.defaultCompleteMode = ToilCompleteMode.Instant;
StartPartnerJob.socialMode = RandomSocialMode.Off;
StartPartnerJob.initAction = delegate
{
Job gettin_loved = JobMaker.MakeJob(xxx.gettin_loved, pawn, Bed);
Partner.jobs.StartJob(gettin_loved, JobCondition.InterruptForced);
};
yield return StartPartnerJob;
Toil SexToil = new Toil();
SexToil.defaultCompleteMode = ToilCompleteMode.Never;
SexToil.socialMode = RandomSocialMode.Off;
SexToil.handlingFacing = true;
SexToil.initAction = delegate
{
Start();
Sexprops.usedCondom = CondomUtility.TryUseCondom(pawn) || CondomUtility.TryUseCondom(Partner);
if (Sexprops.usedCondom)
{
var receiverDriver = Partner?.jobs?.curDriver as JobDriver_SexBaseReciever;
if (receiverDriver is not null && receiverDriver.Sexprops != null)
receiverDriver.Sexprops.usedCondom = true;
}
};
SexToil.FailOn(() => Partner.CurJob?.def != xxx.gettin_loved);
SexToil.AddPreTickAction(delegate
{
if (pawn.IsHashIntervalTick(ticks_between_hearts))
ThrowMetaIconF(pawn.Position, pawn.Map, FleckDefOf.Heart);
SexTick(pawn, Partner);
SexUtility.reduce_rest(Partner, 1);
SexUtility.reduce_rest(pawn, 2);
if (ticks_left <= 0)
ReadyForNextToil();
});
SexToil.AddFinishAction(End);
yield return SexToil;
yield return new Toil
{
initAction = () => SexUtility.ProcessSex(Sexprops),
defaultCompleteMode = ToilCompleteMode.Instant
};
}
}
}
| Korth95/rjw | 1.5/Source/JobDrivers/JobDriver_SexCasual.cs | C# | mit | 2,450 |
using System;
using System.Collections.Generic;
using System.Linq;
using Multiplayer.API;
using RimWorld;
using UnityEngine;
using Verse;
using Verse.AI;
namespace rjw
{
public class JobDriver_SexQuick : JobDriver_SexBaseInitiator
{
public override bool TryMakePreToilReservations(bool errorOnFailed)
{
return pawn.Reserve(Target, job, xxx.max_rapists_per_prisoner, 0, null, errorOnFailed);
}
protected override IEnumerable<Toil> MakeNewToils()
{
//ModLog.Message("" + this.GetType().ToString() + "::MakeNewToils() called");
setup_ticks();
var PartnerJob = xxx.getting_quickie;
this.FailOnDespawnedNullOrForbidden(iTarget);
this.FailOn(() => !Partner.health.capacities.CanBeAwake);
this.FailOn(() => pawn.Drafted);
yield return Toils_Goto.GotoThing(iTarget, PathEndMode.OnCell);
Toil findQuickieSpot = new Toil();
findQuickieSpot.defaultCompleteMode = ToilCompleteMode.PatherArrival;
findQuickieSpot.initAction = delegate
{
//Needs this earlier to decide if current place is good enough
var all_pawns = pawn.Map.mapPawns.AllPawnsSpawned.Where(x
=> x.Position.DistanceTo(pawn.Position) < 100
&& xxx.is_human(x)
&& x != pawn
&& x != Partner
).ToList();
FloatRange temperature = pawn.ComfortableTemperatureRange();
float cellTemp = pawn.Position.GetTemperature(pawn.Map);
if (Partner.IsPrisonerInPrisonCell() || (!CasualSex_Helper.MightBeSeen(all_pawns, pawn.Position, pawn, Partner) && (cellTemp > temperature.min && cellTemp < temperature.max)))
{
ReadyForNextToil();
}
else
{
var spot = CasualSex_Helper.FindSexLocation(pawn, Partner);
pawn.pather.StartPath(spot, PathEndMode.OnCell);
//sometimes errors with stuff like vomiting
//sometimes partner is null ??? no idea how to fix this
Partner?.jobs.StopAll();
Job job = JobMaker.MakeJob(JobDefOf.GotoMindControlled, spot);
Partner?.jobs.StartJob(job, JobCondition.InterruptForced);
}
};
yield return findQuickieSpot;
Toil WaitForPartner = new Toil();
WaitForPartner.defaultCompleteMode = ToilCompleteMode.Delay;
WaitForPartner.initAction = delegate
{
ticksLeftThisToil = 5000;
};
WaitForPartner.tickAction = delegate
{
pawn.GainComfortFromCellIfPossible();
if (pawn.Position.DistanceTo(Partner.Position) <= 1f)
{
ReadyForNextToil();
}
};
yield return WaitForPartner;
Toil StartPartnerJob = new Toil();
StartPartnerJob.defaultCompleteMode = ToilCompleteMode.Instant;
StartPartnerJob.socialMode = RandomSocialMode.Off;
StartPartnerJob.initAction = delegate
{
Job gettingQuickie = JobMaker.MakeJob(PartnerJob, pawn, Partner);
Partner.jobs.StartJob(gettingQuickie, JobCondition.InterruptForced);
};
yield return StartPartnerJob;
Toil SexToil = new Toil();
SexToil.defaultCompleteMode = ToilCompleteMode.Never;
SexToil.socialMode = RandomSocialMode.Off;
SexToil.defaultDuration = duration;
SexToil.handlingFacing = true;
SexToil.FailOn(() => Partner.CurJob?.def != PartnerJob);
SexToil.initAction = delegate
{
Partner.pather.StopDead();
Partner.jobs.curDriver.asleep = false;
Start();
Sexprops.usedCondom = CondomUtility.TryUseCondom(pawn) || CondomUtility.TryUseCondom(Partner);
if (Sexprops.usedCondom)
{
var receiverDriver = Partner?.jobs?.curDriver as JobDriver_SexBaseReciever;
if (receiverDriver is not null && receiverDriver.Sexprops != null)
receiverDriver.Sexprops.usedCondom = true;
}
};
SexToil.AddPreTickAction(delegate
{
if (pawn.IsHashIntervalTick(ticks_between_hearts))
ThrowMetaIconF(pawn.Position, pawn.Map, FleckDefOf.Heart);
SexTick(pawn, Partner);
SexUtility.reduce_rest(Partner, 1);
SexUtility.reduce_rest(pawn, 1);
if (ticks_left <= 0)
ReadyForNextToil();
});
SexToil.AddFinishAction(End);
yield return SexToil;
yield return new Toil
{
initAction = () => SexUtility.ProcessSex(Sexprops),
defaultCompleteMode = ToilCompleteMode.Instant
};
}
}
}
| Korth95/rjw | 1.5/Source/JobDrivers/JobDriver_SexQuick.cs | C# | mit | 4,094 |
public class RJWSexJob : Job, IExposable
{
public VorePath VorePath;
public VoreProposal Proposal;
public Pawn Initiator;
public bool IsForced = false;
public bool IsKidnapping = false;
public bool IsRitualRelated = false;
// we hide base ExposeData here because Tynan thought it was a great idea to completely lock and seal the Job. This entire file is just a mess of workarounds for the restrictive Job class
public new void ExposeData()
{
base.ExposeData();
Scribe_Deep.Look(ref VorePath, "VorePath", new object[0]);
Scribe_Deep.Look(ref Proposal, "Proposal", new object[0]);
Scribe_References.Look(ref Initiator, "Initiator");
Scribe_Values.Look(ref IsKidnapping, "IsKidnapping");
}
}
public static class VoreJobMaker
{
public static VoreJob MakeJob()
{
VoreJob job = SimplePool<VoreJob>.Get();
job.loadID = Find.UniqueIDsManager.GetNextJobID();
return job;
}
public static VoreJob MakeJob(JobDef jobDef)
{
VoreJob job = MakeJob();
job.def = jobDef;
return job;
}
public static VoreJob MakeJob(JobDef jobDef, LocalTargetInfo targetA)
{
VoreJob job = MakeJob();
job.def = jobDef;
job.targetA = targetA;
... -> more MakeJob() overloads with targetA, targetB, etc. but msg too long
} | Korth95/rjw | 1.5/Source/JobDrivers/JobRJWSex.cs | C# | mit | 1,522 |
using System.Linq;
using RimWorld;
using Verse;
using Verse.AI;
using System.Collections.Generic;
using Multiplayer.API;
namespace rjw
{
//Rape to Prisoner of QuestPrisonerWillingToJoin
class JobGiver_AIRapePrisoner : ThinkNode_JobGiver
{
[SyncMethod]
public static Pawn find_victim(Pawn pawn, Map m)
{
float min_fuckability = 0.10f; // Don't rape pawns with <10% fuckability
float avg_fuckability = 0f; // Average targets fuckability, choose target higher than that
var valid_targets = new Dictionary<Pawn, float>(); // Valid pawns and their fuckability
Pawn chosentarget = null; // Final target pawn
IEnumerable<Pawn> targets = m.mapPawns.AllPawns.Where(x
=> x != pawn
&& IsPrisonerOf(x, pawn.Faction)
&& xxx.can_get_raped(x)
&& pawn.CanReserveAndReach(x, PathEndMode.Touch, Danger.Some, xxx.max_rapists_per_prisoner, 0)
&& !x.Position.IsForbidden(pawn)
);
foreach (Pawn target in targets)
{
if (!Pather_Utility.cells_to_target_rape(pawn, target.Position))
continue;// too far
float fuc = SexAppraiser.would_fuck(pawn, target, true, true);
if (fuc > min_fuckability)
if (Pather_Utility.can_path_to_target(pawn, target.Position))
valid_targets.Add(target, fuc);
}
if (valid_targets.Any())
{
avg_fuckability = valid_targets.Average(x => x.Value);
// choose pawns to fuck with above average fuckability
var valid_targetsFiltered = valid_targets.Where(x => x.Value >= avg_fuckability);
if (valid_targetsFiltered.Any())
chosentarget = valid_targetsFiltered.RandomElement().Key;
}
return chosentarget;
}
protected override Job TryGiveJob(Pawn pawn)
{
if (RJWSettings.DebugRape) ModLog.Message(" JobGiver_AIRapePrisoner::TryGiveJob( " + xxx.get_pawnname(pawn) + " ) called ");
if (!xxx.can_rape(pawn)) return null;
if (SexUtility.ReadyForLovin(pawn) || xxx.is_hornyorfrustrated(pawn))
{
// don't allow pawns marked as comfort prisoners to rape others
if (xxx.is_healthy(pawn))
{
Pawn prisoner = find_victim(pawn, pawn.Map);
if (prisoner != null)
{
if (RJWSettings.DebugRape) ModLog.Message(" JobGiver_RandomRape::TryGiveJob( " + xxx.get_pawnname(pawn) + " ) - found victim " + xxx.get_pawnname(prisoner));
return JobMaker.MakeJob(xxx.RapeRandom, prisoner);
}
}
}
return null;
}
protected static bool IsPrisonerOf(Pawn pawn,Faction faction)
{
if (pawn?.guest == null) return false;
return pawn.guest.HostFaction == faction && pawn.guest.IsPrisoner;
}
}
}
| Korth95/rjw | 1.5/Source/JobGivers/JobGiver_AIRapePrisoner.cs | C# | mit | 2,657 |
using RimWorld;
using Verse;
using Verse.AI;
namespace rjw
{
/// <summary>
/// Pawn tries to find animal to do loving/raping.
/// </summary>
public class JobGiver_Bestiality : ThinkNode_JobGiver
{
protected override Job TryGiveJob(Pawn pawn)
{
if (pawn.Drafted) return null;
// Most checks are now done in ThinkNode_ConditionalBestiality
if (!SexUtility.ReadyForLovin(pawn) && !xxx.is_frustrated(pawn))
return null;
Pawn target = BreederHelper.find_breeder_animal(pawn, pawn.Map);
if (target == null) return null;
if (xxx.can_rape(pawn))
{
return JobMaker.MakeJob(xxx.bestiality, target);
}
Building_Bed petbed = target.ownership.OwnedBed;
Building_Bed bed = pawn.ownership.OwnedBed;
if (xxx.can_be_fucked(pawn) && petbed != null && pawn.CanReach(petbed, PathEndMode.OnCell, Danger.Some)) //check for animal bed
{
return JobMaker.MakeJob(xxx.bestialityForFemale, target, petbed); //go to animal bed if possible
}
else if (xxx.can_be_fucked(pawn) && bed != null && target.CanReach(bed, PathEndMode.OnCell, Danger.Some) && !target.Downed) //check for pawn bed
{
return JobMaker.MakeJob(xxx.bestialityForFemale, target, bed); //go to own bed if animal bed is unavailable
}
else return null;
}
}
} | Korth95/rjw | 1.5/Source/JobGivers/JobGiver_Bestiality.cs | C# | mit | 1,285 |
using Verse;
using Verse.AI;
namespace rjw
{
/// <summary>
/// Attempts to give a breeding job to an eligible animal.
/// </summary>
public class JobGiver_Breed : ThinkNode_JobGiver
{
protected override Job TryGiveJob(Pawn animal)
{
//ModLog.Message(" JobGiver_Breed::TryGiveJob( " + xxx.get_pawnname(animal) + " ) ReadyForLovin " + (SexUtility.ReadyForLovin(animal)));
if (!SexUtility.ReadyForLovin(animal))
return null;
//ModLog.Message(" ready to breed::is_healthy " + xxx.is_healthy(animal) + " can_rape " + xxx.can_rape(animal));
if (xxx.is_healthy(animal) && xxx.can_rape(animal))
{
//search for desiganted target to sex
Pawn designated_target = BreederHelper.find_designated_breeder(animal, animal.Map);
if (designated_target != null)
{
return JobMaker.MakeJob(xxx.animalBreed, designated_target);
}
}
return null;
}
}
} | Korth95/rjw | 1.5/Source/JobGivers/JobGiver_Breed.cs | C# | mit | 892 |
using Verse;
using Verse.AI;
using RimWorld;
using System.Collections.Generic;
using System.Linq;
using Multiplayer.API;
namespace rjw
{
public class JobGiver_ComfortPrisonerRape : ThinkNode_JobGiver
{
[SyncMethod]
public static Pawn find_targetCP(Pawn pawn, Map m)
{
if (!DesignatorsData.rjwComfort.Any()) return null;
float min_fuckability = 0.10f; // Don't rape prisoners with <10% fuckability
float avg_fuckability = 0f; // Average targets fuckability, choose target higher than that
var valid_targets = new Dictionary<Pawn, float>(); // Valid pawns and their fuckability
Pawn chosentarget = null; // Final target pawn
string pawnName = xxx.get_pawnname(pawn);
if (RJWSettings.DebugRape) ModLog.Message($"FindComfortPrisoner({pawnName})");
IEnumerable<Pawn> targets = DesignatorsData.rjwComfort.Where(x
=> x != pawn
&& xxx.can_get_raped(x)
&& pawn.CanReserveAndReach(x, PathEndMode.Touch, Danger.Some, xxx.max_rapists_per_prisoner, 0)
&& !x.IsForbidden(pawn)
&& SexAppraiser.would_rape(pawn, x)
);
if (RJWSettings.DebugRape) ModLog.Message($"FindComfortPrisoner({pawnName}): found {targets.Count()}");
if (xxx.is_animal(pawn))
{
// Animals only consider targets they can see, instead of seeking them out.
targets = targets.Where(x => pawn.CanSee(x)).ToList();
}
foreach (Pawn target in targets)
{
if (!Pather_Utility.cells_to_target_rape(pawn, target.Position))
continue;// too far
float fuc = 0f;
if (xxx.is_animal(target))
fuc = SexAppraiser.would_fuck_animal(pawn, target, true);
else if (xxx.is_human(target))
fuc = SexAppraiser.would_fuck(pawn, target, true);
if (RJWSettings.DebugRape) ModLog.Message($"FindComfortPrisoner({pawnName}): {fuc} has to be over {min_fuckability}");
if (fuc > min_fuckability)
if (Pather_Utility.can_path_to_target(pawn, target.Position))
valid_targets.Add(target, fuc);
}
if (valid_targets.Any())
{
// avg_fuckability = valid_targets.Average(x => x.Value); // disabled for CP
// choose pawns to fuck with above average fuckability
var valid_targetsFiltered = valid_targets.Where(x => x.Value >= avg_fuckability);
if (valid_targetsFiltered.Any())
chosentarget = valid_targetsFiltered.RandomElement().Key;
}
return chosentarget;
}
protected override Job TryGiveJob(Pawn pawn)
{
if (RJWSettings.DebugRape) ModLog.Message($"JobGiver_ComfortPrisonerRape::TryGiveJob({xxx.get_pawnname(pawn)}) called");
if (!RJWSettings.WildMode)
{
// don't allow pawns marked as comfort prisoners to rape others
if (RJWSettings.DebugRape) ModLog.Message($"JobGiver_ComfortPrisonerRape::TryGiveJob({xxx.get_pawnname(pawn)}): is healthy = {xxx.is_healthy(pawn)}, is cp = {pawn.IsDesignatedComfort()}, is ready = {SexUtility.ReadyForLovin(pawn)}, is frustrated = {xxx.is_frustrated(pawn)}");
if (!xxx.is_healthy(pawn) || pawn.IsDesignatedComfort() || (!SexUtility.ReadyForLovin(pawn) && !xxx.is_frustrated(pawn))) return null;
}
if (RJWSettings.DebugRape) ModLog.Message($"FindComfortPrisoner({xxx.get_pawnname(pawn)}): can rape = {xxx.can_rape(pawn)}, is drafted = {pawn.Drafted}");
if (pawn.Drafted || !xxx.can_rape(pawn)) return null;
// It's unnecessary to include other job checks. Pawns seem to only look for new jobs when between jobs or laying down idle.
if (!(pawn.jobs.curJob == null || pawn.jobs.curJob.def == JobDefOf.LayDown))
{
if (RJWSettings.DebugRape) ModLog.Message($"FindComfortPrisoner({xxx.get_pawnname(pawn)}): I already have a job ({pawn.CurJobDef})");
return null;
}
// Faction check.
if (!(pawn.Faction?.IsPlayer ?? false) && !pawn.IsPrisonerOfColony)
{
if (RJWSettings.DebugRape) ModLog.Message($"FindComfortPrisoner({xxx.get_pawnname(pawn)}): player faction: {pawn.Faction?.IsPlayer}, prisoner: {pawn.IsPrisonerOfColony}");
return null;
}
Pawn target = find_targetCP(pawn, pawn.Map);
if (target == null) return null;
if (RJWSettings.DebugRape) ModLog.Message($"JobGiver_ComfortPrisonerRape::TryGiveJob({xxx.get_pawnname(pawn)}) with target {xxx.get_pawnname(target)}");
if (xxx.is_animal(target))
return JobMaker.MakeJob(xxx.bestiality, target);
else
return JobMaker.MakeJob(xxx.RapeCP, target);
}
}
}
| Korth95/rjw | 1.5/Source/JobGivers/JobGiver_ComfortPrisonerRape.cs | C# | mit | 4,363 |
using System.Collections.Generic;
using System.Linq;
using RimWorld;
using Verse;
using Verse.AI;
using Multiplayer.API;
namespace rjw
{
public class JobGiver_DoQuickie : ThinkNode_JobGiver
{
/// <summary> Checks all of our potential partners to see if anyone's eligible, returning the most attractive and convenient one. </summary>
protected override Job TryGiveJob(Pawn pawn)
{
if (!RJWHookupSettings.HookupsEnabled || !RJWHookupSettings.QuickHookupsEnabled)
return null;
if (pawn.Drafted)
return null;
if (!SexUtility.ReadyForHookup(pawn))
return null;
// We increase the time right away to prevent the fairly expensive check from happening too frequently
SexUtility.IncreaseTicksToNextHookup(pawn);
// If the pawn is a whore, or recently had sex, skip the job unless they're really horny
if (!xxx.is_frustrated(pawn) && (xxx.is_whore(pawn) || !SexUtility.ReadyForLovin(pawn)))
return null;
// This check attempts to keep groups leaving the map, like guests or traders, from turning around to hook up
if (pawn.mindState?.duty?.def == DutyDefOf.TravelOrLeave)
{
// TODO: Some guest pawns keep the TravelOrLeave duty the whole time, I think the ones assigned to guard the pack animals.
// That's probably ok, though it wasn't the intention.
if (RJWSettings.DebugLogJoinInBed) ModLog.Message($" Quickie.TryGiveJob:({xxx.get_pawnname(pawn)}): has TravelOrLeave, no time for lovin!");
return null;
}
if (pawn.CurJob == null)
{
//--Log.Message(" checking pawn and abilities");
if (CasualSex_Helper.CanHaveSex(pawn))
{
//--Log.Message(" finding partner");
Pawn partner = CasualSex_Helper.find_partner(pawn, pawn.Map, false);
//--Log.Message(" checking partner");
if (partner == null)
return null;
// Interrupt current job.
if (pawn.CurJob != null && pawn.jobs.curDriver != null)
pawn.jobs.curDriver.EndJobWith(JobCondition.InterruptForced);
//--Log.Message(" returning job");
return JobMaker.MakeJob(xxx.quick_sex, partner);
}
}
return null;
}
}
}
| Korth95/rjw | 1.5/Source/JobGivers/JobGiver_DoQuickie.cs | C# | mit | 2,119 |
using RimWorld;
using rjw.Modules.Shared.Extensions;
using rjw.Modules.Shared.Logs;
using Verse;
using Verse.AI;
namespace rjw
{
public class JobGiver_JoinInBed : ThinkNode_JobGiver
{
private readonly static ILog _log = LogManager.GetLogger<JobGiver_JoinInBed>();
protected override Job TryGiveJob(Pawn pawn)
{
if (!RJWHookupSettings.HookupsEnabled)
{
_log.Debug("Hookups disabled");
return null;
}
if (pawn.Drafted)
return null;
if (!SexUtility.ReadyForHookup(pawn))
return null;
string name = pawn.GetName();
_log.Debug($"{name} was ready");
// We increase the time right away to prevent the fairly expensive check from happening too frequently
SexUtility.IncreaseTicksToNextHookup(pawn);
// If the pawn is a whore, or recently had sex, skip the job unless they're really horny
if (!xxx.is_frustrated(pawn) && (xxx.is_whore(pawn) || !SexUtility.ReadyForLovin(pawn)))
{
_log.Debug($"{name} but wasn't ready");
return null;
}
// This check attempts to keep groups leaving the map, like guests or traders, from turning around to hook up
if (pawn.mindState?.duty?.def == DutyDefOf.TravelOrLeave)
{
// TODO: Some guest pawns keep the TravelOrLeave duty the whole time, I think the ones assigned to guard the pack animals.
// That's probably ok, though it wasn't the intention.
if (RJWSettings.DebugLogJoinInBed) _log.Debug($"JoinInBed.TryGiveJob:({xxx.get_pawnname(pawn)}): has TravelOrLeave, no time for lovin!");
return null;
}
if (pawn.CurJob == null || pawn.CurJob.def == JobDefOf.LayDown)
{
//--Log.Message(" checking pawn and abilities");
if (CasualSex_Helper.CanHaveSex(pawn))
{
//--Log.Message(" finding partner");
Pawn partner = CasualSex_Helper.find_partner(pawn, pawn.Map, true);
//--Log.Message(" checking partner");
if (partner == null)
{
_log.Debug($"{name} didn't find a partner");
return null;
}
// Can never be null, since find checks for bed.
Building_Bed bed = partner.CurrentBed();
// Interrupt current job.
if (pawn.CurJob != null && pawn.jobs.curDriver != null)
pawn.jobs.curDriver.EndJobWith(JobCondition.InterruptForced);
//--Log.Message(" returning job");
return JobMaker.MakeJob(xxx.casual_sex, partner, bed);
}
}
return null;
}
}
}
| Korth95/rjw | 1.5/Source/JobGivers/JobGiver_JoinInBed.cs | C# | mit | 2,387 |
using Verse;
using Verse.AI;
namespace rjw
{
/// <summary>
/// Attempts to give a lay egg job to an eligible humanoid.
/// </summary>
public class JobGiver_LayEgg : RimWorld.JobGiver_LayEgg
{
}
} | Korth95/rjw | 1.5/Source/JobGivers/JobGiver_LayEgg.cs | C# | mit | 203 |
using RimWorld;
using Verse;
using Verse.AI;
using System.Collections.Generic;
using System.Linq;
using Multiplayer.API;
namespace rjw
{
public class JobGiver_Masturbate : ThinkNode_JobGiver
{
protected override Job TryGiveJob(Pawn pawn)
{
//--ModLog.Message(" JobGiver_Masturbate::TryGiveJob( " + xxx.get_pawnname(pawn) + " ) called");
if (pawn.Drafted) return null;
if (!xxx.can_masturbate(pawn)) return null;
// Whores only fap if frustrated, unless imprisoned.
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)
{
if ((xxx.is_frustrated(pawn) || xxx.has_quirk(pawn, "Exhibitionist")) || bed.GetRoom().Role == RoomRoleDefOf.Bedroom || bed.GetRoom().Role == RoomRoleDefOf.PrisonCell)
return JobMaker.MakeJob(xxx.Masturbate, pawn, bed, bed.Position);
}
}
else if (RJWPreferenceSettings.FapEverywhere && (xxx.is_frustrated(pawn) || xxx.has_quirk(pawn, "Exhibitionist")))
{
var spot = CasualSex_Helper.FindSexLocation(pawn);
if (spot == null)
return null;
return JobMaker.MakeJob(xxx.Masturbate, pawn, null, spot);
}
}
return null;
}
}
} | Korth95/rjw | 1.5/Source/JobGivers/JobGiver_Masturbate.cs | C# | mit | 1,398 |
using System.Linq;
using RimWorld;
using Verse;
using Verse.AI;
using System.Collections.Generic;
using Multiplayer.API;
namespace rjw
{
public class JobGiver_RandomRape : ThinkNode_JobGiver
{
[SyncMethod]
public Pawn find_victim(Pawn pawn, Map m)
{
float min_fuckability = 0.10f; // Don't rape pawns with <10% fuckability
float avg_fuckability = 0f; // Average targets fuckability, choose target higher than that
var valid_targets = new Dictionary<Pawn, float>(); // Valid pawns and their fuckability
Pawn chosentarget = null; // Final target pawn
// could be prisoner, colonist, or non-hostile outsider
IEnumerable<Pawn> targets = m.mapPawns.AllPawnsSpawned.Where(x
=> x != pawn
&& xxx.is_not_dying(x)
&& xxx.can_get_raped(x)
&& !x.Suspended
&& !x.Drafted
&& !x.IsForbidden(pawn)
&& pawn.CanReserveAndReach(x, PathEndMode.Touch, Danger.Some, xxx.max_rapists_per_prisoner, 0)
&& !x.HostileTo(pawn)
);
//Zoo rape Animal
if (xxx.is_zoophile(pawn) && RJWSettings.bestiality_enabled)
{
foreach (Pawn target in targets.Where(x => xxx.is_animal(x)))
{
if (!Pather_Utility.cells_to_target_rape(pawn, target.Position))
continue;// too far
float fuc = SexAppraiser.would_fuck(pawn, target, true, true);
if (fuc > min_fuckability)
if (Pather_Utility.can_path_to_target(pawn, target.Position))
valid_targets.Add(target, fuc);
}
if (valid_targets.Any())
{
avg_fuckability = valid_targets.Average(x => x.Value);
// choose pawns to fuck with above average fuckability
var valid_targetsFilteredAnimals = valid_targets.Where(x => x.Value >= avg_fuckability);
if (valid_targetsFilteredAnimals.Any())
chosentarget = valid_targetsFilteredAnimals.RandomElement().Key;
return chosentarget;
}
}
valid_targets = new Dictionary<Pawn, float>();
// rape Humanlike
foreach (Pawn target in targets.Where(x => !xxx.is_animal(x)))
{
if (!Pather_Utility.cells_to_target_rape(pawn, target.Position))
continue;// too far
float fuc = SexAppraiser.would_fuck(pawn, target, true, true);
if (fuc > min_fuckability)
if (Pather_Utility.can_path_to_target(pawn, target.Position))
valid_targets.Add(target, fuc);
}
if (valid_targets.Any())
{
avg_fuckability = valid_targets.Average(x => x.Value);
// choose pawns to fuck with above average fuckability
var valid_targetsFilteredAnimals = valid_targets.Where(x => x.Value >= avg_fuckability);
if (valid_targetsFilteredAnimals.Any())
chosentarget = valid_targetsFilteredAnimals.RandomElement().Key;
}
return chosentarget;
}
protected override Job TryGiveJob(Pawn pawn)
{
//ModLog.Message(" JobGiver_RandomRape::TryGiveJob( " + xxx.get_pawnname(pawn) + " ) called");
if (!xxx.can_rape(pawn)) return null;
if (pawn.health.hediffSet.HasHediff(HediffDef.Named("Hediff_RapeEnemyCD"))) return null;
pawn.health.AddHediff(HediffDef.Named("Hediff_RapeEnemyCD"), null, null, null);
Pawn victim = find_victim(pawn, pawn.Map);
if (victim == null) return null;
//ModLog.Message(" JobGiver_RandomRape::TryGiveJob( " + xxx.get_pawnname(pawn) + " ) - found victim " + xxx.get_pawnname(victim));
return JobMaker.MakeJob(xxx.RapeRandom, victim);
}
}
} | Korth95/rjw | 1.5/Source/JobGivers/JobGiver_RandomRape.cs | C# | mit | 3,404 |
using Verse;
using Verse.AI;
using RimWorld;
namespace rjw
{
/// <summary>
/// Pawn try to find enemy to rape.
/// </summary>
public class JobGiver_RapeEnemy : ThinkNode_JobGiver
{
protected override Job TryGiveJob(Pawn pawn)
{
if (RJWSettings.DebugRape) ModLog.Message(" JobGiver_RapeEnemy::TryGiveJob( " + xxx.get_pawnname(pawn) + " ) called0");
//ModLog.Message(" JobGiver_RapeEnemy::TryGiveJob( " + xxx.get_pawnname(pawn) + " ) 0 " + SexUtility.ReadyForLovin(pawn));
//ModLog.Message(" JobGiver_RapeEnemy::TryGiveJob( " + xxx.get_pawnname(pawn) + " ) 1 " + (xxx.need_some_sex(pawn) <= 1f));
//ModLog.Message(" JobGiver_RapeEnemy::TryGiveJob( " + xxx.get_pawnname(pawn) + " ) 2 " + !(SexUtility.ReadyForLovin(pawn) || xxx.need_some_sex(pawn) <= 1f));
//ModLog.Message(" JobGiver_RapeEnemy::TryGiveJob( " + xxx.get_pawnname(pawn) + " ) 1 " + Find.TickManager.TicksGame);
//ModLog.Message(" JobGiver_RapeEnemy::TryGiveJob( " + xxx.get_pawnname(pawn) + " ) 2 " + pawn.mindState.canLovinTick);
if (pawn.Drafted) return null;
if (pawn.health.hediffSet.HasHediff(HediffDef.Named("Hediff_RapeEnemyCD")) || !pawn.health.capacities.CanBeAwake || !(SexUtility.ReadyForLovin(pawn) || xxx.need_some_sex(pawn) <= 1f))
//if (pawn.health.hediffSet.HasHediff(HediffDef.Named("Hediff_RapeEnemyCD")) || !pawn.health.capacities.CanBeAwake || (SexUtility.ReadyForLovin(pawn) || xxx.is_human(pawn) ? xxx.need_some_sex(pawn) <= 1f : false))
return null;
if (!xxx.can_rape(pawn)) return null;
if (RJWSettings.DebugRape) ModLog.Message(" JobGiver_RapeEnemy::TryGiveJob( " + xxx.get_pawnname(pawn) + " ) can rape");
JobDef_RapeEnemy rapeEnemyJobDef = null;
int? highestPriority = null;
foreach (JobDef_RapeEnemy job in DefDatabase<JobDef_RapeEnemy>.AllDefs)
{
if (job.CanUseThisJobForPawn(pawn))
{
if (highestPriority == null)
{
rapeEnemyJobDef = job;
highestPriority = job.priority;
}
else if (job.priority > highestPriority)
{
rapeEnemyJobDef = job;
highestPriority = job.priority;
}
}
}
if (rapeEnemyJobDef == null)
{
if (RJWSettings.DebugRape) ModLog.Message(" JobGiver_RapeEnemy::TryGiveJob( " + xxx.get_pawnname(pawn) + " ) no valid rapeEnemyJobDef found");
return null;
}
if (RJWSettings.DebugRape) ModLog.Message(" JobGiver_RapeEnemy::ChoosedJobDef( " + xxx.get_pawnname(pawn) + " ) - " + rapeEnemyJobDef?.ToString() + " choosen");
Pawn victim = rapeEnemyJobDef?.FindVictim(pawn, pawn.Map);
if (RJWSettings.DebugRape) ModLog.Message(" JobGiver_RapeEnemy::FoundVictim( " + xxx.get_pawnname(victim) + " )");
//prevents 10 job stacks error, no idea whats the prob with JobDriver_Rape
//if (victim != null)
pawn.health.AddHediff(HediffDef.Named("Hediff_RapeEnemyCD"), null, null, null);
return victim != null ? JobMaker.MakeJob(rapeEnemyJobDef, victim) : null;
/*
else
{
if (RJWSettings.DebugRape) ModLog.Message("" + this.GetType().ToString() + "::TryGiveJob( " + xxx.get_pawnname(pawn) + " ) - unable to find victim");
pawn.mindState.canLovinTick = Find.TickManager.TicksGame + Rand.Range(75, 150);
}
*/
//else { if (RJWSettings.DebugRape) ModLog.Message(" JobGiver_RapeEnemy::TryGiveJob( " + xxx.get_pawnname(pawn) + " ) - too fast to play next"); }
}
}
} | Korth95/rjw | 1.5/Source/JobGivers/JobGiver_RapeEnemy.cs | C# | mit | 3,345 |
using RimWorld;
using Verse;
using Verse.AI;
using System.Collections.Generic;
using System.Linq;
using Multiplayer.API;
namespace rjw
{
public class JobGiver_ViolateCorpse : ThinkNode_JobGiver
{
[SyncMethod]
public static Corpse find_corpse(Pawn pawn, Map m)
{
float min_fuckability = 0.10f; // Don't rape pawns with <10% fuckability
float avg_fuckability = 0f; // Average targets fuckability, choose target higher than that
var valid_targets = new Dictionary<Corpse, float>(); // Valid pawns and their fuckability
Corpse chosentarget = null; // Final target pawn
IEnumerable<Thing> targets = m.spawnedThings.Where(x
=> x is Corpse
&& pawn.CanReserveAndReach(x, PathEndMode.OnCell, Danger.Some)
&& !x.IsForbidden(pawn)
);
foreach (Corpse target in targets)
{
if (!Pather_Utility.cells_to_target_rape(pawn, target.Position))
continue;// too far
// Filter out rotters if not necrophile.
if (!xxx.is_necrophiliac(pawn) && target.CurRotDrawMode != RotDrawMode.Fresh)
continue;
float fuc = SexAppraiser.would_fuck(pawn, target, false, false);
if (fuc > min_fuckability)
if (Pather_Utility.can_path_to_target(pawn, target.Position))
valid_targets.Add(target, fuc);
}
if (valid_targets.Any())
{
avg_fuckability = valid_targets.Average(x => x.Value);
// choose pawns to fuck with above average fuckability
var valid_targetsFilteredAnimals = valid_targets.Where(x => x.Value >= avg_fuckability);
if (valid_targetsFilteredAnimals.Any())
chosentarget = valid_targetsFilteredAnimals.RandomElement().Key;
}
return chosentarget;
}
protected override Job TryGiveJob(Pawn pawn)
{
// Most checks are done in ThinkNode_ConditionalNecro.
// filter out necro for nymphs
if (!RJWSettings.necrophilia_enabled) return null;
if (pawn.Drafted) return null;
//--ModLog.Message(" JobGiver_ViolateCorpse::TryGiveJob for ( " + xxx.get_pawnname(pawn) + " )");
if (SexUtility.ReadyForLovin(pawn) || xxx.is_hornyorfrustrated(pawn))
{
//--ModLog.Message(" JobGiver_ViolateCorpse::TryGiveJob, can love ");
if (!xxx.can_rape(pawn)) return null;
var target = find_corpse(pawn, pawn.Map);
//--ModLog.Message(" JobGiver_ViolateCorpse::TryGiveJob - target is " + (target == null ? "NULL" : "Found"));
if (target != null)
{
return JobMaker.MakeJob(xxx.RapeCorpse, target);
}
// Ticks should only be increased after successful sex.
}
return null;
}
}
} | Korth95/rjw | 1.5/Source/JobGivers/JobGiver_ViolateCorpse.cs | C# | mit | 2,617 |
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using RimWorld;
using Verse.AI;
using Verse;
namespace rjw
{
public class MentalState_RandomRape : SexualMentalState
{
public override void PostStart(string reason)
{
base.PostStart(reason);
this.pawn.mindState.canLovinTick = -1;
}
public override bool ForceHostileTo(Thing t)
{
/*
//planning random raper hostile to other colonists. but now, injured raper wont rape.
if ((this.pawn.jobs != null) &&
(this.pawn.jobs.curDriver != null) &&
(this.pawn.jobs.curDriver as JobDriver_Rape != null))
{
return true;
}*/
return false;
}
public override bool ForceHostileTo(Faction f)
{
/*
if ((this.pawn.jobs != null) &&
(this.pawn.jobs.curDriver != null) &&
(this.pawn.jobs.curDriver as JobDriver_Rape != null))
{
return true;
}*/
return false;
}
public override RandomSocialMode SocialModeMax()
{
return RandomSocialMode.Off;
}
}
}
| Korth95/rjw | 1.5/Source/MentalStates/MentalState_RandomRape.cs | C# | mit | 1,007 |
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using RimWorld;
using Verse.AI;
using Verse;
namespace rjw
{
public class SexualMentalState : MentalState
{
public override void MentalStateTick()
{
if (this.pawn.IsHashIntervalTick(150))
{
if (xxx.is_satisfied(pawn))
if (!(pawn.jobs?.curDriver is JobDriver_Sex))
{
this.RecoverFromState();
return;
}
}
base.MentalStateTick();
}
}
public class SexualMentalStateWorker : MentalStateWorker
{
public override bool StateCanOccur(Pawn pawn)
{
if (base.StateCanOccur(pawn))
{
return xxx.is_human(pawn) && xxx.can_rape(pawn) && xxx.is_hornyorfrustrated(pawn);
}
else
{
return false;
}
}
}
public class SexualMentalBreakWorker : MentalBreakWorker
{
public override float CommonalityFor(Pawn pawn, bool moodCaused = false)
{
if (xxx.is_human(pawn))
{
var need_sex = pawn.needs.TryGetNeed<Need_Sex>();
if (need_sex != null)
return base.CommonalityFor(pawn) * (def as SexualMentalBreakDef).commonalityMultiplierBySexNeed.Evaluate(need_sex.CurLevelPercentage * 100f);
else
return 0;
}
else
{
return 0;
}
}
}
public class SexualMentalStateDef : MentalStateDef
{
}
public class SexualMentalBreakDef : MentalBreakDef
{
public SimpleCurve commonalityMultiplierBySexNeed;
}
}
| Korth95/rjw | 1.5/Source/MentalStates/SexualMentalState.cs | C# | mit | 1,399 |
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Verse;
namespace rjw
{
/// <summary>
/// Helper class for ChJees's Androids mod.
/// </summary>
[StaticConstructorOnStartup]
public static class AndroidsCompatibility
{
public static Type androidCompatType;
public static readonly string typeName = "Androids.SexualizeAndroidRJW";
private static bool foundType;
static AndroidsCompatibility()
{
try
{
androidCompatType = Type.GetType(typeName);
foundType = true;
//Log.Message("Found Type: Androids.SexualizeAndroidRJW");
}
catch
{
foundType = false;
//Log.Message("Did NOT find Type: Androids.SexualizeAndroidRJW");
}
}
/*private static bool TestPredicate(DefModExtension extension)
{
if (extension == null)
return false;
Log.Message($"Predicate: {extension} : {extension.GetType()?.FullName}");
return extension.GetType().FullName == typeName;
}*/
public static bool IsAndroid(ThingDef def)
{
if (def == null || !foundType)
{
return false;
}
return def.modExtensions != null && def.modExtensions.Any(extension => extension.GetType().FullName == typeName);
}
public static bool IsAndroid(Thing thing)
{
return IsAndroid(thing.def);
}
public static bool AndroidPenisFertility(Pawn pawn)
{
//androids only fertile with archotech parts
BodyPartRecord Part = Genital_Helper.get_genitalsBPR(pawn);
return (pawn.health.hediffSet.hediffs.Any((Hediff hed) =>
(hed.Part == Part) &&
(hed.def == Genital_Helper.archotech_penis)
));
}
public static bool AndroidVaginaFertility(Pawn pawn)
{
//androids only fertile with archotech parts
BodyPartRecord Part = Genital_Helper.get_genitalsBPR(pawn);
return (pawn.health.hediffSet.hediffs.Any((Hediff hed) =>
(hed.Part == Part) &&
(hed.def == Genital_Helper.archotech_vagina)
));
}
}
}
| Korth95/rjw | 1.5/Source/Modules/Androids/AndroidsCompatibility.cs | C# | mit | 1,934 |
using System;
using System.Text;
using System.Linq;
using UnityEngine;
using Verse;
using RimWorld;
using RimWorld.Planet;
namespace rjw.Modules.Benchmark
{
// RimWorld only instantiates WorldComponents that exist, so if benchmarking
// is not enabled, this class does not exist and never gets added to the game.
// So, it wastes no resources at all.
#if BENCHMARK
public class BenchmarkComponent : WorldComponent
{
const int loggingInterval = GenDate.TicksPerHour;
const long maxNano = 1000L;
const long maxMicro = maxNano * maxNano;
const long maxMilli = maxNano * maxNano * maxNano;
public BenchmarkComponent(World world) : base(world) { }
public override void WorldComponentTick()
{
if (Find.TickManager.TicksGame % loggingInterval != 0) return;
foreach (var record in BenchmarkCore.GetSamples().OrderBy((s) => s.methodName))
LogResults(record);
}
private void LogResults(BenchyRecord record)
{
// Sort it so we can make some assumptions.
record.samples.InsertionSort((l, r) => l.CompareTo(r));
var methodName = record.methodName;
var totalCalls = record.totalCalls;
var length = record.samples.Length;
var totalRuntime = record.samples.Sum();
var averageNanoSecs = (float)record.samples.Average();
var minNanoSecs = record.samples.First();
var maxNanoSecs = record.samples.Last();
(var loAvg, var hiAvg) = GetSplitPercentile(record.samples);
StringBuilder sb = new();
sb.Append("Benchy<").Append(methodName).Append(">(");
sb.Append("avg: ").Append(ToUnitString(averageNanoSecs)).Append(", ");
sb.Append("lo90%: ").Append(ToUnitString(loAvg)).Append(", ");
sb.Append("hi10%: ").Append(ToUnitString(hiAvg)).Append(", ");
sb.Append("min: ").Append(ToUnitString(minNanoSecs)).Append(", ");
sb.Append("max: ").Append(ToUnitString(maxNanoSecs)).Append(")");
sb.AppendLine().Append(" Total calls: ")
.Append(totalCalls);
sb.AppendLine().Append(" Total of last ").Append(length).Append(" samples: ")
.Append(ToUnitString(totalRuntime));
ModLog.Message(sb.ToString());
}
private (float, float) GetSplitPercentile(long[] samples)
{
var hiRange = Math.Max(Mathf.CeilToInt(0.1f * samples.Length), 1);
var loRange = Math.Max(samples.Length - hiRange, 1);
var hiAvg = (float)samples.TakeLast(hiRange).Average();
var loAvg = (float)samples.Take(loRange).Average();
return (loAvg, hiAvg);
}
private string ToUnitString(long nanoSecs) => nanoSecs switch
{
< maxNano => $"{nanoSecs}ns",
_ => ToUnitString((float)nanoSecs)
};
private string ToUnitString(float nanoSecs) => nanoSecs switch
{
< maxNano => $"{nanoSecs:F3}ns",
< maxMicro => $"{nanoSecs / maxNano:F3}µs",
< maxMilli => $"{nanoSecs / maxMicro:F3}ms",
_ => $"{nanoSecs / maxMilli:F3}s"
};
}
#endif
} | Korth95/rjw | 1.5/Source/Modules/Benchmark/BenchmarkComponent.cs | C# | mit | 2,821 |
using System.Diagnostics;
using System.Collections.Generic;
using Verse;
namespace rjw.Modules.Benchmark
{
#if BENCHMARK
/// <summary>
/// <para>BENCHMARKING ENABLED!</para>
/// <para>A disposable ref-struct that represents a running benchmark.</para>
/// <para>You must enable the `BENCHMARK` compiler constant to enable this.</para>
/// <example>
/// <para>To benchmark a method, the simplest way is to place a `using` expression
/// at the start of the method. The unused variable is required by this form of
/// `using`.</para>
/// <code>
/// // Pull in the benchy type at the top of the C# file.
/// using Benchy = rjw.Modules.Benchmark.Benchy;
///
/// void MethodToTest()
/// {
/// using var _benchy = Benchy.Watch(nameof(MethodToTest));
/// DoNormalMethodThings();
/// }
/// </code>
/// <para>When the method returns, the ref-struct is disposed, which records the
/// run time of the function.</para>
/// <para>A `using` block also works, if you prefer that. Then you don't even need
/// to define a variable, if that bugs you.</para>
/// </example>
/// </summary>
public ref struct Benchy
{
private string methodName;
private int warmupCalls;
private readonly Stopwatch stopwatch;
private Benchy(string methodName, int warmupCalls)
{
this.methodName = methodName;
this.warmupCalls = warmupCalls;
stopwatch = new Stopwatch();
stopwatch.Start();
}
public void Dispose()
{
stopwatch.Stop();
BenchmarkCore.AddResult(methodName, warmupCalls, stopwatch.ElapsedTicks);
}
/// <summary>
/// <para>BENCHMARKING ENABLED!</para>
/// <para>Begins timing a method from this point until disposed.</para>
/// <para>If your method is called rarely, set `warmupCalls` lower, as needed.</para>
/// </summary>
/// <param name="methodName">The name of the method.</param>
/// <param name="warmupCalls">How many calls to skip before taking samples.</param>
/// <returns>A benchy instance, representing a benchmark context.</returns>
public static Benchy Watch(string methodName, int warmupCalls = 10) =>
new(methodName, warmupCalls);
}
public struct BenchyRecord
{
/// <summary>
/// The name of the method benchmarked.
/// </summary>
public string methodName;
/// <summary>
/// <para>The total number of calls seen thus far.</para>
/// <para>Note: the number of samples may not match this value.</para>
/// </summary>
public long totalCalls;
/// <summary>
/// The recorded sample times, in integer nanoseconds.
/// </summary>
public long[] samples;
public BenchyRecord(string methodName, long totalCalls, long[] samples)
{
this.methodName = methodName;
this.totalCalls = totalCalls;
this.samples = samples;
}
}
public static class BenchmarkCore
{
const int MAX_SAMPLES = 1000;
static readonly long nanoSecsPerTick = 1000L * 1000L * 1000L / Stopwatch.Frequency;
/// <summary>
/// <para>Stores the samples of the benchmarked methods.</para>
/// <para>The results are stored in integer nanoseconds.</para>
/// </summary>
static readonly Dictionary<string, Queue<long>> samples = new();
/// <summary>
/// <para>Stores the number of times each method was called.</para>
/// </summary>
static readonly Dictionary<string, long> callCounts = new();
public static void AddResult(string methodName, int warmupCalls, long ticks)
{
var totalCalls = callCounts.GetWithFallback(methodName, 0L) + 1L;
callCounts.SetOrAdd(methodName, totalCalls);
// Let a few calls go without logging. This warms up the jitter.
if (totalCalls <= warmupCalls) return;
// The call was too fast to really get a good read. Use a minimum.
ticks = ticks == 0L ? 1L : ticks;
var resultStore = samples.TryGetValue(methodName, out var q) ? q : new();
// Drop samples if we have too many.
while (resultStore.Count >= MAX_SAMPLES)
resultStore.Dequeue();
resultStore.Enqueue(ticks * nanoSecsPerTick);
samples.SetOrAdd(methodName, resultStore);
}
/// <summary>
/// <para>Yields the current results of benchmarks.</para>
/// <para>The `samples` are copied arrays, so are safe to manipulate.</para>
/// </summary>
/// <returns>An enumerable of benchmark records.</returns>
public static IEnumerable<BenchyRecord> GetSamples()
{
foreach (var kvp in samples)
{
// Only bother if we have at least one sample.
if (kvp.Value.Count == 0) continue;
var totalCalls = callCounts.GetWithFallback(kvp.Key, 0L);
yield return new BenchyRecord(kvp.Key, totalCalls, kvp.Value.ToArray());
}
}
}
#else
/// <summary>
/// <para>BENCHMARKING DISABLED!</para>
/// <para>Dummy ref-struct used when benchmarking is disabled.</para>
/// <para>You must enable the `BENCHMARK` compiler constant to enable this.</para>
/// <para>This allows for leaving `Benchy.Watch()` around the code with minimal
/// effects on performance.</para>
/// <para>But, you should remove them when you no longer intend to benchmark.</para>
/// </summary>
public ref struct Benchy
{
private Benchy(string methodName) { }
public void Dispose() { }
/// <summary>
/// <para>BENCHMARKING DISABLED!</para>
/// <para>Does nothing useful without the `BENCHMARK` compiler constant defined.</para>
/// </summary>
/// <param name="methodName">The name of the method.</param>
/// <param name="warmupCalls">How many calls to skip before taking samples.</param>
/// <returns>A new dummy instance that does nothing.</returns>
public static Benchy Watch(string methodName, int warmupCalls = 10) =>
new(methodName);
}
#endif
} | Korth95/rjw | 1.5/Source/Modules/Benchmark/BenchmarkCore.cs | C# | mit | 5,599 |
using System.Collections.Generic;
using RimWorld;
using Verse;
using Verse.AI;
// Adds options to the right-click menu for bondage gear to equip the gear on prisoners/downed pawns
namespace rjw
{
public class CompBondageGear : CompUsable
{
public override IEnumerable<FloatMenuOption> CompFloatMenuOptions(Pawn pawn)
{
if ((pawn.Map != null) && (pawn.Map == Find.CurrentMap))// && (pawn.Map.mapPawns.PrisonersOfColonyCount > 0)
{
if (!pawn.CanReserve(parent))
yield return new FloatMenuOption(FloatMenuOptionLabel(pawn) + " on (" + "Reserved".Translate() + ")", null, MenuOptionPriority.DisabledOption);
else if (pawn.CanReach(parent, PathEndMode.Touch, Danger.Some))
foreach (Pawn other in pawn.Map.mapPawns.AllPawns)
if ((other != pawn) && other.Spawned && (other.Downed || other.IsPrisonerOfColony || xxx.is_slave(other)))
yield return this.make_option(FloatMenuOptionLabel(pawn) + " on " + xxx.get_pawnname(other), pawn, other, (other.IsPrisonerOfColony || xxx.is_slave(other)) ? WorkTypeDefOf.Warden : null);
}
}
}
} | Korth95/rjw | 1.5/Source/Modules/Bondage/Comps/CompBondageGear.cs | C# | mit | 1,074 |
using System;
using RimWorld;
using Verse;
using Multiplayer.API;
namespace rjw
{
public class CompCryptoStamped : ThingComp
{
public string name;
public string key;
[SyncMethod]
public string random_hex_byte()
{
//Rand.PopState();
//Rand.PushState(RJW_Multiplayer.PredictableSeed());
var rv = Rand.RangeInclusive(0x00, 0xFF);
var padding = (rv < 0x10) ? "0" : "";
return padding + rv.ToString("X");
}
public override void Initialize(CompProperties pro)
{
name = NameGenerator.GenerateName(RulePackDef.Named("EngravedName"));
key = "";
for (int i = 0; i < 16; ++i)
key += random_hex_byte();
}
public override void PostExposeData()
{
base.PostExposeData();
Scribe_Values.Look<string>(ref name, "engraved_name");
Scribe_Values.Look<string>(ref key, "cryptostamp");
}
public override bool AllowStackWith(Thing t)
{
return false;
}
public override string CompInspectStringExtra()
{
var inspect_engraving = "Engraved with the name \"" + name + "\"";
var inspect_key = "Cryptostamp: " + key;
return base.CompInspectStringExtra() + inspect_engraving + "\n" + inspect_key;
}
public override string TransformLabel(string lab)
{
return lab + " \"" + name + "\"";
}
public bool matches(CompHoloCryptoStamped other)
{
return String.Equals(key, other.key);
}
public void copy_stamp_from(CompHoloCryptoStamped other)
{
name = other.name;
key = other.key;
}
}
public class CompProperties_CryptoStamped : CompProperties
{
public CompProperties_CryptoStamped()
{
compClass = typeof(CompHoloCryptoStamped);
}
}
} | Korth95/rjw | 1.5/Source/Modules/Bondage/Comps/CompCryptoStamped.cs | C# | mit | 1,637 |
using RimWorld;
using Verse;
namespace rjw
{
public class CompGetBondageGear : CompUseEffect
{
public override float OrderPriority
{
get
{
return -79;
}
}
public override void DoEffect(Pawn p)
{
base.DoEffect(p);
var app = parent as Apparel;
if ((p.apparel != null) && (app != null))
p.apparel.Wear(app);
}
}
} | Korth95/rjw | 1.5/Source/Modules/Bondage/Comps/CompGetBondageGear.cs | C# | mit | 356 |
using System;
using RimWorld;
using Verse;
using Multiplayer.API;
namespace rjw
{
public class CompHoloCryptoStamped : ThingComp
{
public string name;
public string key;
[SyncMethod]
public string random_hex_byte()
{
//Rand.PopState();
//Rand.PushState(RJW_Multiplayer.PredictableSeed());
var rv = Rand.RangeInclusive(0x00, 0xFF);
var padding = (rv < 0x10) ? "0" : "";
return padding + rv.ToString("X");
}
public override void Initialize(CompProperties pro)
{
name = NameGenerator.GenerateName(RulePackDef.Named("EngravedName"));
key = "";
for (int i = 0; i < 16; ++i)
key += random_hex_byte();
}
public override void PostExposeData()
{
base.PostExposeData();
Scribe_Values.Look<string>(ref name, "engraved_name");
Scribe_Values.Look<string>(ref key, "cryptostamp");
}
public override bool AllowStackWith(Thing t)
{
return false;
}
public override string CompInspectStringExtra()
{
var inspect_engraving = "Engraved with the name \"" + name + "\"";
var inspect_key = "Cryptostamp: " + key;
return base.CompInspectStringExtra() + inspect_engraving + "\n" + inspect_key;
}
public override string TransformLabel(string lab)
{
return lab + " \"" + name + "\"";
}
public bool matches(CompHoloCryptoStamped other)
{
return String.Equals(key, other.key);
}
public void copy_stamp_from(CompHoloCryptoStamped other)
{
name = other.name;
key = other.key;
}
}
public class CompProperties_HoloCryptoStamped : CompProperties
{
public CompProperties_HoloCryptoStamped()
{
compClass = typeof(CompHoloCryptoStamped);
}
}
} | Korth95/rjw | 1.5/Source/Modules/Bondage/Comps/CompHoloCryptoStamped.cs | C# | mit | 1,649 |
using System.Collections.Generic;
using RimWorld;
using Verse;
using Verse.AI;
// Adds unlock options to right-click menu for holokeys.
namespace rjw
{
public class CompStampedApparelKey : CompUsable
{
protected string make_label(Pawn pawn, Pawn other)
{
return FloatMenuOptionLabel(pawn) + " on " + ((other == null) ? "self" : xxx.get_pawnname(other));
}
public override IEnumerable<FloatMenuOption> CompFloatMenuOptions(Pawn pawn)
{
if (!pawn.CanReserve(parent))
yield return new FloatMenuOption(FloatMenuOptionLabel(pawn) + " (" + "Reserved".Translate() + ")", null, MenuOptionPriority.DisabledOption);
else if (pawn.CanReach(parent, PathEndMode.Touch, Danger.Some))
{
// Option for the pawn to use the key on themself
if (!pawn.is_wearing_locked_apparel())
yield return new FloatMenuOption("Not wearing locked apparel", null, MenuOptionPriority.DisabledOption);
else
yield return this.make_option(make_label(pawn, null), pawn, null, null);
if ((pawn.Map != null) && (pawn.Map == Find.CurrentMap))
{
// Options for use on colonists
foreach (var other in pawn.Map.mapPawns.FreeColonists)
if ((other != pawn) && other.is_wearing_locked_apparel())
yield return this.make_option(make_label(pawn, other), pawn, other, null);
// Options for use on prisoners
foreach (var prisoner in pawn.Map.mapPawns.PrisonersOfColony)
if (prisoner.is_wearing_locked_apparel())
yield return this.make_option(make_label(pawn, prisoner), pawn, prisoner, WorkTypeDefOf.Warden);
// Options for use on corpses
foreach (var q in pawn.Map.listerThings.ThingsInGroup(ThingRequestGroup.Corpse))
{
var corpse = q as Corpse;
if (corpse.InnerPawn.is_wearing_locked_apparel())
yield return this.make_option(make_label(pawn, corpse.InnerPawn), pawn, corpse, null);
}
}
}
}
}
} | Korth95/rjw | 1.5/Source/Modules/Bondage/Comps/CompStampedApparelKey.cs | C# | mit | 1,904 |
using RimWorld;
using Verse;
namespace rjw
{
public class CompUnlockBondageGear : CompUseEffect
{
public override float OrderPriority
{
get
{
return -69;
}
}
public override void DoEffect(Pawn p)
{
base.DoEffect(p);
var key_stamp = parent.GetComp<CompHoloCryptoStamped>();
if ((key_stamp == null) || (p.MapHeld == null) || (p.apparel == null))
return;
Apparel locked_app = null;
var any_locked = false;
{
foreach (var app in p.apparel.WornApparel)
{
var app_stamp = app.GetComp<CompHoloCryptoStamped>();
if (app_stamp != null)
{
any_locked = true;
if (app_stamp.matches(key_stamp))
{
locked_app = app;
break;
}
}
}
}
if (locked_app != null)
{
//locked_app.Notify_Stripped (p); // TODO This was removed. Necessary?
p.apparel.Remove(locked_app);
Thing dropped = null;
GenThing.TryDropAndSetForbidden(locked_app, p.Position, p.MapHeld, ThingPlaceMode.Near, out dropped, false); //this will create a new key somehow.
if (dropped != null)
{
Messages.Message("Unlocked " + locked_app.def.label, p, MessageTypeDefOf.SilentInput);
IntVec3 keyPostition = parent.Position;
parent.Destroy();
}
else if (PawnUtility.ShouldSendNotificationAbout(p))
{
Messages.Message("Couldn't drop " + locked_app.def.label, p, MessageTypeDefOf.NegativeEvent);
}
}
else if (any_locked)
Messages.Message("The key doesn't fit!", p, MessageTypeDefOf.NegativeEvent);
}
}
} | Korth95/rjw | 1.5/Source/Modules/Bondage/Comps/CompUnlockBondageGear.cs | C# | mit | 1,547 |
using System.Collections.Generic;
using RimWorld;
using Verse;
using Verse.AI;
namespace rjw
{
public class JobDriver_StruggleInBondageGear : JobDriver
{
public Apparel target_gear
{
get
{
return (Apparel)TargetA.Thing;
}
}
public override bool TryMakePreToilReservations(bool errorOnFailed)
{
return this.pawn.Reserve(this.target_gear, this.job, 1, -1, null, errorOnFailed);
}
protected override IEnumerable<Toil> MakeNewToils()
{
yield return new Toil
{
initAction = delegate
{
pawn.pather.StopDead();
},
defaultCompleteMode = ToilCompleteMode.Delay,
defaultDuration = 60
};
yield return new Toil
{
initAction = delegate
{
if (PawnUtility.ShouldSendNotificationAbout(pawn))
{
var pro = (pawn.gender == Gender.Male) ? "his" : "her";
Messages.Message(xxx.get_pawnname(pawn) + " struggles to remove " + pro + " " + target_gear.def.label + ". It's no use!", pawn, MessageTypeDefOf.NegativeEvent);
}
},
defaultCompleteMode = ToilCompleteMode.Instant
};
}
}
} | Korth95/rjw | 1.5/Source/Modules/Bondage/JobDrivers/JobDriver_StruggleInBondageGear.cs | C# | mit | 1,085 |
using System.Collections.Generic;
using RimWorld;
using Verse;
using Verse.AI;
namespace rjw
{
public class JobDriver_UseItemOn : JobDriver_UseItem
{
public static Toil pickup_item(Pawn p, Thing item)
{
return new Toil
{
initAction = delegate
{
p.carryTracker.TryStartCarry(item, 1);
if (item.Spawned) // If the item is still spawned that means the pawn failed to pick it up
p.jobs.curDriver.EndJobWith(JobCondition.Incompletable);
},
defaultCompleteMode = ToilCompleteMode.Instant
};
}
protected TargetIndex iitem = TargetIndex.A;
protected TargetIndex itar = TargetIndex.B;
protected Thing item
{
get
{
return base.job.GetTarget(iitem).Thing;
}
}
protected Thing tar
{
get
{
return base.job.GetTarget(itar).Thing;
}
}
protected override IEnumerable<Toil> MakeNewToils()
{
if (tar == null)
foreach (var toil in base.MakeNewToils())
yield return toil;
else
{
// Find the pawn to use the item on.
Pawn other;
{
var corpse = tar as Corpse;
other = (corpse == null) ? (Pawn)tar : corpse.InnerPawn;
}
this.FailOnDespawnedNullOrForbidden(itar);
if (!other.Dead)
this.FailOnAggroMentalState(itar);
yield return Toils_Reserve.Reserve(itar);
if ((pawn.inventory != null) && pawn.inventory.Contains(item))
{
yield return Toils_Misc.TakeItemFromInventoryToCarrier(pawn, iitem);
}
else
{
yield return Toils_Reserve.Reserve(iitem);
yield return Toils_Goto.GotoThing(iitem, PathEndMode.ClosestTouch).FailOnForbidden(iitem);
yield return pickup_item(pawn, item);
}
yield return Toils_Goto.GotoThing(itar, PathEndMode.Touch);
yield return new Toil
{
initAction = delegate
{
if (!other.Dead)
PawnUtility.ForceWait(other, 60);
},
defaultCompleteMode = ToilCompleteMode.Delay,
defaultDuration = 60
};
yield return new Toil
{
initAction = delegate
{
var effective_item = item;
// Drop the item if it's some kind of apparel. This is because ApparelTracker.Wear only works properly
// if the apparel to wear is spawned. (I'm just assuming that DoEffect for apparel wears it, which is
// true for bondage gear)
if ((effective_item as Apparel) != null)
{
Thing dropped_thing;
if (pawn.carryTracker.TryDropCarriedThing(pawn.Position, ThingPlaceMode.Near, out dropped_thing))
effective_item = dropped_thing as Apparel;
else
{
ModLog.Error("Unable to drop " + effective_item.Label + " for use on " + xxx.get_pawnname(other) + " (apparel must be dropped before use)");
effective_item = null;
}
}
if (effective_item != null)
{
var eff = effective_item.TryGetComp<CompUseEffect>();
if (eff != null)
eff.DoEffect(other);
else
ModLog.Error("Unable to get CompUseEffect for use of " + effective_item.Label + " on " + xxx.get_pawnname(other) + " by " + xxx.get_pawnname(pawn));
}
},
defaultCompleteMode = ToilCompleteMode.Instant
};
}
}
}
} | Korth95/rjw | 1.5/Source/Modules/Bondage/JobDrivers/JobDriver_UseItemOn.cs | C# | mit | 3,171 |
using System.Collections.Generic;
using RimWorld;
using Verse;
namespace rjw
{
public class Recipe_InstallChastityBelt : Recipe_InstallImplant
{
public override IEnumerable<BodyPartRecord> GetPartsToApplyOn(Pawn p, RecipeDef r)
{
return base.GetPartsToApplyOn(p, r);
}
}
public class Recipe_UnlockChastityBelt : Recipe_InstallImplant
{
public override IEnumerable<BodyPartRecord> GetPartsToApplyOn(Pawn p, RecipeDef r)
{
return base.GetPartsToApplyOn(p, r);
}
}
} | Korth95/rjw | 1.5/Source/Modules/Bondage/Recipes/Recipe_ChastityBelt.cs | C# | mit | 492 |
using System.Collections.Generic;
using RimWorld;
using Verse;
using Multiplayer.API;
namespace rjw
{
public class Recipe_ForceOffGear : Recipe_Surgery
{
public static bool is_wearing(Pawn p, ThingDef apparel_def)
{
if (p.apparel != null)
foreach (var app in p.apparel.WornApparel)
if (app.def == apparel_def)
return true;
return false;
}
public static BodyPartRecord find_part_record(BodyPartDef part_def, Pawn p)
{
return p.RaceProps.body.AllParts.Find((BodyPartRecord bpr) => bpr.def == part_def);
}
// Puts the recipe in the operations list only if "p" is wearing the relevant apparel. The little trick here is that yielding
// null causes the game to put the recipe in the list but not actually apply it to a body part.
public override IEnumerable<BodyPartRecord> GetPartsToApplyOn(Pawn p, RecipeDef generic_def)
{
var r = (force_off_gear_def)generic_def;
if (is_wearing(p, r.removes_apparel))
yield return null;
}
[SyncMethod]
public static void apply_burns(Pawn p, List<BodyPartDef> parts, float min_severity, float max_severity)
{
foreach (var part in parts)
{
var rec = find_part_record(part, p);
if (rec != null)
{
//Rand.PopState();
//Rand.PushState(RJW_Multiplayer.PredictableSeed());
var to_deal = Rand.Range(min_severity, max_severity) * part.GetMaxHealth(p);
var dealt = 0.0f;
var counter = 0;
while ((counter < 100) && (dealt < to_deal) && (!p.health.hediffSet.PartIsMissing(rec)))
{
var dam = Rand.RangeInclusive(3, 5);
p.TakeDamage(new DamageInfo(DamageDefOf.Burn, dam, 999, -1.0f, null, rec, null));
++counter;
dealt += (float)dam;
}
}
}
}
[SyncMethod]
public override void ApplyOnPawn(Pawn p, BodyPartRecord null_part, Pawn surgeon, List<Thing> ingredients,Bill bill)
{
var r = (force_off_gear_def)recipe;
if ((surgeon != null) &&
(p.apparel != null) &&
(!CheckSurgeryFail(surgeon, p, ingredients, find_part_record(r.failure_affects, p),bill)))
{
// Remove apparel
foreach (var app in p.apparel.WornApparel)
if (app.def == r.removes_apparel)
{
p.apparel.Remove(app);
break;
}
// Destroy parts
//Rand.PopState();
//Rand.PushState(RJW_Multiplayer.PredictableSeed());
var def_to_destroy = r.destroys_one_of.RandomElement<BodyPartDef>();
if (def_to_destroy != null)
{
var record_to_destroy = find_part_record(def_to_destroy, p);
if (record_to_destroy != null)
{
var dam = (int)(1.5f * def_to_destroy.GetMaxHealth(p));
p.TakeDamage(new DamageInfo(DamageDefOf.Burn, dam, 999, -1.0f, null, record_to_destroy, null));
}
}
if (r.major_burns_on != null)
apply_burns(p, r.major_burns_on, 0.30f, 0.60f);
if (r.minor_burns_on != null)
apply_burns(p, r.minor_burns_on, 0.15f, 0.35f);
}
}
}
} | Korth95/rjw | 1.5/Source/Modules/Bondage/Recipes/Recipe_ForceOffGear.cs | C# | mit | 2,904 |
using RimWorld;
using Verse;
namespace rjw
{
public class ThoughtWorker_Bound : ThoughtWorker
{
protected override ThoughtState CurrentStateInternal(Pawn p)
{
if (p.apparel != null)
{
bool bound = false, gagged = false;
foreach (var app in p.apparel.WornApparel)
{
var gear_def = app.def as bondage_gear_def;
if (gear_def != null)
{
bound |= gear_def.gives_bound_moodlet;
gagged |= gear_def.gives_gagged_moodlet;
}
}
if (bound && gagged)
return ThoughtState.ActiveAtStage(2);
else if (gagged)
return ThoughtState.ActiveAtStage(1);
else if (bound)
return ThoughtState.ActiveAtStage(0);
}
return ThoughtState.Inactive;
}
}
} | Korth95/rjw | 1.5/Source/Modules/Bondage/Thoughts/ThoughtWorker_Bound.cs | C# | mit | 723 |
using System;
using System.Collections.Generic;
using System.Linq;
using RimWorld;
using Verse;
using Verse.AI;
namespace rjw
{
//public static class bondage_gear_tradeability
//{
// public static void init()
// {
// // Allows bondage gear to be selled by traders
// if (xxx.config.bondage_gear_enabled)
// {
// foreach (var def in DefDatabase<bondage_gear_def>.AllDefs)
// def.tradeability = Tradeability.Sellable;
// }
// // Forbids bondage gear to be selled by traders
// else
// {
// foreach (var def in DefDatabase<bondage_gear_def>.AllDefs)
// def.tradeability = Tradeability.None;
// }
// }
//}
public static class bondage_gear_extensions
{
public static bool has_lock(this Apparel app)
{
return (app.TryGetComp<CompHoloCryptoStamped>() != null);
}
public static bool is_wearing_locked_apparel(this Pawn p)
{
if (p.apparel != null)
foreach (var app in p.apparel.WornApparel)
if (app.has_lock())
return true;
return false;
}
// Tries to get p started on the job of using an item on either another pawn or on themself (if "other" is null).
// Of course in order for this method to work, the item's useJob has to be able to handle use on another pawn. This
// is true for the holokey and bondage gear in RJW but not the items in the core game
public static void start_job(this CompUsable usa, Pawn p, LocalTargetInfo tar)
{
if (p.CanReserveAndReach(usa.parent, PathEndMode.Touch, Danger.Some) &&
((tar == null) || p.CanReserveAndReach(tar, PathEndMode.Touch, Danger.Some)))
{
var comfor = usa.parent.GetComp<CompForbiddable>();
if (comfor != null)
comfor.Forbidden = false;
var job = JobMaker.MakeJob(((CompProperties_Usable)usa.props).useJob, usa.parent, tar);
p.jobs.TryTakeOrderedJob(job);
}
}
// Creates a menu option to use an item. "tar" is expected to be a pawn, corpse or null if it doesn't apply (in which
// case the pawn will presumably use the item on themself). "required_work" can also be null.
public static FloatMenuOption make_option(this CompUsable usa, string label, Pawn p, LocalTargetInfo tar, WorkTypeDef required_work)
{
if ((tar != null) && (!p.CanReserve(tar)))
{
string key = "Reserved";
string text = TranslatorFormattedStringExtensions.Translate(key);
return new FloatMenuOption(label + " (" + text + ")", null, MenuOptionPriority.DisabledOption);
}
else if ((tar != null) && (!p.CanReach(tar, PathEndMode.Touch, Danger.Some)))
{
string key = "NoPath";
string text = TranslatorFormattedStringExtensions.Translate(key);
return new FloatMenuOption(label + " (" + text + ")", null, MenuOptionPriority.DisabledOption);
}
else if ((required_work != null) && p.WorkTagIsDisabled(required_work.workTags))
{
string key = "CannotPrioritizeWorkTypeDisabled";
string text = TranslatorFormattedStringExtensions.Translate(key, required_work.gerundLabel);
return new FloatMenuOption(label + " (" + text + ")", null, MenuOptionPriority.DisabledOption);
}
else
return new FloatMenuOption(
label,
delegate
{
usa.start_job(p, tar);
},
MenuOptionPriority.Default);
}
}
public class bondage_gear_def : ThingDef
{
public Type soul_type;
public HediffDef equipped_hediff = null;
public bool gives_bound_moodlet = false;
public bool gives_gagged_moodlet = false;
public bool blocks_hands = false;
public bool blocks_oral = false;
public bool blocks_penis = false;
public bool blocks_vagina = false;
public bool blocks_anus = false;
public bool blocks_breasts = false;
private bondage_gear_soul soul_ins = null;
public List<BodyPartDef> HediffTargetBodyPartDefs; //field for optional list of targeted parts for hediff applying
public List<BodyPartGroupDef> BoundBodyPartGroupDefs; //field for optional list of groups restrained of verbcasting
public bondage_gear_soul soul
{
get
{
if (soul_ins == null)
soul_ins = (bondage_gear_soul)Activator.CreateInstance(soul_type);
return soul_ins;
}
}
}
public class bondage_gear_soul
{
// Adds the bondage gear's associated HediffDef and spawns a matching holokey
public virtual void on_wear(Pawn wearer, Apparel gear)
{
var def = (bondage_gear_def)gear.def;
if (def.equipped_hediff != null && def.HediffTargetBodyPartDefs != null)
{
foreach (BodyPartDef partDef in def.HediffTargetBodyPartDefs) //getting BodyPartDef, for example "Arm"
{
foreach (BodyPartRecord partRec in wearer.RaceProps.body.GetPartsWithDef(partDef)) //applying hediff to every single arm found on pawn
{
wearer.health.AddHediff(def.equipped_hediff, partRec);
}
}
}
else if (def.equipped_hediff != null && def.HediffTargetBodyPartDefs == null) //backward compatibility/simplified gear define without HediffTargetBodyPartDefs
{ //Hediff applyed to whole body
wearer.health.AddHediff(def.equipped_hediff);
}
var gear_stamp = gear.TryGetComp<CompHoloCryptoStamped>();
if (gear_stamp != null)
{
var key = ThingMaker.MakeThing(ThingDef.Named("Holokey"));
var key_stamp = key.TryGetComp<CompHoloCryptoStamped>();
key_stamp.copy_stamp_from(gear_stamp);
if (wearer.Map != null)
GenSpawn.Spawn(key, wearer.Position, wearer.Map);
else
wearer.inventory.TryAddItemNotForSale(key);
}
}
// Removes the gear's HediffDef
public virtual void on_remove(Apparel gear, Pawn former_wearer)
{
var def = (bondage_gear_def)gear.def;
if (def.equipped_hediff != null && def.HediffTargetBodyPartDefs != null)
{ //getting all Hediffs according with equipped_hediff def
List<Hediff> hediffs = former_wearer.health.hediffSet.hediffs.Where(x => x.def == def.equipped_hediff).ToList();
foreach (Hediff hedToRemove in hediffs)
{
if (def.HediffTargetBodyPartDefs.Contains(hedToRemove.Part.def)) //removing if applyed by this bondage_gear
former_wearer.health.RemoveHediff(hedToRemove); //assuming there can be several different bondages
} //with the same equipped_hediff def
}
else if (def.equipped_hediff != null && def.HediffTargetBodyPartDefs == null) //backward compatibility/simplified gear define without HediffTargetBodyPartDefs
{
var hed = former_wearer.health.hediffSet.GetFirstHediffOfDef(def.equipped_hediff);
if (hed != null)
former_wearer.health.RemoveHediff(hed);
}
}
}
// Give bondage gear an extremely low score when it's not being worn so pawns never equip it on themselves and give
// it an extremely high score when it is being worn so pawns never try to take it off to equip something "better".
public class bondage_gear : Apparel
{
// made this method universal for any bondage_gear, won't affect anything if gear's BoundBodyPartGroupDefs is empty or null
public override bool AllowVerbCast(Verb verb)
{
if ((this.def as bondage_gear_def).BoundBodyPartGroupDefs != null &&
verb.tool != null &&
(this.def as bondage_gear_def).BoundBodyPartGroupDefs.Contains(verb.tool.linkedBodyPartsGroup))
{
return false;
}
return true;
}
//needed for save compatibility only
public override void ExposeData()
{
base.ExposeData();
//if (Scribe.mode == LoadSaveMode.PostLoadInit)
// CheckHediffs();
}
//save compatibility insurance, will prevent Armbinder hediff with 0part efficiency on whole body
private void CheckHediffs()
{
var def = (bondage_gear_def)this.def;
if (this.Wearer == null || def.equipped_hediff == null) return;
bool changedHediff = false;
void ApplyHediffDirect(HediffDef hedDef, BodyPartRecord partRec)
{
Hediff hediff = (Hediff)HediffMaker.MakeHediff(hedDef, Wearer);
if (partRec != null)
hediff.Part = partRec;
Wearer.health.hediffSet.AddDirect(hediff);
changedHediff = true;
}
void RemoveHediffDirect(Hediff hed)
{
Wearer.health.hediffSet.hediffs.Remove(hed);
changedHediff = true;
}
List<bondage_gear> wornBondageGear = Wearer.apparel.WornApparel.Where(x => x is bondage_gear).Cast<bondage_gear>().ToList();
List<Hediff> hediffs = new List<Hediff>();
foreach (Hediff h in this.Wearer.health.hediffSet.hediffs) hediffs.Add(h);
//checking current hediffs defined by bondage_gear for being on defined place, cleaning up the misplaced
bool equippedHediff;
bool onPlace;
foreach (Hediff hed in hediffs)
{
equippedHediff = false;
onPlace = false;
foreach (bondage_gear gear in wornBondageGear)
{
if (hed.def == (gear.def as bondage_gear_def).equipped_hediff)
{
//if hediff from bondage_gear and on it's defined place then don't touch it else remove
//assuming there can be several different bondages with the same equipped_hediff def and different hediff target parts, don't know why
equippedHediff = true;
if ((hed.Part != null && (gear.def as bondage_gear_def).HediffTargetBodyPartDefs == null))
{
//pass
}
else if ((hed.Part == null && (gear.def as bondage_gear_def).HediffTargetBodyPartDefs == null))
{
onPlace = true;
break;
}
else if (hed.Part != null && (gear.def as bondage_gear_def).HediffTargetBodyPartDefs.Contains(hed.Part.def))
{
onPlace = true;
break;
}
}
}
if (equippedHediff && !onPlace)
{
ModLog.Message("Removing Hediff " + hed.Label + " from " + Wearer + (hed.Part == null ? "'s body" : "'s " + hed.Part));
RemoveHediffDirect(hed);
}
}
// now iterating every gear for having all hediffs in place, adding missing
foreach (bondage_gear gear in wornBondageGear)
{
if ((gear.def as bondage_gear_def).equipped_hediff == null) continue;
if ((gear.def as bondage_gear_def).HediffTargetBodyPartDefs == null) //handling gear without HediffTargetBodyPartDefs
{
Hediff hed = Wearer.health.hediffSet.hediffs.Find(x => (x.def == (gear.def as bondage_gear_def).equipped_hediff && x.Part == null));//checking hediff defined by gear on whole body
if (hed == null) //if no legit hediff, adding
{
ModLog.Message("Adding missing Hediff " + (gear.def as bondage_gear_def).equipped_hediff.label + " to " + Wearer + "'s body");
ApplyHediffDirect((gear.def as bondage_gear_def).equipped_hediff, null);
}
}
else //handling gear with defined HediffTargetBodyPartDefs
{
foreach (BodyPartDef partDef in (gear.def as bondage_gear_def).HediffTargetBodyPartDefs) //getting every partDef
{
foreach (BodyPartRecord partRec in Wearer.RaceProps.body.GetPartsWithDef(partDef)) //checking all parts of def for applyed hediff
{
Hediff hed = Wearer.health.hediffSet.hediffs.Find(x => (x.def == (gear.def as bondage_gear_def).equipped_hediff && x.Part == partRec));//checking hediff defined by gear on defined place
if (hed == null) //if hediff missing, adding
{
ModLog.Message("Adding missing Hediff " + (gear.def as bondage_gear_def).equipped_hediff.label + " to " + Wearer + "'s " + partRec.Label);
ApplyHediffDirect((gear.def as bondage_gear_def).equipped_hediff, partRec);
}
}
}
}
//possibility of several different items with THE SAME equipped_hediff def ON THE SAME PART is not considered, that's sick
}
if (changedHediff)
{
//Possible error in current toil on Notify_HediffChanged() if capacity.Manipulation is involved so making it in the end.
//Probably harmless, shouldn't happen again after corrected hediffs will be saved
Wearer.health.Notify_HediffChanged(null);
}
}
}
public class armbinder : bondage_gear
{
// Prevents pawns in armbinders from melee attacking
//public override bool AllowVerbCast (IntVec3 root, TargetInfo targ)
//{
// return false;
//}
}
public class yoke : bondage_gear
{
// Prevents pawns in armbinders from melee attacking
//public override bool AllowVerbCast (IntVec3 root, TargetInfo targ)
//{
// return false;
//}
}
public class Restraints : bondage_gear
{
// Prevents pawns in armbinders from melee attacking
//public override bool AllowVerbCast (IntVec3 root, TargetInfo targ)
//{
// return false;
//}
}
public class force_off_gear_def : RecipeDef
{
public ThingDef removes_apparel;
public BodyPartDef failure_affects;
public List<BodyPartDef> destroys_one_of = null;
public List<BodyPartDef> major_burns_on = null;
public List<BodyPartDef> minor_burns_on = null;
}
} | Korth95/rjw | 1.5/Source/Modules/Bondage/bondage_gear.cs | C# | mit | 13,130 |
namespace rjw.Modules.Genitals.Enums
{
public enum Gender
{
Male,
Female,
Trap,
Futa,
MaleOvi,
FemaleOvi,
Unknown
}
}
| Korth95/rjw | 1.5/Source/Modules/Genitals/Enums/Gender.cs | C# | mit | 144 |
namespace rjw.Modules.Genitals.Enums
{
public enum LewdablePartKind
{
Unsupported,
Penis,
Vagina,
Anus,
FemaleOvipositor,
MaleOvipositor,
Breasts,
Udders, // Unsupported
Hand,
Foot,
Tail,
Mouth,
Beak,
Tongue
}
}
| Korth95/rjw | 1.5/Source/Modules/Genitals/Enums/LewdablePartKind.cs | C# | mit | 248 |
using rjw.Modules.Genitals.Enums;
using rjw.Modules.Interactions.Objects;
using rjw.Modules.Shared.Extensions;
using rjw.Modules.Shared.Logs;
using System.Linq;
namespace rjw.Modules.Genitals.Helpers
{
public class GenderHelper
{
private static ILog _log = LogManager.GetLogger<GenderHelper>();
public static Gender GetGender(InteractionPawn pawn)
{
bool hasVagina = pawn.Parts.Vaginas.Any();
bool hasPenis = pawn.Parts.Penises.Any();
bool hasOviFemale = pawn.Parts.FemaleOvipositors.Any();
bool hasOviMale = pawn.Parts.MaleOvipositors.Any();
bool hasBreasts = pawn.HasBigBreasts();
Gender result = Gender.Unknown;
if (hasVagina && !hasPenis)
{
result = Gender.Female;
}
else
if (hasPenis && hasVagina)
{
result = Gender.Futa;
}
else
if (hasPenis && hasBreasts)
{
result = Gender.Trap;
}
else
if (hasPenis)
{
result = Gender.Male;
}
else
if (hasOviMale)
{
result = Gender.MaleOvi;
}
else
if (hasOviFemale)
{
result = Gender.FemaleOvi;
}
else
if (pawn.Pawn.gender == Verse.Gender.Male)
{
result = Gender.Male;
}
else
if (pawn.Pawn.gender == Verse.Gender.Female)
{
result = Gender.Female;
}
_log.Debug($"{pawn.Pawn.GetName()} detected as {result}");
return result;
}
}
}
| Korth95/rjw | 1.5/Source/Modules/Genitals/Helpers/GenderHelper.cs | C# | mit | 1,339 |
namespace rjw.Modules.Interactions.Contexts
{
public class InteractionContext
{
public InteractionInputs Inputs { get; set; }
public InteractionInternals Internals { get; set; }
public InteractionOutputs Outputs { get; set; }
public InteractionContext() { }
public InteractionContext(InteractionInputs inputs)
{
Inputs = inputs;
Internals = new InteractionInternals();
Outputs = new InteractionOutputs();
}
}
}
| Korth95/rjw | 1.5/Source/Modules/Interactions/Contexts/InteractionContext.cs | C# | mit | 441 |
using Verse;
namespace rjw.Modules.Interactions.Contexts
{
public class InteractionInputs
{
public Pawn Initiator { get; set; }
public Pawn Partner { get; set; }
public bool IsRape { get; set; }
public bool IsWhoring { get; set; }
}
}
| Korth95/rjw | 1.5/Source/Modules/Interactions/Contexts/InteractionInputs.cs | C# | mit | 251 |
using rjw.Modules.Interactions.Enums;
using rjw.Modules.Interactions.Objects;
namespace rjw.Modules.Interactions.Contexts
{
/// <summary>
/// All the stuff stored in there shouldn't be used by other modules ... hence the "internal"
/// </summary>
public class InteractionInternals
{
public InteractionPawn Dominant { get; set; }
public InteractionPawn Submissive { get; set; }
public InteractionType InteractionType { get; set; }
public bool IsReverse { get; set; }
public InteractionWithExtension Selected { get; set; }
public InteractionInternals()
{
}
}
}
| Korth95/rjw | 1.5/Source/Modules/Interactions/Contexts/InteractionInternals.cs | C# | mit | 589 |
using rjw.Modules.Interactions.Objects;
namespace rjw.Modules.Interactions.Contexts
{
public class InteractionOutputs
{
public Interaction Generated { get; set; }
public InteractionOutputs()
{
Generated = new Interaction();
}
}
}
| Korth95/rjw | 1.5/Source/Modules/Interactions/Contexts/InteractionOutputs.cs | C# | mit | 249 |
using RimWorld;
using Verse;
namespace rjw.Modules.Interactions.Contexts
{
public class SpecificInteractionInputs
{
public Pawn Initiator { get; set; }
public Pawn Partner { get; set; }
public InteractionDef Interaction { get; set; }
}
}
| Korth95/rjw | 1.5/Source/Modules/Interactions/Contexts/SpecificInteractionInputs.cs | C# | mit | 252 |
using rjw.Modules.Interactions.Defs;
using rjw.Modules.Interactions.Defs.DefFragment;
using rjw.Modules.Interactions.Enums;
using System;
using System.Collections.Generic;
using System.Linq;
using Verse;
namespace rjw.Modules.Interactions.DefModExtensions
{
public class InteractionSelectorExtension : DefModExtension
{
public List<RulePackDef> rulepacks = new List<RulePackDef>();
public List<InteractionTag> tags = new List<InteractionTag>();
public InteractionRequirement dominantRequirement;
public InteractionRequirement submissiveRequirement;
public string customRequirementHandler;
}
}
| Korth95/rjw | 1.5/Source/Modules/Interactions/DefModExtensions/InteractionSelectorExtension.cs | C# | mit | 610 |
using rjw.Modules.Interactions.Defs;
using rjw.Modules.Genitals.Enums;
using rjw.Modules.Shared.Enums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace rjw.Modules.Interactions.Defs.DefFragment
{
public class InteractionRequirement
{
//Default = false
public bool hand = false;
public bool tail = false;
public bool foot = false;
public bool mouth = false;
public bool beak = false;
public bool mouthORbeak = false;
public bool oral = false;
public bool tongue = false;
///<summary>Default = 1</summary>
public Nullable<int> minimumCount = 1;
///<summary>Default = 1</summary>
///@ed86 - nullables are good for you ! don't use default values :b
public Nullable<float> minimumSeverity;
//Default = empty
public List<string> partProps = new List<string>();
//Default = empty
public List<GenitalTag> tags = new List<GenitalTag>();
//Default = empty
public List<GenitalFamily> families = new List<GenitalFamily>();
//Default = PawnState.Healthy
public List<PawnState> pawnStates = new List<PawnState>();
//overrides - edging, spanking?
//public bool canOrgasm = true; // true - orgasm satisfy need, false - ruin orgasm/ dont satisfy need
//public bool canCum = true; // orgasm with cum effects -semen, pregnancy etc
//public float Sensetivity = 1.0f;
}
}
| Korth95/rjw | 1.5/Source/Modules/Interactions/Defs/DefFragment/InteractionRequirement.cs | C# | mit | 1,394 |
using RimWorld;
using rjw.Modules.Interactions.DefModExtensions;
using rjw.Modules.Interactions.Objects;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Verse;
namespace rjw.Modules.Interactions.Defs
{
public class InteractionDefOf
{
public static IList<InteractionWithExtension> Interactions { get; set; }
public static InteractionWithExtension DefaultConsensualSex => Interactions
.Where(e => e.Interaction.defName == "Sex_Vaginal")
.FirstOrDefault();
public static InteractionWithExtension DefaultWhoringSex => Interactions
.Where(e => e.Interaction.defName == "Sex_Vaginal")
.FirstOrDefault();
public static InteractionWithExtension DefaultRapeSex => Interactions
.Where(e => e.Interaction.defName == "Rape_Vaginal")
.FirstOrDefault();
public static InteractionWithExtension DefaultMechImplantSex => Interactions
.Where(e => e.Interaction.defName == "Rape_MechImplant")
.FirstOrDefault();
public static InteractionWithExtension DefaultNecrophiliaSex => Interactions
.Where(e => e.Interaction.defName == "Rape_Vaginal")
.FirstOrDefault();
public static InteractionWithExtension DefaultBestialitySex => Interactions
.Where(e => e.Interaction.defName == "Bestiality_Vaginal")
.FirstOrDefault();
public static InteractionWithExtension DefaultAnimalSex => Interactions
.Where(e => e.Interaction.defName == "Bestiality_Vaginal")
.FirstOrDefault();
static InteractionDefOf()
{
Interactions = DefDatabase<InteractionDef>.AllDefs
.Where(def => def.HasModExtension<InteractionSelectorExtension>())
.Where(def => def.HasModExtension<InteractionExtension>())
.Select(def => new InteractionWithExtension
{
Interaction = def,
Extension = def.GetModExtension<InteractionExtension>(),
SelectorExtension = def.GetModExtension<InteractionSelectorExtension>()
})
.Where(defWithExtensions => ParseHelper.FromString<xxx.rjwSextype>(defWithExtensions.Extension.rjwSextype) != xxx.rjwSextype.None)
.ToList();
}
}
}
| Korth95/rjw | 1.5/Source/Modules/Interactions/Defs/InteractionDefOf.cs | C# | mit | 2,094 |
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace rjw.Modules.Interactions.Enums
{
public enum InteractionTag
{
Reverse,
Fertilization,
EggFertilization,
EggLaying,
Masturbation,
Rape,
Whoring,
Consensual,
Bestiality,
Necrophilia,
Animal,
MechImplant
}
}
| Korth95/rjw | 1.5/Source/Modules/Interactions/Enums/InteractionTag.cs | C# | mit | 364 |
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace rjw.Modules.Interactions.Enums
{
public enum InteractionType
{
Masturbation,
Consensual,
Whoring,
Rape,
Bestiality,
Animal,
Necrophilia,
Mechanoid
}
}
| Korth95/rjw | 1.5/Source/Modules/Interactions/Enums/InteractionType.cs | C# | mit | 300 |
namespace rjw.Modules.Interactions.Enums
{
public enum LewdablePartKind
{
Unsupported,
Penis,
Vagina,
Anus,
FemaleOvipositor,
MaleOvipositor,
Breasts,
Udders, // Unsupported
Hand,
Foot,
Tail,
Mouth,
Beak,
Tongue
}
}
| Korth95/rjw | 1.5/Source/Modules/Interactions/Enums/LewdablePartKind.cs | C# | mit | 252 |
using KTrie;
using rjw.Modules.Interactions.DefModExtensions;
using rjw.Modules.Interactions.Objects;
using rjw.Modules.Shared.Logs;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Text;
using Verse;
namespace rjw.Modules.Interactions.Exposable
{
public class HediffWithExtensionExposable : IExposable
{
private static ILog _log = LogManager.GetLogger<HediffWithExtensionExposable>();
public Hediff hediff;
public ISexPartHediff GenitalPart
{
get
{
return hediff as ISexPartHediff;
}
}
public void ExposeData()
{
Scribe_References.Look(ref hediff, nameof(hediff));
}
/// <summary>
/// Dummy method to not break build pending removal of unused submodule
/// </summary>
/// <param name="self"></param>
/// <returns></returns>
public static ISexPartHediff Convert(HediffWithExtensionExposable self)
{
_log.Debug(self.ToString());
return self.hediff as ISexPartHediff;
}
/// <summary>
/// Dummy method to not break build pending removal of unused submodule
/// </summary>
/// <param name="self"></param>
/// <returns></returns>
public static HediffWithExtensionExposable Convert(ISexPartHediff self)
{
return new HediffWithExtensionExposable()
{
hediff = self.AsHediff
};
}
public override string ToString()
{
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.AppendLine($"{nameof(hediff)} = {hediff?.def.defName}");
return stringBuilder.ToString();
}
}
}
| Korth95/rjw | 1.5/Source/Modules/Interactions/Exposable/HediffWithExtensionExposable.cs | C# | mit | 1,523 |
using rjw.Modules.Interactions.Enums;
using rjw.Modules.Interactions.Objects;
using rjw.Modules.Interactions.Objects.Parts;
using rjw.Modules.Shared.Extensions;
using rjw.Modules.Shared.Logs;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Verse;
namespace rjw.Modules.Interactions.Exposable
{
public class InteractionExposable : IExposable
{
private static ILog _log = LogManager.GetLogger<InteractionExposable>();
private InteractionType interactionType;
private bool isReverse;
private InteractionPawnExposable initiator;
private InteractionPawnExposable receiver;
private InteractionWithExtensionExposable interactionWithExtension;
private RulePackDef rulePack;
private xxx.rjwSextype RjwSexType
{
get
{
return ParseHelper.FromString<xxx.rjwSextype>(interactionWithExtension.Extension.rjwSextype);
}
}
private List<RJWLewdablePartExposable> selectedDominantParts_RJW;
private List<VanillaLewdablePartExposable> selectedDominantParts_Vanilla;
private List<RJWLewdablePartExposable> selectedSubmissiveParts_RJW;
private List<VanillaLewdablePartExposable> selectedSubmissiveParts_Vanilla;
public void ExposeData()
{
Scribe_Values.Look(ref interactionType, nameof(interactionType));
Scribe_Values.Look(ref isReverse, nameof(isReverse));
Scribe_Deep.Look(ref initiator, nameof(initiator));
Scribe_Deep.Look(ref receiver, nameof(receiver));
Scribe_Deep.Look(ref interactionWithExtension, nameof(interactionWithExtension));
Scribe_Defs.Look(ref rulePack, nameof(rulePack));
Scribe_Collections.Look(ref selectedDominantParts_RJW, nameof(selectedDominantParts_RJW));
Scribe_Collections.Look(ref selectedDominantParts_Vanilla, nameof(selectedDominantParts_Vanilla));
Scribe_Collections.Look(ref selectedSubmissiveParts_RJW, nameof(selectedSubmissiveParts_RJW));
Scribe_Collections.Look(ref selectedSubmissiveParts_Vanilla, nameof(selectedSubmissiveParts_Vanilla));
}
public static Interaction Convert(InteractionExposable toCast)
{
return new Interaction()
{
InteractionType = toCast.interactionType,
Initiator = InteractionPawnExposable.Convert(toCast.initiator),
Receiver = InteractionPawnExposable.Convert(toCast.receiver),
Dominant = InteractionPawnExposable.Convert(toCast.initiator),
Submissive = InteractionPawnExposable.Convert(toCast.receiver),
InteractionDef = InteractionWithExtensionExposable.Convert(toCast.interactionWithExtension),
RjwSexType = toCast.RjwSexType,
RulePack = toCast.rulePack,
SelectedDominantParts = Enumerable.Concat(
toCast.selectedDominantParts_RJW.Select(RJWLewdablePartExposable.Convert).OfType<ILewdablePart>(),
toCast.selectedDominantParts_Vanilla.Select(VanillaLewdablePartExposable.Convert).OfType<ILewdablePart>()
).ToList(),
SelectedSubmissiveParts = Enumerable.Concat(
toCast.selectedSubmissiveParts_RJW.Select(RJWLewdablePartExposable.Convert).OfType<ILewdablePart>(),
toCast.selectedSubmissiveParts_Vanilla.Select(VanillaLewdablePartExposable.Convert).OfType<ILewdablePart>()
).ToList()
};
}
public static InteractionExposable Convert(Interaction toCast)
{
return new InteractionExposable()
{
interactionType = toCast.InteractionType,
initiator = InteractionPawnExposable.Convert(toCast.Initiator),
receiver = InteractionPawnExposable.Convert(toCast.Receiver),
interactionWithExtension = InteractionWithExtensionExposable.Convert(toCast.InteractionDef),
rulePack = toCast.RulePack,
selectedDominantParts_RJW = toCast.SelectedDominantParts
.OfType<RJWLewdablePart>()
.Select(RJWLewdablePartExposable.Convert)
.ToList(),
selectedDominantParts_Vanilla = toCast.SelectedDominantParts
.OfType<VanillaLewdablePart>()
.Select(VanillaLewdablePartExposable.Convert)
.ToList(),
selectedSubmissiveParts_RJW = toCast.SelectedDominantParts
.OfType<RJWLewdablePart>()
.Select(RJWLewdablePartExposable.Convert)
.ToList(),
selectedSubmissiveParts_Vanilla = toCast.SelectedDominantParts
.OfType<VanillaLewdablePart>()
.Select(VanillaLewdablePartExposable.Convert)
.ToList()
};
}
public override string ToString()
{
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.AppendLine($"{nameof(interactionType)} = {interactionType}");
stringBuilder.AppendLine($"{nameof(initiator)} = {initiator?.pawn.GetName()}");
stringBuilder.AppendLine($"{nameof(receiver)} = {receiver?.pawn.GetName()}");
stringBuilder.AppendLine($"{nameof(interactionWithExtension)} = {interactionWithExtension?.interactionDef.defName}");
stringBuilder.AppendLine($"{nameof(rulePack)} = {rulePack?.defName}");
return stringBuilder.ToString();
}
}
}
| Korth95/rjw | 1.5/Source/Modules/Interactions/Exposable/InteractionExposable.cs | C# | mit | 4,837 |
using rjw.Modules.Interactions.Enums;
using rjw.Modules.Interactions.Objects;
using rjw.Modules.Shared.Extensions;
using rjw.Modules.Shared.Logs;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Verse;
namespace rjw.Modules.Interactions.Exposable
{
public class InteractionPawnExposable : IExposable
{
private static ILog _log = LogManager.GetLogger<InteractionPawnExposable>();
public Pawn pawn;
public List<BodyPartRecord> mouths;
public List<BodyPartRecord> beaks;
public List<BodyPartRecord> tongues;
public List<BodyPartRecord> hands;
public List<BodyPartRecord> tails;
public List<HediffWithExtensionExposable> penises;
public List<HediffWithExtensionExposable> vaginas;
public List<HediffWithExtensionExposable> breasts;
public List<HediffWithExtensionExposable> anuses;
public List<HediffWithExtensionExposable> femaleOvipositors;
public List<HediffWithExtensionExposable> maleOvipositors;
public List<LewdablePartKind> blockedParts;
public Dictionary<LewdablePartKind, float> partPreferences;
public void ExposeData()
{
Scribe_References.Look(ref pawn, nameof(pawn));
Scribe_Collections.Look(ref beaks, nameof(beaks), LookMode.BodyPart);
Scribe_Collections.Look(ref mouths, nameof(mouths), LookMode.BodyPart);
Scribe_Collections.Look(ref tongues, nameof(tongues), LookMode.BodyPart);
Scribe_Collections.Look(ref hands, nameof(hands), LookMode.BodyPart);
Scribe_Collections.Look(ref tails, nameof(tails), LookMode.BodyPart);
Scribe_Collections.Look(ref penises, nameof(penises), LookMode.Deep);
Scribe_Collections.Look(ref vaginas, nameof(vaginas), LookMode.Deep);
Scribe_Collections.Look(ref breasts, nameof(breasts), LookMode.Deep);
Scribe_Collections.Look(ref anuses, nameof(anuses), LookMode.Deep);
Scribe_Collections.Look(ref femaleOvipositors, nameof(femaleOvipositors), LookMode.Deep);
Scribe_Collections.Look(ref maleOvipositors, nameof(maleOvipositors), LookMode.Deep);
Scribe_Collections.Look(ref blockedParts, nameof(blockedParts), LookMode.Value);
Scribe_Collections.Look(ref partPreferences, nameof(partPreferences), LookMode.Value, LookMode.Value);
}
public static InteractionPawn Convert(InteractionPawnExposable toCast)
{
return new InteractionPawn()
{
Pawn = toCast.pawn,
Parts = new SexablePawnParts()
{
Mouths = toCast.mouths,
Beaks = toCast.beaks,
Tongues = toCast.tongues,
Hands = toCast.hands,
Tails = toCast.tails,
Penises = toCast.penises.Select(HediffWithExtensionExposable.Convert).ToList(),
Vaginas = toCast.vaginas.Select(HediffWithExtensionExposable.Convert).ToList(),
Breasts = toCast.breasts.Select(HediffWithExtensionExposable.Convert).ToList(),
Anuses = toCast.anuses.Select(HediffWithExtensionExposable.Convert).ToList(),
FemaleOvipositors = toCast.femaleOvipositors.Select(HediffWithExtensionExposable.Convert).ToList(),
MaleOvipositors = toCast.maleOvipositors.Select(HediffWithExtensionExposable.Convert).ToList(),
},
BlockedParts = toCast.blockedParts,
PartPreferences = toCast.partPreferences
};
}
public static InteractionPawnExposable Convert(InteractionPawn toCast)
{
return new InteractionPawnExposable()
{
pawn = toCast.Pawn,
mouths = toCast.Parts.Mouths.ToList(),
beaks = toCast.Parts.Beaks.ToList(),
tongues = toCast.Parts.Tongues.ToList(),
hands = toCast.Parts.Hands.ToList(),
tails = toCast.Parts.Tails.ToList(),
penises = toCast.Parts.Penises.Select(HediffWithExtensionExposable.Convert).ToList(),
vaginas = toCast.Parts.Vaginas.Select(HediffWithExtensionExposable.Convert).ToList(),
breasts = toCast.Parts.Breasts.Select(HediffWithExtensionExposable.Convert).ToList(),
anuses = toCast.Parts.Anuses.Select(HediffWithExtensionExposable.Convert).ToList(),
femaleOvipositors = toCast.Parts.FemaleOvipositors.Select(HediffWithExtensionExposable.Convert).ToList(),
maleOvipositors = toCast.Parts.MaleOvipositors.Select(HediffWithExtensionExposable.Convert).ToList(),
blockedParts = toCast.BlockedParts.ToList(),
partPreferences = toCast.PartPreferences.ToDictionary(e => e.Key, e => e.Value)
};
}
public override string ToString()
{
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.AppendLine($"{nameof(pawn)} = {pawn.GetName()}");
stringBuilder.AppendLine($"{nameof(blockedParts)} = {String.Join("/", blockedParts)}");
stringBuilder.AppendLine($"{nameof(partPreferences)} = {String.Join("/", partPreferences.Select(e => $"{e.Key}-{e.Value}"))}");
return stringBuilder.ToString();
}
}
}
| Korth95/rjw | 1.5/Source/Modules/Interactions/Exposable/InteractionPawnExposable.cs | C# | mit | 4,690 |
using RimWorld;
using rjw.Modules.Interactions.DefModExtensions;
using rjw.Modules.Interactions.Objects;
using rjw.Modules.Shared.Logs;
using System.Text;
using Verse;
namespace rjw.Modules.Interactions.Exposable
{
public class InteractionWithExtensionExposable : IExposable
{
private static ILog _log = LogManager.GetLogger<InteractionWithExtensionExposable>();
public InteractionDef interactionDef;
public InteractionSelectorExtension InteractionSelectorExtension
{
get
{
return interactionDef.GetModExtension<InteractionSelectorExtension>();
}
}
public InteractionExtension Extension
{
get
{
return interactionDef.GetModExtension<InteractionExtension>();
}
}
public void ExposeData()
{
Scribe_Defs.Look(ref interactionDef, nameof(interactionDef));
}
public static InteractionWithExtension Convert(InteractionWithExtensionExposable toCast)
{
return new InteractionWithExtension()
{
Interaction = toCast.interactionDef,
Extension = toCast.Extension,
SelectorExtension = toCast.InteractionSelectorExtension
};
}
public static InteractionWithExtensionExposable Convert(InteractionWithExtension toCast)
{
return new InteractionWithExtensionExposable()
{
interactionDef = toCast.Interaction
};
}
public override string ToString()
{
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.AppendLine($"{nameof(interactionDef)} = {interactionDef?.defName}");
return stringBuilder.ToString();
}
}
}
| Korth95/rjw | 1.5/Source/Modules/Interactions/Exposable/InteractionWithExtensionExposable.cs | C# | mit | 1,528 |
using rjw.Modules.Interactions.Enums;
using rjw.Modules.Interactions.Objects.Parts;
using rjw.Modules.Shared.Logs;
using System.Collections.Generic;
using System.Text;
using Verse;
namespace rjw.Modules.Interactions.Exposable
{
public class RJWLewdablePartExposable : IExposable
{
private static ILog _log = LogManager.GetLogger<RJWLewdablePartExposable>();
public HediffWithExtensionExposable hediff;
public LewdablePartKind partKind;
public float Size => hediff.hediff.Severity;
public IList<string> Props => (hediff.hediff.def as HediffDef_SexPart)?.partTags ?? new();
public void ExposeData()
{
Scribe_Deep.Look(ref hediff, nameof(hediff));
Scribe_Values.Look(ref partKind, nameof(partKind));
}
/// <summary>
/// Dummy method to not break build pending removal of unused submodule
/// </summary>
/// <param name="toCast"></param>
/// <returns></returns>
public static RJWLewdablePart Convert(RJWLewdablePartExposable toCast)
{
return new RJWLewdablePart(
toCast.hediff.hediff as ISexPartHediff,
toCast.partKind
);
}
public static RJWLewdablePartExposable Convert(RJWLewdablePart toCast)
{
return new RJWLewdablePartExposable()
{
hediff = HediffWithExtensionExposable.Convert(toCast.Part),
partKind = toCast.PartKind
};
}
public override string ToString()
{
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.AppendLine($"{nameof(partKind)} = {partKind}");
return stringBuilder.ToString();
}
}
}
| Korth95/rjw | 1.5/Source/Modules/Interactions/Exposable/RJWLewdablePartExposable.cs | C# | mit | 1,521 |
using rjw.Modules.Interactions.Enums;
using rjw.Modules.Interactions.Objects.Parts;
using rjw.Modules.Shared.Logs;
using System.Text;
using Verse;
namespace rjw.Modules.Interactions.Exposable
{
public class VanillaLewdablePartExposable : IExposable
{
private static ILog _log = LogManager.GetLogger<VanillaLewdablePartExposable>();
public Pawn pawn;
public BodyPartRecord part;
public LewdablePartKind partKind;
public void ExposeData()
{
Scribe_References.Look(ref pawn, nameof(pawn));
Scribe_BodyParts.Look(ref part, nameof(part));
Scribe_Values.Look(ref partKind, nameof(partKind));
}
public static VanillaLewdablePart Convert(VanillaLewdablePartExposable toCast)
{
return new VanillaLewdablePart(
toCast.pawn,
toCast.part,
toCast.partKind
);
}
public static VanillaLewdablePartExposable Convert(VanillaLewdablePart toCast)
{
return new VanillaLewdablePartExposable()
{
pawn = toCast.Owner,
part = toCast.Part,
partKind = toCast.PartKind
};
}
public override string ToString()
{
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.AppendLine($"{nameof(partKind)} = {partKind}");
return stringBuilder.ToString();
}
}
}
| Korth95/rjw | 1.5/Source/Modules/Interactions/Exposable/VanillaLewdablePartExposable.cs | C# | mit | 1,242 |
using rjw.Modules.Interactions.Enums;
using rjw.Modules.Interactions.Objects;
using rjw.Modules.Interactions.Objects.Parts;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
namespace rjw.Modules.Interactions.Extensions
{
public static class EnumerableExtensions
{
public static IEnumerable<ILewdablePart> FilterSeverity(this IEnumerable<ILewdablePart> self, Nullable<float> severity)
{
IEnumerable<ILewdablePart> result = self;
if (severity.HasValue == true)
{
result = Enumerable.Union(
result.Where(e => e is VanillaLewdablePart),
result.Where(e => e is RJWLewdablePart)
.Where(e => (e as RJWLewdablePart).Part.AsHediff.Severity >= severity.Value)
);
}
foreach (ILewdablePart part in result)
{
yield return part;
}
}
public static IEnumerable<ILewdablePart> WithPartKind(this IEnumerable<ILewdablePart> self, LewdablePartKind partKind)
{
return self
.Where(e => e.PartKind == partKind);
}
public static IEnumerable<ILewdablePart> WithPartTag(this IEnumerable<ILewdablePart> self, GenitalTag tag)
{
return self
.OfType<RJWLewdablePart>()
.Where(e => e.Part.Def.genitalTags.Contains(tag));
}
public static IEnumerable<ILewdablePart> WithPartKindAndTag(this IEnumerable<ILewdablePart> self, LewdablePartKind partKind, GenitalTag tag)
{
return self
.WithPartKind(partKind)
.WithPartTag(tag);
}
public static bool HasPartKind(this IEnumerable<ILewdablePart> self, LewdablePartKind partKind)
{
return self
.WithPartKind(partKind)
.Any();
}
public static bool HasPartTag(this IEnumerable<ILewdablePart> self, GenitalTag tag)
{
return self
.WithPartTag(tag)
.Any();
}
public static bool HasPartKindAndTag(this IEnumerable<ILewdablePart> self, LewdablePartKind partKind, GenitalTag tag)
{
return self
.WithPartKindAndTag(partKind, tag)
.Any();
}
public static IEnumerable<ISexPartHediff> BigBreasts(this IEnumerable<ISexPartHediff> self)
{
if (self == null)
{
return null;
}
return self
.Where(e => e.Def.genitalFamily == GenitalFamily.Breasts)
.Where(e => e.AsHediff.CurStageIndex >= 1);
}
public static bool HasBigBreasts(this IEnumerable<ISexPartHediff> self)
{
if (self == null)
{
return false;
}
return self
.BigBreasts()
.Any();
}
public static ISexPartHediff Largest(this IEnumerable<ISexPartHediff> self)
{
if (self == null)
{
return null;
}
return self
.OrderByDescending(e => e.AsHediff.Severity)
.FirstOrDefault();
}
public static ISexPartHediff Smallest(this IEnumerable<ISexPartHediff> self)
{
if (self == null)
{
return null;
}
return self
.OrderBy(e => e.AsHediff.Severity)
.FirstOrDefault();
}
public static ISexPartHediff GetBestSizeAppropriate(this IEnumerable<ISexPartHediff> self, ISexPartHediff toFit)
{
if (self == null)
{
return null;
}
return self
.OrderBy(e => Mathf.Abs(e.AsHediff.Severity - toFit.AsHediff.Severity))
.FirstOrDefault();
}
}
}
| Korth95/rjw | 1.5/Source/Modules/Interactions/Extensions/EnumerableExtensions.cs | C# | mit | 3,176 |
using rjw.Modules.Interactions.Enums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace rjw.Modules.Interactions.Extensions
{
public static class GenitalFamilyExtension
{
public static LewdablePartKind ToPartKind(this GenitalFamily self)
{
switch (self)
{
case GenitalFamily.Vagina:
return LewdablePartKind.Vagina;
case GenitalFamily.Penis:
return LewdablePartKind.Penis;
case GenitalFamily.Breasts:
return LewdablePartKind.Breasts;
case GenitalFamily.Udders:
return LewdablePartKind.Udders;
case GenitalFamily.Anus:
return LewdablePartKind.Anus;
case GenitalFamily.FemaleOvipositor:
return LewdablePartKind.FemaleOvipositor;
case GenitalFamily.MaleOvipositor:
return LewdablePartKind.MaleOvipositor;
default:
return LewdablePartKind.Unsupported;
}
}
}
}
| Korth95/rjw | 1.5/Source/Modules/Interactions/Extensions/GenitalFamilyExtension.cs | C# | mit | 925 |
using rjw.Modules.Interactions.Defs;
using rjw.Modules.Interactions.Enums;
using rjw.Modules.Interactions.Objects;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace rjw.Modules.Interactions.Extensions
{
public static class HediffWithGenitalPartExtensions
{
//Vanilla
public static IEnumerable<ISexPartHediff> Penises(this IEnumerable<ISexPartHediff> self) =>
self.Where(e => e.Def.genitalFamily == GenitalFamily.Penis);
public static IEnumerable<ISexPartHediff> Vaginas(this IEnumerable<ISexPartHediff> self) =>
self.Where(e => e.Def.genitalFamily == GenitalFamily.Vagina);
public static IEnumerable<ISexPartHediff> Breasts(this IEnumerable<ISexPartHediff> self) =>
self.Where(e => e.Def.genitalFamily == GenitalFamily.Breasts);
public static IEnumerable<ISexPartHediff> Udders(this IEnumerable<ISexPartHediff> self) =>
self.Where(e => e.Def.genitalFamily == GenitalFamily.Udders);
public static IEnumerable<ISexPartHediff> Anuses(this IEnumerable<ISexPartHediff> self) =>
self.Where(e => e.Def.genitalFamily == GenitalFamily.Anus);
//Ovi
public static IEnumerable<ISexPartHediff> FemaleOvipositors(this IEnumerable<ISexPartHediff> self) =>
self.Where(e => e.Def.genitalFamily == GenitalFamily.FemaleOvipositor);
public static IEnumerable<ISexPartHediff> MaleOvipositors(this IEnumerable<ISexPartHediff> self) =>
self.Where(e => e.Def.genitalFamily == GenitalFamily.MaleOvipositor);
}
}
| Korth95/rjw | 1.5/Source/Modules/Interactions/Extensions/HediffWithGenitalPartExtensions.cs | C# | mit | 1,510 |
using rjw.Modules.Interactions.Defs;
using rjw.Modules.Interactions.Enums;
using rjw.Modules.Interactions.Objects;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace rjw.Modules.Interactions.Extensions
{
public static class InteractionWithExtensions
{
public static IEnumerable<InteractionWithExtension> Reverse(this IEnumerable<InteractionWithExtension> self)
{
return self
.Where(interaction => interaction.HasInteractionTag(InteractionTag.Reverse));
}
public static IEnumerable<InteractionWithExtension> NonReverse(this IEnumerable<InteractionWithExtension> self)
{
return self
.Where(interaction => interaction.HasInteractionTag(InteractionTag.Reverse) == false);
}
public static IEnumerable<InteractionWithExtension> FilterReverse(this IEnumerable<InteractionWithExtension> self, bool isReverse)
{
return self
.Where(interaction => interaction.HasInteractionTag(InteractionTag.Reverse) == isReverse);
}
}
}
| Korth95/rjw | 1.5/Source/Modules/Interactions/Extensions/InteractionWithExtensions.cs | C# | mit | 1,033 |
using RimWorld;
using rjw.Modules.Interactions.DefModExtensions;
using rjw.Modules.Interactions.Enums;
using rjw.Modules.Interactions.Objects;
using rjw.Modules.Shared.Extensions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Verse;
namespace rjw.Modules.Interactions.Extensions
{
public static class PawnExtensions
{
public static SexablePawnParts GetSexablePawnParts(this Pawn self)
{
if (self == null)
{
return null;
}
//We get the genital parts once so we don't parse ALL the hediff all the time
IList<ISexPartHediff> hediffWithGenitalParts = self.health.hediffSet.hediffs
.OfType<ISexPartHediff>()
.ToList();
return new SexablePawnParts
{
Mouths = self.Mouths(),
Beaks = self.Beaks(),
Tongues = self.Tongues(),
Hands = self.Hands(),
Feet = self.Feet(),
Tails = self.Tails(),
AllParts = hediffWithGenitalParts,
Penises = hediffWithGenitalParts.Penises(),
Vaginas = hediffWithGenitalParts.Vaginas(),
Breasts = hediffWithGenitalParts.Breasts(),
Udders = hediffWithGenitalParts.Udders(),
Anuses = hediffWithGenitalParts.Anuses(),
FemaleOvipositors = hediffWithGenitalParts.FemaleOvipositors(),
MaleOvipositors = hediffWithGenitalParts.MaleOvipositors()
};
}
private static IList<BodyPartRecord> Mouths(this Pawn self)
{
return self.RaceProps.body.AllParts
//EatingSource = mouth
.Where(part => part.def.tags.Contains(RimWorld.BodyPartTagDefOf.EatingSource))
.Where(part => part.def.defName?.ToLower().Contains("beak") == false)
.Where(part => part.IsMissingForPawn(self) == false)
.ToList();
}
private static IList<BodyPartRecord> Beaks(this Pawn self)
{
return self.RaceProps.body.AllParts
//EatingSource = mouth
.Where(part => part.def.tags.Contains(RimWorld.BodyPartTagDefOf.EatingSource))
.Where(part => part.def.defName?.ToLower().Contains("beak") == true)
.Where(part => part.IsMissingForPawn(self) == false)
.ToList();
}
private static IList<BodyPartRecord> Tongues(this Pawn self)
{
return self.RaceProps.body.AllParts
//EatingSource = mouth
.Where(part => part.def.defName?.ToLower().Contains("tongue") == true)
.Where(part => part.IsMissingForPawn(self) == false)
.ToList();
}
private static IList<BodyPartRecord> Tails(this Pawn self)
{
return self.RaceProps.body.AllParts
.Where(part => part.def.defName?.ToLower().Contains("tail") == true)
.Where(part => part.IsMissingForPawn(self) == false)
.ToList();
}
private static IList<BodyPartRecord> Hands(this Pawn self)
{
return self.RaceProps.body.AllParts
.Where(part => part.IsInGroup(BodyPartGroupDefOf.LeftHand) || part.IsInGroup(BodyPartGroupDefOf.RightHand) || part.def.defName?.ToLower().Contains("hand") == true || part.def.defName?.ToLower().Contains("arm") == true)
.Where(part => part.IsMissingForPawn(self) == false)
.ToList();
}
private static IList<BodyPartRecord> Feet(this Pawn self)
{
return self.RaceProps.body.AllParts
.Where(part => part.def.defName?.ToLower().Contains("leftfoot") == true || part.def.defName?.ToLower().Contains("rightfoot") == true|| part.def.defName?.ToLower().Contains("foot") == true || part.def.defName?.ToLower().Contains("paw") == true)
.Where(part => part.IsMissingForPawn(self) == false)
.ToList();
}
}
}
| Korth95/rjw | 1.5/Source/Modules/Interactions/Extensions/PawnExtensions.cs | C# | mit | 3,445 |
using RimWorld;
using rjw.Modules.Interactions.DefModExtensions;
using rjw.Modules.Interactions.Objects;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace rjw.Modules.Interactions.Helpers
{
public static class InteractionHelper
{
public static InteractionWithExtension GetWithExtension(InteractionDef interactionDef)
{
if (interactionDef.HasModExtension<InteractionSelectorExtension>() == false)
{
return null;
}
if (interactionDef.HasModExtension<InteractionExtension>() == false)
{
return null;
}
return new InteractionWithExtension
{
Interaction = interactionDef,
Extension = interactionDef.GetModExtension<InteractionExtension>(),
SelectorExtension = interactionDef.GetModExtension<InteractionSelectorExtension>()
};
}
}
}
| Korth95/rjw | 1.5/Source/Modules/Interactions/Helpers/InteractionHelper.cs | C# | mit | 865 |
using RimWorld;
using rjw.Modules.Interactions.DefModExtensions;
using rjw.Modules.Interactions.Enums;
using rjw.Modules.Interactions.Objects;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using rjw.Modules.Interactions.Extensions;
using rjw.Modules.Interactions.Objects.Parts;
using Verse;
using rjw.Modules.Interactions.Defs.DefFragment;
namespace rjw.Modules.Interactions.Helpers
{
public static class PartHelper
{
private readonly static Internals.IPartFinderService _partFinderService;
private readonly static Internals.IBlockedPartDetectorService _blockedPartDetectorService;
static PartHelper()
{
_partFinderService = Internals.Implementation.PartFinderService.Instance;
_blockedPartDetectorService = Internals.Implementation.BlockedPartDetectorService.Instance;
}
public static IList<ILewdablePart> FindParts(Pawn pawn, GenitalFamily family)
{
InteractionPawn interactionPawn = ToInteractionPawn(pawn);
return _partFinderService.FindUnblockedForPawn(interactionPawn, family)
.ToList();
}
public static IList<ILewdablePart> FindParts(Pawn pawn, GenitalFamily family, IList<string> props)
{
InteractionPawn interactionPawn = ToInteractionPawn(pawn);
return _partFinderService.FindUnblockedForPawn(interactionPawn, family, props)
.ToList();
}
public static IList<ILewdablePart> FindParts(Pawn pawn, GenitalTag tag)
{
InteractionPawn interactionPawn = ToInteractionPawn(pawn);
return _partFinderService.FindUnblockedForPawn(interactionPawn, tag)
.ToList();
}
public static IList<ILewdablePart> FindParts(Pawn pawn, GenitalTag tag, IList<string> props)
{
InteractionPawn interactionPawn = ToInteractionPawn(pawn);
return _partFinderService.FindUnblockedForPawn(interactionPawn, tag, props)
.ToList();
}
private static InteractionPawn ToInteractionPawn(Pawn pawn)
{
InteractionPawn interactionPawn = new InteractionPawn
{
Pawn = pawn,
Parts = pawn.GetSexablePawnParts()
};
interactionPawn.BlockedParts = _blockedPartDetectorService.BlockedPartsForPawn(interactionPawn);
return interactionPawn;
}
}
}
| Korth95/rjw | 1.5/Source/Modules/Interactions/Helpers/PartHelper.cs | C# | mit | 2,197 |
using rjw.Modules.Interactions.Objects;
namespace rjw.Modules.Interactions
{
public interface ICustomRequirementHandler
{
/// <summary>
/// Will be used to match the field <see cref="InteractionSelectorExtension.customRequirementHandler"/>
/// </summary>
string HandlerKey { get; }
bool FufillRequirements(InteractionWithExtension interaction, InteractionPawn dominant, InteractionPawn submissive);
}
}
| Korth95/rjw | 1.5/Source/Modules/Interactions/ICustomRequirementHandler.cs | C# | mit | 421 |
using rjw.Modules.Interactions.Enums;
using rjw.Modules.Interactions.Objects;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace rjw.Modules.Interactions.Internals
{
public interface IInteractionRequirementService
{
bool FufillRequirements(InteractionWithExtension interaction, InteractionPawn dominant, InteractionPawn submissive);
}
}
| Korth95/rjw | 1.5/Source/Modules/Interactions/IInteractionRequirementService.cs | C# | mit | 421 |
using rjw.Modules.Interactions.Contexts;
namespace rjw.Modules.Interactions
{
public interface ILewdInteractionService
{
InteractionOutputs GenerateInteraction(InteractionInputs inputs);
}
}
| Korth95/rjw | 1.5/Source/Modules/Interactions/ILewdInteractionService.cs | C# | mit | 200 |
using rjw.Modules.Interactions.Contexts;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using RimWorld;
using Verse;
namespace rjw.Modules.Interactions
{
public interface ILewdInteractionValidatorService
{
bool IsValid(InteractionDef interaction, Pawn dominant, Pawn submissive);
}
}
| Korth95/rjw | 1.5/Source/Modules/Interactions/ILewdInteractionValidatorService.cs | C# | mit | 362 |
using rjw.Modules.Interactions.Contexts;
namespace rjw.Modules.Interactions
{
public interface ISpecificLewdInteractionService
{
InteractionOutputs GenerateSpecificInteraction(SpecificInteractionInputs inputs);
}
}
| Korth95/rjw | 1.5/Source/Modules/Interactions/ISpecificLewdInteractionService.cs | C# | mit | 224 |
using rjw.Modules.Interactions.Defs.DefFragment;
using rjw.Modules.Interactions.Enums;
using rjw.Modules.Interactions.Extensions;
using rjw.Modules.Interactions.Objects;
using rjw.Modules.Interactions.Objects.Parts;
using rjw.Modules.Shared;
using rjw.Modules.Shared.Enums;
using rjw.Modules.Shared.Extensions;
using rjw.Modules.Shared.Implementation;
using rjw.Modules.Shared.Logs;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Verse;
namespace rjw.Modules.Interactions.Internals.Implementation
{
public class InteractionRequirementService : IInteractionRequirementService
{
private static ILog _log = LogManager.GetLogger<InteractionRequirementService, InteractionLogProvider>();
public static IInteractionRequirementService Instance { get; private set; }
public static IList<ICustomRequirementHandler> CustomRequirementHandlers { get; private set; }
static InteractionRequirementService()
{
Instance = new InteractionRequirementService();
_partFinderService = PartFinderService.Instance;
_pawnStateService = PawnStateService.Instance;
CustomRequirementHandlers = new List<ICustomRequirementHandler>();
}
/// <summary>
/// Do not instantiate, use <see cref="Instance"/>
/// </summary>
private InteractionRequirementService() { }
private static readonly IPartFinderService _partFinderService;
private static readonly IPawnStateService _pawnStateService;
/// <summary>
/// Check if the pawns don't have the lewdable parts required
/// to partake in this interaction
/// </summary>
public bool FufillRequirements(InteractionWithExtension interaction, InteractionPawn dominant, InteractionPawn submissive)
{
_log.Debug($"{interaction.Interaction.defName} checks");
if (String.IsNullOrWhiteSpace(interaction.SelectorExtension.customRequirementHandler) == false)
{
if (TryCustomHandler(interaction, dominant, submissive, out bool result) == false)
{
_log.Debug($"{interaction.Interaction.defName} TryCustomHandler fail");
return false;
}
}
if (CheckRequirement(dominant, interaction.SelectorExtension.dominantRequirement) == false)
{
return false;
}
_log.Debug($"{submissive.Pawn.GetName()} checks");
if (CheckRequirement(submissive, interaction.SelectorExtension.submissiveRequirement) == false)
{
return false;
}
return true;
}
private bool CheckRequirement(InteractionPawn pawn, InteractionRequirement requirement)
{
int required = 0;
List<ILewdablePart> availableParts = new List<ILewdablePart>();
_log.Debug($"{pawn.Pawn.GetName()} checks");
//pawn state should match
if (IsPawnstateValid(pawn, requirement) == false)
{
return false;
}
//need hand
if (requirement.hand == true)
{
AppendByKind(availableParts, _partFinderService.FindUnblockedForPawn(pawn, LewdablePartKind.Hand), LewdablePartKind.Hand);
required++;
}
//need foot
if (requirement.foot == true)
{
AppendByKind(availableParts, _partFinderService.FindUnblockedForPawn(pawn, LewdablePartKind.Foot), LewdablePartKind.Foot);
required++;
}
//need mouth
if (requirement.mouth == true || requirement.mouthORbeak == true)
{
AppendByKind(availableParts, _partFinderService.FindUnblockedForPawn(pawn, LewdablePartKind.Mouth), LewdablePartKind.Mouth);
required++;
}
//need beak
if (requirement.beak == true || requirement.mouthORbeak == true)
{
AppendByKind(availableParts, _partFinderService.FindUnblockedForPawn(pawn, LewdablePartKind.Beak), LewdablePartKind.Beak);
required++;
}
//need tongue
if (requirement.tongue == true)
{
AppendByKind(availableParts, _partFinderService.FindUnblockedForPawn(pawn, LewdablePartKind.Tongue), LewdablePartKind.Tongue);
required++;
}
//any oral thingy
if (requirement.oral == true)
{
AppendByKind(availableParts, _partFinderService.FindUnblockedForPawn(pawn, LewdablePartKind.Tongue), LewdablePartKind.Tongue);
AppendByKind(availableParts, _partFinderService.FindUnblockedForPawn(pawn, LewdablePartKind.Beak), LewdablePartKind.Beak);
AppendByKind(availableParts, _partFinderService.FindUnblockedForPawn(pawn, LewdablePartKind.Mouth), LewdablePartKind.Mouth);
required++;
}
//need tail
if (requirement.tail == true)
{
AppendByKind(availableParts, _partFinderService.FindUnblockedForPawn(pawn, LewdablePartKind.Tail), LewdablePartKind.Tail);
required++;
}
//need family
if (requirement.families != null && requirement.families.Any())
{
foreach (GenitalFamily family in requirement.families)
{
AppendByFamily(availableParts, _partFinderService.FindUnblockedForPawn(pawn, family, requirement.partProps), family);
}
required++;
}
//need tag
if (requirement.tags != null && requirement.tags.Any())
{
foreach (GenitalTag tag in requirement.tags)
{
AppendByTag(availableParts, _partFinderService.FindUnblockedForPawn(pawn, tag, requirement.partProps), tag);
}
required++;
}
//_log.Debug($"Requirement for {pawn.Pawn.GetName()} Min {requirement.minimumCount} Got {matches}");
//The interaction have NO requirements
if (required == 0)
{
return true;
}
int matches = availableParts
.FilterSeverity(requirement.minimumSeverity)
.Count();
//Now ... all that's left is to check we have enough !
if (requirement.minimumCount.HasValue)
{
return matches >= requirement.minimumCount.Value;
}
return matches >= 1;
}
private static void AppendByFamily(List<ILewdablePart> parts, IEnumerable<ILewdablePart> toAppend, GenitalFamily familly)
{
var array = toAppend.ToArray();
if (array.Length > 0)
{
parts.AddRange(array);
}
else
{
_log.Debug($"Missing requirement : {familly}");
}
}
private static void AppendByKind(List<ILewdablePart> parts, IEnumerable<ILewdablePart> toAppend, LewdablePartKind kind)
{
var array = toAppend.ToArray();
if (array.Length > 0)
{
parts.AddRange(array);
}
else
{
_log.Debug($"Missing requirement : {kind}");
}
}
private static void AppendByTag(List<ILewdablePart> parts, IEnumerable<ILewdablePart> toAppend, GenitalTag tag)
{
var array = toAppend.ToArray();
if (array.Length > 0)
{
parts.AddRange(array);
}
else
{
_log.Debug($"Missing requirement : {tag}");
}
}
private bool IsPawnstateValid(InteractionPawn pawn, InteractionRequirement requirement)
{
PawnState state = _pawnStateService.Detect(pawn.Pawn);
//By default, the pawn must be healthy
if (requirement.pawnStates == null || requirement.pawnStates.Any() == false)
{
return state == PawnState.Healthy;
}
return requirement.pawnStates.Contains(state);
}
private bool TryCustomHandler(InteractionWithExtension interaction, InteractionPawn dominant, InteractionPawn submissive, out bool result)
{
ICustomRequirementHandler handler = CustomRequirementHandlers
.Where(e => e.HandlerKey == interaction.SelectorExtension.customRequirementHandler)
.FirstOrDefault();
if (handler == null)
{
result = false;
return false;
}
try
{
result = handler.FufillRequirements(interaction, dominant, submissive);
}
catch(Exception e)
{
_log.Error($"Exception occured during call to custom handler {handler.GetType().FullName}. Will use regular requirement as fallback.", e);
result = false;
return false;
}
return result;
}
}
}
| Korth95/rjw | 1.5/Source/Modules/Interactions/Implementation/InteractionRequirementService.cs | C# | mit | 7,596 |