code
stringlengths 0
56.1M
| repo_name
stringclasses 515
values | path
stringlengths 2
147
| language
stringclasses 447
values | license
stringclasses 7
values | size
int64 0
56.8M
|
---|---|---|---|---|---|
using Verse;
using System.Diagnostics;
namespace rjw
{
public static class PawnDesignations_Utility
{
public static bool UpdateCanChangeDesignationColonist(this Pawn pawn)
{
//check if pawn is a hero of other player
//if yes - limit widget access in mp for this pawn
if ((pawn.IsDesignatedHero() && !pawn.IsHeroOwner()))
{
//Log.Warning("CanChangeDesignationColonist:: Pawn:" + xxx.get_pawnname(pawn));
//Log.Warning("CanChangeDesignationColonist:: IsDesignatedHero:" + pawn.IsDesignatedHero());
//Log.Warning("CanChangeDesignationColonist:: IsHeroOwner:" + pawn.IsHeroOwner());
return SaveStorage.DataStore.GetPawnData(pawn).CanChangeDesignationColonist = false;
}
return SaveStorage.DataStore.GetPawnData(pawn).CanChangeDesignationColonist = true;
}
public static bool CanChangeDesignationColonist(this Pawn pawn)
{
return SaveStorage.DataStore.GetPawnData(pawn).CanChangeDesignationColonist;
}
public static bool UpdateCanChangeDesignationPrisoner(this Pawn pawn)
{
//check if player hero is a slave/prisoner
//if yes - limit widget access in mp for all widgets
//Stopwatch sw = new Stopwatch();
//sw.Start();
foreach (Pawn item in DesignatorsData.rjwHero)
{
//Log.Warning("CanChangeDesignationPrisoner:: Pawn:" + xxx.get_pawnname(item));
//Log.Warning("CanChangeDesignationPrisoner:: IsHeroOwner:" + item.IsHeroOwner());
if (item.IsHeroOwner())
{
if (item.IsPrisonerOfColony || item.IsPrisoner || xxx.is_slave(item))
{
//Log.Warning("CanChangeDesignationPrisoner:: Pawn:" + xxx.get_pawnname(item));
//Log.Warning("CanChangeDesignationPrisoner:: Hero of " + MP.PlayerName);
//Log.Warning("CanChangeDesignationPrisoner:: is prisoner(colony):" + item.IsPrisonerOfColony);
//Log.Warning("CanChangeDesignationPrisoner:: is prisoner:" + item.IsPrisoner);
//Log.Warning("CanChangeDesignationPrisoner:: is slave:" + xxx.is_slave(item));
return SaveStorage.DataStore.GetPawnData(pawn).CanChangeDesignationPrisoner = false;
}
}
}
//sw.Stop();
//Log.Warning("Elapsed={0}" + sw.Elapsed);
return SaveStorage.DataStore.GetPawnData(pawn).CanChangeDesignationPrisoner = true;
}
public static bool CanChangeDesignationPrisoner(this Pawn pawn)
{
return SaveStorage.DataStore.GetPawnData(pawn).CanChangeDesignationPrisoner;
}
}
}
|
Mewtopian/rjw
|
Source/Designators/Utility.cs
|
C#
|
mit
| 2,389 |
using System.Collections.Generic;
using Verse;
using UnityEngine;
namespace rjw
{
/// <summary>
/// Handles creation of RJWdesignations button group for gui
/// </summary>
public class RJWdesignations : Command
{
//is actually a group of four buttons, but I've wanted them be small and so vanilla gizmo system is mostly bypassed for them
private const float ContentPadding = 5f;
private const float IconSize = 32f;
private const float IconGap = 1f;
private readonly Pawn parent;
private Rect gizmoRect;
/// <summary>
/// This should keep track of last pressed pseudobutton. It is set in the pseudobutton callback.
/// Then, the callback to encompassed Gizmo is performed by game, and this field is used to determine what exact button was pressed
/// The callback is called by the tynancode right after the loop which detects click on button,
/// so it will be called then and only then when it should be (no unrelated events).
/// event handling shit is needed to apply settings to all selected pawns.
/// </summary>
private static SubIcon lastClicked;
static readonly List<SubIcon> subIcons = new List<SubIcon> {
new Comfort(),
new Service(),
new BreedingHuman(),
new BreedingAnimal(),
new Breeder(),
new Milking(),
new Hero()
};
public RJWdesignations(Pawn pawn)
{
parent = pawn;
defaultLabel = "RJWdesignations";
defaultDesc = "RJWdesignations";
}
public override GizmoResult GizmoOnGUI(Vector2 topLeft, float maxWidth)
{
Rect rect = new Rect(topLeft.x, topLeft.y, 75f, 75f);
gizmoRect = rect.ContractedBy(ContentPadding);
Widgets.DrawWindowBackground(rect);
//Log.Message("RJWgizmo");
foreach (SubIcon icon in subIcons)
{
if (DrawSubIcon(icon))
{
lastClicked = icon;
icon.state = icon.applied(parent);
return new GizmoResult(GizmoState.Interacted, Event.current);
}
}
return new GizmoResult(GizmoState.Clear);
}
//this and class mess below was supposed to be quick shortcut to not write four repeated chunks of code in GizmoOnGUI
private bool DrawSubIcon(SubIcon icon)
{
if (!icon.applicable(parent)) { return false; }
//Log.Message("sub gizmo");
Rect iconRect = new Rect(gizmoRect.x + icon.offset.x, gizmoRect.y + icon.offset.y, IconSize, IconSize);
TooltipHandler.TipRegion(iconRect, icon.desc(parent).Translate());
bool applied = icon.applied(parent);
Texture2D texture = applied ? icon.cancel : icon.texture(parent);
GUI.DrawTexture(iconRect, texture);
//GUI.color = Color.white;
return Widgets.ButtonInvisible(iconRect, false);
}
public override void ProcessInput(Event ev)
{
SubIcon icon = lastClicked;
if (icon.state)
icon.unapply(parent);
else
icon.apply(parent);
}
[StaticConstructorOnStartup]//this is needed for textures
public abstract class SubIcon
{
public abstract Texture2D texture(Pawn pawn);
public abstract Vector2 offset { get; }
public abstract string desc(Pawn pawn);
public abstract bool applicable(Pawn pawn);
public abstract bool applied(Pawn pawn);
public abstract void apply(Pawn pawn);
public abstract void unapply(Pawn pawn);
static readonly Texture2D cancellText = ContentFinder<Texture2D>.Get("UI/Commands/cancel");
public virtual Texture2D cancel => cancellText;
public bool state;
}
[StaticConstructorOnStartup]
public class Comfort : SubIcon
{
//comfort raping
static readonly Texture2D iconAccept = ContentFinder<Texture2D>.Get("UI/Commands/ComfortPrisoner_off");
static readonly Texture2D iconRefuse = ContentFinder<Texture2D>.Get("UI/Commands/ComfortPrisoner_Refuse");
static readonly Texture2D iconCancel = ContentFinder<Texture2D>.Get("UI/Commands/ComfortPrisoner_on");
public override Texture2D texture(Pawn pawn) => (pawn.CanDesignateComfort() || pawn.IsDesignatedComfort()) && xxx.is_human(pawn) ? iconAccept : iconRefuse;
public override Texture2D cancel { get; } = iconCancel;
static readonly Vector2 posComf = new Vector2(IconGap + IconSize, 0);
public override Vector2 offset => posComf;
public override string desc(Pawn pawn) => pawn.CanDesignateComfort() ? "ForComfortDesc" :
!pawn.CanChangeDesignationPrisoner() ? "ForHeroRefuse2Desc" :
!pawn.CanChangeDesignationColonist() ? "ForHeroRefuse1Desc" : "ForComfortRefuseDesc";
public override bool applicable(Pawn pawn) => xxx.is_human(pawn);
public override bool applied(Pawn pawn) => pawn.IsDesignatedComfort();
public override void apply(Pawn pawn) => pawn.ToggleComfort();
public override void unapply(Pawn pawn) => pawn.ToggleComfort();
}
[StaticConstructorOnStartup]
public class Service : SubIcon
{
//whoring
static readonly Texture2D iconAccept = ContentFinder<Texture2D>.Get("UI/Commands/Service_off");
static readonly Texture2D iconRefuse = ContentFinder<Texture2D>.Get("UI/Commands/Service_Refuse");
static readonly Texture2D iconCancel = ContentFinder<Texture2D>.Get("UI/Commands/Service_on");
public override Texture2D texture(Pawn pawn) => (pawn.CanDesignateService() || pawn.IsDesignatedService()) && xxx.is_human(pawn) ? iconAccept : iconRefuse;
public override Texture2D cancel { get; } = iconCancel;
public override Vector2 offset { get; } = new Vector2(0, 0);
public override string desc(Pawn pawn) => pawn.CanDesignateService() ? "ForServiceDesc" :
!pawn.CanChangeDesignationPrisoner() ? "ForHeroRefuse2Desc" :
!pawn.CanChangeDesignationColonist() ? "ForHeroRefuse1Desc" : "ForServiceRefuseDesc";
public override bool applicable(Pawn pawn) => xxx.is_human(pawn);
public override bool applied(Pawn pawn) => pawn.IsDesignatedService() && xxx.is_human(pawn);
public override void apply(Pawn pawn) => pawn.ToggleService();
public override void unapply(Pawn pawn) => pawn.ToggleService();
}
[StaticConstructorOnStartup]
public class BreedingHuman : SubIcon
{
//Breed humanlike
static readonly Texture2D iconAccept = ContentFinder<Texture2D>.Get("UI/Commands/Breeding_Pawn_off");
static readonly Texture2D iconRefuse = ContentFinder<Texture2D>.Get("UI/Commands/Breeding_Pawn_Refuse");
static readonly Texture2D iconCancel = ContentFinder<Texture2D>.Get("UI/Commands/Breeding_Pawn_on");
public override Texture2D texture(Pawn pawn) => (pawn.CanDesignateBreeding() || pawn.IsDesignatedBreeding()) && xxx.is_human(pawn) ? iconAccept : iconRefuse;
public override Texture2D cancel { get; } = iconCancel;
public override Vector2 offset { get; } = new Vector2(0, IconSize + IconGap);
public override string desc(Pawn pawn) => pawn.CanDesignateBreeding() && xxx.is_human(pawn) ? "ForBreedingDesc" :
!pawn.CanChangeDesignationPrisoner() ? "ForHeroRefuse2Desc" :
!pawn.CanChangeDesignationColonist() ? "ForHeroRefuse1Desc" : "ForBreedingRefuseDesc";
public override bool applicable(Pawn pawn) => xxx.is_human(pawn);
public override bool applied(Pawn pawn) => pawn.IsDesignatedBreeding() && xxx.is_human(pawn);
public override void apply(Pawn pawn) => pawn.ToggleBreeding();
public override void unapply(Pawn pawn) => pawn.ToggleBreeding();
}
[StaticConstructorOnStartup]
public class BreedingAnimal : SubIcon
{
//Breed animal
static readonly Texture2D iconAccept = ContentFinder<Texture2D>.Get("UI/Commands/Breeding_Animal_off");
static readonly Texture2D iconCancel = ContentFinder<Texture2D>.Get("UI/Commands/Breeding_Animal_on");
public override Texture2D texture(Pawn pawn) => iconAccept;
public override Texture2D cancel { get; } = iconCancel;
public override Vector2 offset { get; } = new Vector2(0, IconSize + IconGap);
public override string desc(Pawn pawn) => !pawn.CanChangeDesignationPrisoner() ? "ForHeroRefuse2Desc" : "ForBreedingDesc";
public override bool applicable(Pawn pawn) => (pawn.CanDesignateBreeding() || pawn.IsDesignatedBreeding()) && xxx.is_animal(pawn);
public override bool applied(Pawn pawn) => pawn.IsDesignatedBreeding() && xxx.is_animal(pawn);
public override void apply(Pawn pawn) => pawn.ToggleBreeding();
public override void unapply(Pawn pawn) => pawn.ToggleBreeding();
}
[StaticConstructorOnStartup]
public class Breeder : SubIcon
{
//Breeder(fucker) animal
static readonly Texture2D iconAccept = ContentFinder<Texture2D>.Get("UI/Commands/Breeder_Animal_off");
static readonly Texture2D iconCancel = ContentFinder<Texture2D>.Get("UI/Commands/Breeder_Animal_on");
public override Texture2D texture(Pawn pawn) => iconAccept;
public override Texture2D cancel { get; } = iconCancel;
public override Vector2 offset { get; } = new Vector2(0, 0);
public override string desc(Pawn pawn) => !pawn.CanChangeDesignationPrisoner() ? "ForHeroRefuse2Desc" : "ForBreedingAnimalDesc";
public override bool applicable(Pawn pawn) => pawn.CanDesignateBreedingAnimal() || pawn.IsDesignatedBreedingAnimal();
public override bool applied(Pawn pawn) => pawn.IsDesignatedBreedingAnimal();
public override void apply(Pawn pawn) => pawn.ToggleBreedingAnimal();
public override void unapply(Pawn pawn) => pawn.ToggleBreedingAnimal();
}
[StaticConstructorOnStartup]
public class Milking : SubIcon
{
static readonly Texture2D iconAccept = ContentFinder<Texture2D>.Get("UI/Commands/Milking_off");
static readonly Texture2D iconCancel = ContentFinder<Texture2D>.Get("UI/Commands/Milking_on");
public override Texture2D texture(Pawn pawn) => iconAccept;
public override Texture2D cancel { get; } = iconCancel;
public override Vector2 offset { get; } = new Vector2(IconGap + IconSize, IconSize + IconGap);
public override string desc(Pawn pawn) => !pawn.CanChangeDesignationPrisoner() ? "ForHeroRefuse2Desc" : "ForMilkingDesc";
public override bool applicable(Pawn pawn) => pawn.CanDesignateMilking() || pawn.IsDesignatedMilking();
public override bool applied(Pawn pawn) => pawn.IsDesignatedMilking();
public override void apply(Pawn pawn) => pawn.ToggleMilking();
public override void unapply(Pawn pawn) => pawn.ToggleMilking();
}
[StaticConstructorOnStartup]
public class Hero : SubIcon
{
static readonly Texture2D iconAccept = ContentFinder<Texture2D>.Get("UI/Commands/Hero_off");
static readonly Texture2D iconCancel = ContentFinder<Texture2D>.Get("UI/Commands/Hero_on");
public override Texture2D texture(Pawn pawn) => iconAccept;
public override Texture2D cancel { get; } = iconCancel;
public override Vector2 offset { get; } = new Vector2(IconGap + IconSize, IconSize + IconGap);
//public override string desc(Pawn pawn) => pawn.CanDesignateHero() || (pawn.IsDesignatedHero() && pawn.IsHeroOwner()) ? "ForHeroDesc" : "Hero of " + SaveStorage.DataStore.GetPawnData(pawn).HeroOwner;
public override string desc(Pawn pawn) => pawn.CanDesignateHero() ? "ForHeroDesc" :
pawn.IsDesignatedHero() ? "Hero of " + SaveStorage.DataStore.GetPawnData(pawn).HeroOwner : "ForHeroDesc";
public override bool applicable(Pawn pawn) => pawn.CanDesignateHero() || pawn.IsDesignatedHero();
public override bool applied(Pawn pawn) => pawn.IsDesignatedHero();
public override void apply(Pawn pawn) => pawn.ToggleHero();
public override void unapply(Pawn pawn) => pawn.ToggleHero();
}
}
}
|
Mewtopian/rjw
|
Source/Designators/_RJWdesignationsWidget.cs
|
C#
|
mit
| 11,350 |
using System.Collections.Generic;
using Harmony;
using RimWorld;
using UnityEngine;
using Verse;
namespace rjw
{
public static class Building_Bed_Patch
{
[HarmonyPatch(typeof(Building_Bed))]
[HarmonyPatch("ForPrisoners", MethodType.Setter)]
public static class ForPrisoners
{
[HarmonyPostfix]
public static void Postfix(Building_Bed __instance)
{
if (!__instance.ForPrisoners) return;
if (__instance is Building_WhoreBed)
{
Building_WhoreBed.Swap(__instance);
}
}
}
[HarmonyPatch(typeof(Building_Bed), "GetGizmos")]
public static class GetGizmos
{
[HarmonyPostfix]
public static void Postfix(Building_Bed __instance, ref IEnumerable<Gizmo> __result)
{
__result = Process(__instance, __result);
}
private static IEnumerable<Gizmo> Process(Building_Bed __instance, IEnumerable<Gizmo> __result)
{
foreach (var gizmo in __result)
{
yield return gizmo;
}
if (__instance!=null && !__instance.ForPrisoners && !__instance.Medical && __instance.def.building.bed_humanlike)
{
//--Log.Message("[RJW]Building_Bed_Patch::Process - before new Command_Toggle is called");
yield return
new Command_Toggle
{
defaultLabel = "CommandBedSetAsWhoreLabel".Translate(),
defaultDesc = "CommandBedSetAsWhoreDesc".Translate(),
icon = ContentFinder<Texture2D>.Get("UI/Commands/AsWhore"),
isActive = () => __instance is Building_WhoreBed,
toggleAction = () => Building_WhoreBed.Swap(__instance),
hotKey = KeyBindingDefOf.Misc4
};
}
}
}
}
}
|
Mewtopian/rjw
|
Source/Harmony/Building_Bed_Patch.cs
|
C#
|
mit
| 1,594 |
using System.Reflection;
using Harmony;
using RimWorld;
using Verse;
namespace rjw
{
/// <summary>
/// Conditional patching class that only does patching if CnP is active
/// </summary>
public class CnPcompatibility
{
//CnP (or BnC) try to address the joy need of a child, prisoners don't have that.
//Considering how you can arrest children without rjw, it is more of a bug of that mod than ours.
[HarmonyPatch(typeof(Pawn_NeedsTracker), "BindDirectNeedFields")]
static class jfpk
{
[HarmonyPostfix]
static void postfix(ref Pawn_NeedsTracker __instance)
{
Pawn_NeedsTracker tr = __instance;
FieldInfo fieldInfo = AccessTools.Field(typeof(Pawn_NeedsTracker), "pawn");
Pawn pawn = fieldInfo.GetValue(__instance) as Pawn;
if (xxx.is_human(pawn) && pawn.ageTracker.CurLifeStageIndex < AgeStage.Teenager)
{
if (tr.TryGetNeed(NeedDefOf.Joy) == null)
{
MethodInfo method = AccessTools.Method(typeof(Pawn_NeedsTracker), "AddNeed");
method.Invoke(tr, new object[] { NeedDefOf.Joy });
}
}
}
}
//For whatever reason, harmony shits itself, when trying to patch non void private fields, below are variants the code that would work nicely, if it didn't
//[HarmonyPatch]
//[StaticConstructorOnStartup]
//internal static class joy_for_prison_kids
//{
// [HarmonyTargetMethod]
// static MethodBase CalculateMethod(HarmonyInstance instance)
// {
// var r = AccessTools.Method(typeof(Pawn_NeedsTracker), "ShouldHaveNeed");
// //Log.Message("Found method "+ r.ReturnType + ' ' + r.FullDescription());
// //Log.Message("Parameters " + r.GetType() );
// //Log.Message("return " + r.ReturnParameter);
// return AccessTools.Method(typeof(Pawn_NeedsTracker), "ShouldHaveNeed");
// }
// [HarmonyPrepare]
// static bool should_patch(HarmonyInstance instance)
// {
// Log.Clear();
// Log.Message("Will patch "+ xxx.RimWorldChildrenIsActive);
// return xxx.RimWorldChildrenIsActive;
// }
//doesn't work, gets: System.Reflection.TargetParameterCountException: parameters do not match signature
//static void Postfix(HarmonyInstance instance)
//{
// Log.Message("FOO");
//}
//[HarmonyPrefix]
//static bool foo(NeedDef nd)
//{
// Log.Message("Prerun ");
// return true;
//}
//[HarmonyPostfix]
//static void postfix(ref bool __result, ref Pawn_NeedsTracker __instance, NeedDef nd)
//{
// if (nd != NeedDefOf.Joy) { return; }
// FieldInfo fieldInfo = AccessTools.Field(typeof(Pawn_NeedsTracker), "pawn");
// Pawn pawn = fieldInfo.GetValue(__instance) as Pawn;
// if (pawn.ageTracker.CurLifeStageIndex < AgeStage.Teenager)
// {
// __result = true;
// }
//}
//}
public static void Patch(HarmonyInstance harmony)
{
if (!xxx.RimWorldChildrenIsActive) return;
Doit(harmony);
}
private static void Doit(HarmonyInstance harmony)
{
var original = typeof(RimWorldChildren.ChildrenUtility).GetMethod("CanBreastfeed");
var postfix = typeof(CnPcompatibility).GetMethod("CanBreastfeed");
harmony.Patch(original, null, new HarmonyMethod(postfix));
original = typeof(Building_Bed).GetMethod("get_AssigningCandidates");
postfix = typeof(CnPcompatibility).GetMethod("BedCandidates");
harmony.Patch(original, null, new HarmonyMethod(postfix));
//doesn't work cannot reflect private class
//original = typeof(RimWorldChildren.Hediff_UnhappyBaby).GetMethod("IsBabyUnhappy", BindingFlags.Static | BindingFlags.NonPublic);
//Log.Message("original is nul " + (original == null));
//var prefix = typeof(CnPcompatibility).GetMethod("IsBabyUnhappy");
//harmony.Patch(original, new HarmonyMethod(prefix), null);
}
private static void CanBreastfeed(ref bool __result, ref Pawn __instance)//Postfix
{
__result = __instance.health.hediffSet.HasHediff(HediffDef.Named("Lactating"));//I'm a simple man
}
private static void BedCandidates(ref IEnumerable<Pawn> __result, ref Building_Bed bed)
{
if (!RimWorldChildren.BedPatchMethods.IsCrib(bed)) return;
__result = bed.Map.mapPawns.FreeColonists.Where(x => x.ageTracker.CurLifeStageIndex <= 2 && x.Faction == Faction.OfPlayer);//Basically do all the work second time but with a tweak
}
private static bool IsBabyUnhappy(ref bool __result, ref RimWorldChildren.Hediff_UnhappyBaby __instance)
{
var pawn = __instance.pawn;
if ((pawn.needs?.joy.CurLevelPercentage??1) < 0.2f)
__result = true;
else
__result = false;
return false;
}
}
}
|
Mewtopian/rjw
|
Source/Harmony/CnPcompatibility.cs
|
C#
|
mit
| 4,612 |
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Linq;
using Harmony;
using RimWorld;
using Verse;
namespace rjw
{
// Add genitalia to pawns that have the comp.
[HarmonyPatch(typeof(PawnGenerator), "GenerateTraits")]
public static class PawnGenerator_GenitaliaPatch
{
[HarmonyPostfix]
public static void AddGenitalia(ref Pawn pawn, ref PawnGenerationRequest request)
{
if (CompRJW.Comp(pawn) == null) return;
if (CompRJW.Comp(pawn).orientation == Orientation.None)
{
CompRJW.Comp(pawn).Sexualize(pawn);
}
}
}
[StaticConstructorOnStartup]
internal static class First
{
/*private static void show_bpr(String body_part_record_def_name)
{
var bpr = BodyDefOf.Human.AllParts.Find((BodyPartRecord can) => String.Equals(can.def.defName, body_part_record_def_name));
--Log.Message(body_part_record_def_name + " BPR internals:");
--Log.Message(" def: " + bpr.def.ToString());
--Log.Message(" parts: " + bpr.parts.ToString());
--Log.Message(" parts.count: " + bpr.parts.Count.ToString());
--Log.Message(" height: " + bpr.height.ToString());
--Log.Message(" depth: " + bpr.depth.ToString());
--Log.Message(" coverage: " + bpr.coverage.ToString());
--Log.Message(" groups: " + bpr.groups.ToString());
--Log.Message(" groups.count: " + bpr.groups.Count.ToString());
--Log.Message(" parent: " + bpr.parent.ToString());
--Log.Message (" fleshCoverage: " + bpr.fleshCoverage.ToString ());
--Log.Message (" absoluteCoverage: " + bpr.absoluteCoverage.ToString ());
--Log.Message (" absoluteFleshCoverage: " + bpr.absoluteFleshCoverage.ToString ());
}*/
//Children mod use same defname. but not has worker class. so overriding here.
public static void inject_Reproduction()
{
PawnCapacityDef reproduction = DefDatabase<PawnCapacityDef>.GetNamed("Reproduction");
reproduction.workerClass = typeof(PawnCapacityWorker_Fertility);
}
private static void inject_recipes()
{
//--Log.Message("[RJW] First::inject_recipes");
// Inject the recipes to create the artificial privates into the crafting spot or machining bench.
// BUT, also dynamically detect if EPOE is loaded and, if it is, inject the recipes into EPOE's
// crafting benches instead.
if (IsLoaded("Lord of the Rims - The Third Age"))
{
// no idea why it removes MakePegDick recipe
Log.Warning("[RJW]The Third Age is installed. Unable to inject advanced recipes.");
return;
}
//Vanilla benches
var cra_spo = DefDatabase<ThingDef>.GetNamed("CraftingSpot");
var mac_ben = DefDatabase<ThingDef>.GetNamed("TableMachining");
var fab_ben = DefDatabase<ThingDef>.GetNamed("FabricationBench");
var tai_ben = DefDatabase<ThingDef>.GetNamed("ElectricTailoringBench");
//EPOE benches
var bas_ben = DefDatabase<ThingDef>.GetNamed("TableBasicProsthetic", false);
var sim_ben = DefDatabase<ThingDef>.GetNamed("TableSimpleProsthetic", false);
var bio_ben = DefDatabase<ThingDef>.GetNamed("TableBionics", false);
(bas_ben ?? cra_spo).AllRecipes.Add(DefDatabase<RecipeDef>.GetNamed("MakePegDick"));
(sim_ben ?? mac_ben).AllRecipes.Add(DefDatabase<RecipeDef>.GetNamed("MakeHydraulicAnus"));
(sim_ben ?? mac_ben).AllRecipes.Add(DefDatabase<RecipeDef>.GetNamed("MakeHydraulicBreasts"));
(sim_ben ?? mac_ben).AllRecipes.Add(DefDatabase<RecipeDef>.GetNamed("MakeHydraulicPenis"));
(sim_ben ?? mac_ben).AllRecipes.Add(DefDatabase<RecipeDef>.GetNamed("MakeHydraulicVagina"));
(bio_ben ?? fab_ben).AllRecipes.Add(DefDatabase<RecipeDef>.GetNamed("MakeBionicAnus"));
(bio_ben ?? fab_ben).AllRecipes.Add(DefDatabase<RecipeDef>.GetNamed("MakeBionicBreasts"));
(bio_ben ?? fab_ben).AllRecipes.Add(DefDatabase<RecipeDef>.GetNamed("MakeBionicPenis"));
(bio_ben ?? fab_ben).AllRecipes.Add(DefDatabase<RecipeDef>.GetNamed("MakeBionicVagina"));
// Inject the bondage gear recipes into their appropriate benches
if (xxx.config.bondage_gear_enabled)
{
tai_ben.AllRecipes.Add(DefDatabase<RecipeDef>.GetNamed("MakeHololock"));
tai_ben.AllRecipes.Add(DefDatabase<RecipeDef>.GetNamed("MakeArmbinder"));
tai_ben.AllRecipes.Add(DefDatabase<RecipeDef>.GetNamed("MakeChastityBelt"));
tai_ben.AllRecipes.Add(DefDatabase<RecipeDef>.GetNamed("MakeGag"));
}
}
/*private static void show_bs(Backstory bs)
{
--Log.Message("Backstory \"" + bs.Title + "\" internals:");
--Log.Message(" identifier: " + bs.identifier);
--Log.Message(" slot: " + bs.slot.ToString());
--Log.Message(" Title: " + bs.Title);
--Log.Message(" TitleShort: " + bs.TitleShort);
--Log.Message(" baseDesc: " + bs.baseDesc);
--Log.Message(" skillGains: " + ((bs.skillGains == null) ? "null" : bs.skillGains.ToString()));
--Log.Message(" skillGainsResolved: " + ((bs.skillGainsResolved == null) ? "null" : bs.skillGainsResolved.ToString()));
--Log.Message(" workDisables: " + bs.workDisables.ToString());
--Log.Message(" requiredWorkTags: " + bs.requiredWorkTags.ToString());
--Log.Message(" spawnCategories: " + bs.spawnCategories.ToString());
--Log.Message(" bodyTypeGlobal: " + bs.bodyTypeGlobal.ToString());
--Log.Message(" bodyTypeFemale: " + bs.bodyTypeFemale.ToString());
--Log.Message(" bodyTypeMale: " + bs.bodyTypeMale.ToString());
--Log.Message(" forcedTraits: " + ((bs.forcedTraits == null) ? "null" : bs.forcedTraits.ToString()));
--Log.Message(" disallowedTraits: " + ((bs.disallowedTraits == null) ? "null" : bs.disallowedTraits.ToString()));
--Log.Message(" shuffleable: " + bs.shuffleable.ToString());
}*/
//Quick check to see if an another mod is loaded.
private static bool IsLoaded(string mod)
{
return LoadedModManager.RunningModsListForReading.Any(x => x.Name == mod);
}
private static void CheckingCompatibleMods()
{
//RomanceDiversified
try
{
xxx.straight = DefDatabase<TraitDef>.GetNamedSilentFail("Straight");
xxx.bisexual = DefDatabase<TraitDef>.GetNamedSilentFail("Bisexual");
xxx.asexual = DefDatabase<TraitDef>.GetNamedSilentFail("Asexual");
xxx.faithful = DefDatabase<TraitDef>.GetNamedSilentFail("Faithful");
xxx.philanderer = DefDatabase<TraitDef>.GetNamedSilentFail("Philanderer");
xxx.polyamorous = DefDatabase<TraitDef>.GetNamedSilentFail("Polyamorous");
if (xxx.straight is null)
{
xxx.RomanceDiversifiedIsActive = false;
if (Prefs.DevMode) Log.Message("[RJW]RomanceDiversified is not detected");
}
else
{
xxx.RomanceDiversifiedIsActive = true;
if (Prefs.DevMode) Log.Message("[RJW]RomanceDiversified is detected.");
}
}
catch (Exception)
{
xxx.RomanceDiversifiedIsActive = false;
xxx.straight = null;
xxx.bisexual = null;
xxx.asexual = null;
xxx.faithful = null;
xxx.philanderer = null;
xxx.polyamorous = null;
if (Prefs.DevMode) Log.Message("[RJW]RomanceDiversified is not detected.error");
}
if (IsLoaded("[KV] Consolidated Traits - 1.0"))
{
Log.Message("[RJW]Consolidated Traits found, adding trait compatibility.");
xxx.CTIsActive = true;
}
else
{
xxx.CTIsActive = false;
}
if (IsLoaded("Lord of the Rims - The Third Age"))
{
Log.Warning("[RJW]The Third Age detected. High tech items removed");
}
//Rimworld of Magic - need this for the check to avoid undead pregnancies
if (IsLoaded("A RimWorld of Magic"))
{
xxx.RoMIsActive = true;
if (Prefs.DevMode) Log.Message("[RJW]Rimworld of Magic is detected.");
}
else
{
xxx.RoMIsActive = false;
}
//[SYR] Individuality
if (IsLoaded("[SYR] Individuality"))
{
xxx.IndividualityIsActive = true;
if (Prefs.DevMode) Log.Message("[RJW]Individuality is detected.");
}
else
{
xxx.IndividualityIsActive = false;
}
//Humanoid Alien Races Framework 2.0
if (IsLoaded("Humanoid Alien Races 2.0"))
{
xxx.AlienFrameworkIsActive = true;
xxx.xenophobia = DefDatabase<TraitDef>.GetNamedSilentFail("Xenophobia");
if (Prefs.DevMode) Log.Message("[RJW]Humanoid Alien Races 2.0 is detected. Xenophile and Xenophobe traits active.");
}
else
{
xxx.AlienFrameworkIsActive = false;
}
//Psychology
if (IsLoaded("Psychology"))
{
xxx.PsychologyIsActive = true;
xxx.prude = DefDatabase<TraitDef>.GetNamedSilentFail("Prude");
xxx.lecher = DefDatabase<TraitDef>.GetNamedSilentFail("Lecher");
xxx.polygamous = DefDatabase<TraitDef>.GetNamedSilentFail("Polygamous");
if (Prefs.DevMode) Log.Message("[RJW]Psychology is detected. (Note: only partially supported)");
}
else
{
xxx.PsychologyIsActive = false;
}
//SimpleSlavery
if (IsLoaded("Simple Slavery[1.0]"))
{
xxx.SimpleSlaveryIsActive = true;
if (Prefs.DevMode) Log.Message("[RJW]SimpleSlavery is detected.");
}
else
{
xxx.SimpleSlaveryIsActive = false;
}
//DubsBadHygiene
if (IsLoaded("Dubs Bad Hygiene"))
{
xxx.DubsBadHygieneIsActive = true;
if (Prefs.DevMode) Log.Message("[RJW]Dubs Bad Hygiene is detected.");
}
else
{
xxx.DubsBadHygieneIsActive = false;
}
//Children and Pregnancy
try
{
//bool CNPActive = ModsConfig.ActiveModsInLoadOrder.FirstIndexOf(m => m.Name == "Children and Pregnancy");//Won't work, name is wrong
xxx.babystate = DefDatabase<HediffDef>.GetNamedSilentFail("BabyState");
if (xxx.babystate is null)
{
xxx.RimWorldChildrenIsActive = false;
if (Prefs.DevMode) Log.Message("[RJW]Children&Pregnancy is not detected");
}
else
{
xxx.RimWorldChildrenIsActive = true;
if (Prefs.DevMode) Log.Message("[RJW]Children&Pregnancy is detected.");
}
}
catch (Exception)
{
xxx.RimWorldChildrenIsActive = false; //A dirty way to check if the mod is active
xxx.babystate = null;
if (Prefs.DevMode) Log.Message("[RJW]Children&Pregnancy is not detected.error");
}
//Combat Extended
try
{
xxx.MuscleSpasms = DefDatabase<HediffDef>.GetNamedSilentFail("MuscleSpasms");
if (xxx.MuscleSpasms is null)
{
xxx.CombatExtendedIsActive = false;
}
else
{
xxx.CombatExtendedIsActive = true;
if (Prefs.DevMode) Log.Message("[RJW]Combat Extended is detected. Current compatibility unknown, use at your own risk. ");
}
}
catch (Exception)
{
xxx.CombatExtendedIsActive = false;
xxx.MuscleSpasms = null;
if (Prefs.DevMode) Log.Message("[RJW]Combat Extended is not detected.error");
}
}
static First()
{
//--Log.Message("[RJW] First::First() called");
// check for required mods
//CheckModRequirements();
//CheckIncompatibleMods();
CheckingCompatibleMods();
inject_recipes();
inject_Reproduction();
nymph_backstories.init();
bondage_gear_tradeability.init();
var har = HarmonyInstance.Create("rjw");
har.PatchAll(Assembly.GetExecutingAssembly());
PATCH_Pawn_ApparelTracker_TryDrop.apply(har);
//CnPcompatibility.Patch(har); //CnP IS NO OUT YET
}
internal static void CheckModRequirements()
{
//--Log.Message("First::CheckModRequirements() called");
List<string> required_mods = new List<string> {
"HugsLib",
};
foreach (string required_mod in required_mods)
{
bool found = false;
foreach (ModMetaData installed_mod in ModLister.AllInstalledMods)
{
if (installed_mod.Active && installed_mod.Name.Contains(required_mod))
{
found = true;
}
if (!found)
{
ErrorMissingRequirement(required_mod);
}
}
}
}
internal static void CheckIncompatibleMods()
{
//--Log.Message("First::CheckIncompatibleMods() called");
List<string> incompatible_mods = new List<string> {
"Bogus Test Mod That Doesn't Exist"
};
foreach (string incompatible_mod in incompatible_mods)
{
foreach (ModMetaData installed_mod in ModLister.AllInstalledMods)
{
if (installed_mod.Active && installed_mod.Name.Contains(incompatible_mod))
{
ErrorIncompatibleMod(installed_mod);
}
}
}
}
internal static void ErrorMissingRequirement(string missing)
{
Log.Error("Initialization error: Unable to find required mod '" + missing + "' in mod list");
}
internal static void ErrorIncompatibleMod(ModMetaData othermod)
{
Log.Error("Initialization Error: Incompatible mod '" + othermod.Name + "' detected in mod list");
}
}
}
|
Mewtopian/rjw
|
Source/Harmony/First.cs
|
C#
|
mit
| 12,484 |
using Harmony;
using RimWorld;
using UnityEngine;
using Verse;
using Verse.Sound;
using System.Collections.Generic;
using System.Reflection;
using System.Reflection.Emit;
namespace rjw
{
[HarmonyPatch(typeof(CharacterCardUtility), "DrawCharacterCard")]
public static class SexcardPatch
{
public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
{
MethodInfo HighlightOpportunity = AccessTools.Method(typeof(UIHighlighter), "HighlightOpportunity");
MethodInfo SexualityCardToggle = AccessTools.Method(typeof(SexcardPatch), nameof(SexualityCardToggle));
bool traits = false;
bool found = false;
foreach (CodeInstruction i in instructions)
{
if (found)
{
yield return new CodeInstruction(OpCodes.Ldarg_0) { labels = i.labels.ListFullCopy() };//rect
yield return new CodeInstruction(OpCodes.Ldarg_1);//pawn
yield return new CodeInstruction(OpCodes.Ldarg_3);//creationRect
yield return new CodeInstruction(OpCodes.Call, SexualityCardToggle);
found = false;
i.labels.Clear();
}
if (i.opcode == OpCodes.Call && i.operand == HighlightOpportunity)
{
found = true;
}
if (i.opcode == OpCodes.Ldstr && i.operand.Equals("Traits"))
{
traits = true;
}
if (traits && i.opcode == OpCodes.Ldc_R4 && i.operand.Equals(2f))//replaces rect y calculation
{
yield return new CodeInstruction(OpCodes.Ldc_R4, 0f);
traits = false;
continue;
}
yield return i;
}
}
public static void SexualityCardToggle(Rect rect, Pawn pawn, Rect creationRect)
{
if (pawn == null) return;
if (CompRJW.Comp(pawn) == null) return;
Rect rectNew = new Rect(CharacterCardUtility.PawnCardSize.x - 50f, 2f, 24f, 24f);
if (Current.ProgramState != ProgramState.Playing)
{
if (xxx.IndividualityIsActive) // Move icon lower to avoid overlap.
rectNew = new Rect(creationRect.width - 24f, 56f, 24f, 24f);
else
rectNew = new Rect(creationRect.width - 24f, 30f, 24f, 24f);
}
Color old = GUI.color;
GUI.color = rectNew.Contains(Event.current.mousePosition) ? new Color(0.25f, 0.59f, 0.75f) : new Color(1f, 1f, 1f);
// TODO: Replace the placeholder icons with... something
if (CompRJW.Comp(pawn).quirks.ToString() != "None")
GUI.DrawTexture(rectNew, ContentFinder<Texture2D>.Get("UI/Commands/Service_on"));
else
GUI.DrawTexture(rectNew, ContentFinder<Texture2D>.Get("UI/Commands/Service_off"));
TooltipHandler.TipRegion(rectNew, "SexcardTooltip".Translate());
if (Widgets.ButtonInvisible(rectNew))
{
SoundDefOf.InfoCard_Open.PlayOneShotOnCamera();
Find.WindowStack.Add(new Dialog_Sexcard(pawn));
}
GUI.color = old;
}
}
}
|
Mewtopian/rjw
|
Source/Harmony/SexualityCard.cs
|
C#
|
mit
| 2,730 |
using System.Text;
using RimWorld;
using UnityEngine;
using Verse;
using System;
using System.Collections.Generic;
using System.Linq;
using Multiplayer.API;
namespace rjw
{
//TODO: check slime stuff working in mp
//TODO: separate menus in sub scripts
//TODO: add demon switch parts
//TODO: figure out and make interface?
//TODO: add vibration toggle for bionics(+50% partner satisfaction?)
public class Dialog_Sexcard : Window
{
private readonly Pawn pawn;
public Dialog_Sexcard(Pawn editFor)
{
pawn = editFor;
}
public static breasts Breasts;
public enum breasts
{
selectone,
none,
featureless_chest,
flat_breasts,
small_breasts,
average_breasts,
large_breasts,
huge_breasts,
slime_breasts,
};
public static anuses Anuses;
public enum anuses
{
selectone,
none,
micro_anus,
tight_anus,
average_anus,
loose_anus,
gaping_anus,
slime_anus,
};
public static vaginas Vaginas;
public enum vaginas
{
selectone,
none,
micro_vagina,
tight_vagina,
average_vagina,
loose_vagina,
gaping_vagina,
slime_vagina,
feline_vagina,
canine_vagina,
equine_vagina,
dragon_vagina,
};
public static penises Penises;
public enum penises
{
selectone,
none,
micro_penis,
small_penis,
average_penis,
big_penis,
huge_penis,
slime_penis,
feline_penis,
canine_penis,
equine_penis,
dragon_penis,
raccoon_penis,
hemipenis,
crocodilian_penis,
};
public void SexualityCard(Rect rect, Pawn pawn)
{
CompRJW comp = pawn.TryGetComp<CompRJW>();
if (pawn == null || comp == null) return;
Text.Font = GameFont.Medium;
Rect rect1 = new Rect(8f, 4f, rect.width - 8f, rect.height - 20f);
Widgets.Label(rect1, "RJW");//rjw
Text.Font = GameFont.Tiny;
float num = rect1.y + 40f;
Rect row1 = new Rect(10f, num, rect.width - 8f, 24f);//sexuality
Rect row2 = new Rect(10f, num + 24, rect.width - 8f, 24f);//quirks
Rect row3 = new Rect(10f, num + 48, rect.width - 8f, 24f);//whore price
//Rect sexuality_button = new Rect(10f, rect1.height - 0f, rect.width - 8f, 24f);//change sex pref
Rect button1 = new Rect(10f, rect1.height - 10f, rect.width - 8f, 24f);//re sexualize
Rect button2 = new Rect(10f, rect1.height - 34f, rect.width - 8f, 24f);//archtech toggle
Rect button3 = new Rect(10f, rect1.height - 58f, rect.width - 8f, 24f);//breast
Rect button4 = new Rect(10f, rect1.height - 82f, rect.width - 8f, 24f);//anus
Rect button5 = new Rect(10f, rect1.height - 106f, rect.width - 8f, 24f);//vagina
Rect button6 = new Rect(10f, rect1.height - 130f, rect.width - 8f, 24f);//penis 1
Rect button7 = new Rect(10f, rect1.height - 154f, rect.width - 8f, 24f);//penis 2
string price;
string sexuality;
// Check for Rational Romance consistency, in case the player adds it mid-game or adds traits (such as with Prepare Carefully)
if (xxx.RomanceDiversifiedIsActive || pawn.story.traits.HasTrait(TraitDefOf.Gay))
if (RJWPreferenceSettings.sexuality_distribution == RJWPreferenceSettings.Rjw_sexuality.RationalRomance)
CompRJW.RRTraitCheck(pawn);
switch (CompRJW.Comp(pawn).orientation)
{
case Orientation.Asexual:
sexuality = "Asexual";
break;
case Orientation.Bisexual:
sexuality = "Bisexual";
break;
case Orientation.Heterosexual:
sexuality = "Hetero";
break;
case Orientation.Homosexual:
sexuality = "Gay";
break;
case Orientation.LeaningHeterosexual:
sexuality = "Bisexual, leaning hetero";
break;
case Orientation.LeaningHomosexual:
sexuality = "Bisexual, leaning gay";
break;
case Orientation.MostlyHeterosexual:
sexuality = "Mostly hetero";
break;
case Orientation.MostlyHomosexual:
sexuality = "Mostly gay";
break;
case Orientation.Pansexual:
sexuality = "Pansexual";
break;
default:
sexuality = "None";
break;
}
//allow to change own hero sexuality
if (RJWPreferenceSettings.sexuality_distribution == RJWPreferenceSettings.Rjw_sexuality.RimJobWorld &&
Current.ProgramState == ProgramState.Playing &&
pawn.IsDesignatedHero() && pawn.IsHeroOwner())
{
if (Widgets.ButtonText(row1, "Sexuality: " + sexuality))
{
Find.WindowStack.Add(new FloatMenu(new List<FloatMenuOption>()
{
new FloatMenuOption("Asexual", (() => Change_orientation(pawn, Orientation.Asexual)), MenuOptionPriority.Default),
new FloatMenuOption("Pansexual", (() => Change_orientation(pawn, Orientation.Pansexual)), MenuOptionPriority.Default),
new FloatMenuOption("Heterosexual", (() => Change_orientation(pawn, Orientation.Heterosexual)), MenuOptionPriority.Default),
new FloatMenuOption("MostlyHeterosexual", (() => Change_orientation(pawn, Orientation.MostlyHeterosexual)), MenuOptionPriority.Default),
new FloatMenuOption("LeaningHeterosexual", (() => Change_orientation(pawn, Orientation.LeaningHeterosexual)), MenuOptionPriority.Default),
new FloatMenuOption("Bisexual", (() => Change_orientation(pawn, Orientation.Bisexual)), MenuOptionPriority.Default),
new FloatMenuOption("LeaningHomosexual", (() => Change_orientation(pawn, Orientation.LeaningHomosexual)), MenuOptionPriority.Default),
new FloatMenuOption("MostlyHomosexual", (() => Change_orientation(pawn, Orientation.MostlyHomosexual)), MenuOptionPriority.Default),
new FloatMenuOption("Homosexual", (() => Change_orientation(pawn, Orientation.Homosexual)), MenuOptionPriority.Default),
}));
}
}
else
{
Widgets.Label(row1, "Sexuality: " + sexuality);
if (Mouse.IsOver(row1))
Widgets.DrawHighlight(row1);
}
string quirklist = CompRJW.Comp(pawn).quirks.ToString();
Widgets.Label(row2, "Quirks".Translate() + quirklist);
if (Mouse.IsOver(row2))
{
Widgets.DrawHighlight(row2);
if (quirklist == "None")
TooltipHandler.TipRegion(row2, "NoQuirks".Translate());
else
{
StringBuilder tooltip = new StringBuilder();
if (quirklist.Contains("Breeder"))
tooltip.AppendLine("BreederQuirk".Translate());
if (quirklist.Contains("Endytophile"))
tooltip.AppendLine("EndytophileQuirk".Translate());
if (quirklist.Contains("Exhibitionist"))
tooltip.AppendLine("ExhibitionistQuirk".Translate());
if (quirklist.Contains("Fertile"))
tooltip.AppendLine("FertileQuirk".Translate());
if (quirklist.Contains("Gerontophile"))
tooltip.AppendLine("GerontophileQuirk".Translate());
if (quirklist.Contains("Impregnation fetish"))
tooltip.AppendLine("ImpregnationFetishQuirk".Translate());
if (quirklist.Contains("Incubator"))
tooltip.AppendLine("IncubatorQuirk".Translate());
if (quirklist.Contains("Infertile"))
tooltip.AppendLine("InfertileQuirk".Translate());
if (quirklist.Contains("Messy"))
tooltip.AppendLine("MessyQuirk".Translate());
if (quirklist.Contains("Podophile"))
tooltip.AppendLine("PodophileQuirk".Translate());
if (quirklist.Contains("Pregnancy fetish"))
tooltip.AppendLine("PregnancyFetishQuirk".Translate());
if (quirklist.Contains("Sapiosexual"))
tooltip.AppendLine("SapiosexualQuirk".Translate());
if (quirklist.Contains("Somnophile"))
tooltip.AppendLine("SomnophileQuirk".Translate());
if (quirklist.Contains("Teratophile"))
tooltip.AppendLine("TeratophileQuirk".Translate());
if (quirklist.Contains("Vigorous"))
tooltip.AppendLine("VigorousQuirk".Translate());
TooltipHandler.TipRegion(row2, tooltip.ToString());
}
}
if (RJWSettings.sex_minimum_age > pawn.ageTracker.AgeBiologicalYears)
price = "Inapplicable (too young)";
else if (pawn.ownership.OwnedRoom == null)
{
if (Current.ProgramState == ProgramState.Playing)
price = WhoringHelper.WhoreMinPrice(pawn) + " - " + WhoringHelper.WhoreMaxPrice(pawn) + " (base, needs suitable bedroom)";
else
price = WhoringHelper.WhoreMinPrice(pawn) + " - " + WhoringHelper.WhoreMaxPrice(pawn) + " (base, modified by bedroom quality)";
}
else if (xxx.is_animal(pawn))
price = "Incapable of whoring";
else
price = WhoringHelper.WhoreMinPrice(pawn) + " - " + WhoringHelper.WhoreMaxPrice(pawn);
Widgets.Label(row3, "WhorePrice".Translate() + price);
if (Mouse.IsOver(row3))
Widgets.DrawHighlight(row3);
// TODO: Add translations. or not
if (Prefs.DevMode || Current.ProgramState != ProgramState.Playing)
{
if (Widgets.ButtonText(button1, Current.ProgramState != ProgramState.Playing ? "Reroll sexuality" : "[DEV] Reroll sexuality"))
{
Re_sexualize(pawn);
}
}
if (pawn.health.hediffSet.HasHediff(Genital_Helper.archotech_penis) || pawn.health.hediffSet.HasHediff(Genital_Helper.archotech_vagina))
{
if (pawn.health.hediffSet.HasHediff(HediffDef.Named("ImpregnationBlocker")))
{
if (Widgets.ButtonText(button2, "[Archotech genitalia] Enable reproduction"))
{
Change_Archotechmode(pawn);
}
}
else if (!pawn.health.hediffSet.HasHediff(HediffDef.Named("FertilityEnhancer")))
{
if (Widgets.ButtonText(button2, "[Archotech genitalia] Enchance fertility"))
{
Change_Archotechmode(pawn);
}
}
else if (Widgets.ButtonText(button2, "[Archotech genitalia] Disable reproduction"))
{
Change_Archotechmode(pawn);
}
}
// TODO: add mp synchronizers
// TODO: clean that mess
// TODO: add demon toggles
if (MP.IsInMultiplayer)
return;
if (xxx.is_slime(pawn) && (pawn.IsColonistPlayerControlled || pawn.IsPrisonerOfColony))
{
BodyPartRecord bpr_genitalia = Genital_Helper.get_genitals(pawn);
BodyPartRecord bpr_breasts = Genital_Helper.get_breasts(pawn);
BodyPartRecord bpr_anus = Genital_Helper.get_anus(pawn);
BodyPartRecord bpr = null;
HediffDef hed = null;
if (Widgets.ButtonText(button3, "Morph breasts"))
{
Find.WindowStack.Add(new FloatMenu(new List<FloatMenuOption>()
{
new FloatMenuOption("none", (() => Breasts = breasts.none), MenuOptionPriority.Default),
new FloatMenuOption(Genital_Helper.featureless_chest.label.CapitalizeFirst(), (() => Breasts = breasts.featureless_chest), MenuOptionPriority.Default),
new FloatMenuOption(Genital_Helper.flat_breasts.label.CapitalizeFirst(), (() => Breasts = breasts.flat_breasts), MenuOptionPriority.Default),
new FloatMenuOption(Genital_Helper.small_breasts.label.CapitalizeFirst(), (() => Breasts = breasts.small_breasts), MenuOptionPriority.Default),
new FloatMenuOption(Genital_Helper.average_breasts.label.CapitalizeFirst(), (() => Breasts = breasts.average_breasts), MenuOptionPriority.Default),
new FloatMenuOption(Genital_Helper.large_breasts.label.CapitalizeFirst(), (() => Breasts = breasts.large_breasts), MenuOptionPriority.Default),
new FloatMenuOption(Genital_Helper.huge_breasts.label.CapitalizeFirst(), (() => Breasts = breasts.huge_breasts), MenuOptionPriority.Default),
new FloatMenuOption(Genital_Helper.slime_breasts.label.CapitalizeFirst(), (() => Breasts = breasts.slime_breasts), MenuOptionPriority.Default),
}));
}
switch (Breasts)
{
case breasts.none:
bpr = bpr_breasts;
break;
case breasts.featureless_chest:
bpr = bpr_breasts;
hed = Genital_Helper.featureless_chest;
break;
case breasts.flat_breasts:
bpr = bpr_breasts;
hed = Genital_Helper.flat_breasts;
break;
case breasts.small_breasts:
bpr = bpr_breasts;
hed = Genital_Helper.small_breasts;
break;
case breasts.average_breasts:
bpr = bpr_breasts;
hed = Genital_Helper.average_breasts;
break;
case breasts.large_breasts:
bpr = bpr_breasts;
hed = Genital_Helper.large_breasts;
break;
case breasts.huge_breasts:
bpr = bpr_breasts;
hed = Genital_Helper.huge_breasts;
break;
case breasts.slime_breasts:
bpr = bpr_breasts;
hed = Genital_Helper.slime_breasts;
break;
default:
break;
}
if (Widgets.ButtonText(button4, "Morph anus"))
{
Find.WindowStack.Add(new FloatMenu(new List<FloatMenuOption>()
{
new FloatMenuOption("none", (() => Anuses = anuses.none), MenuOptionPriority.Default),
new FloatMenuOption(Genital_Helper.micro_anus.label.CapitalizeFirst(), (() => Anuses = anuses.micro_anus), MenuOptionPriority.Default),
new FloatMenuOption(Genital_Helper.tight_anus.label.CapitalizeFirst(), (() => Anuses = anuses.tight_anus), MenuOptionPriority.Default),
new FloatMenuOption(Genital_Helper.average_anus.label.CapitalizeFirst(), (() => Anuses = anuses.average_anus), MenuOptionPriority.Default),
new FloatMenuOption(Genital_Helper.loose_anus.label.CapitalizeFirst(), (() => Anuses = anuses.loose_anus), MenuOptionPriority.Default),
new FloatMenuOption(Genital_Helper.gaping_anus.label.CapitalizeFirst(), (() => Anuses = anuses.gaping_anus), MenuOptionPriority.Default),
new FloatMenuOption(Genital_Helper.slime_anus.label.CapitalizeFirst(), (() => Anuses = anuses.slime_anus), MenuOptionPriority.Default),
}));
}
switch (Anuses)
{
case anuses.none:
bpr = bpr_anus;
break;
case anuses.micro_anus:
bpr = bpr_anus;
hed = Genital_Helper.micro_anus;
break;
case anuses.tight_anus:
bpr = bpr_anus;
hed = Genital_Helper.tight_anus;
break;
case anuses.average_anus:
bpr = bpr_anus;
hed = Genital_Helper.average_anus;
break;
case anuses.loose_anus:
bpr = bpr_anus;
hed = Genital_Helper.loose_anus;
break;
case anuses.gaping_anus:
bpr = bpr_anus;
hed = Genital_Helper.gaping_anus;
break;
case anuses.slime_anus:
bpr = bpr_anus;
hed = Genital_Helper.slime_anus;
break;
default:
break;
}
if (Widgets.ButtonText(button5, "Morph vagina"))
{
Find.WindowStack.Add(new FloatMenu(new List<FloatMenuOption>()
{
new FloatMenuOption("none", (() => Vaginas = vaginas.none), MenuOptionPriority.Default),
new FloatMenuOption(Genital_Helper.micro_vagina.label.CapitalizeFirst(), (() => Vaginas = vaginas.micro_vagina), MenuOptionPriority.Default),
new FloatMenuOption(Genital_Helper.tight_vagina.label.CapitalizeFirst(), (() => Vaginas = vaginas.tight_vagina), MenuOptionPriority.Default),
new FloatMenuOption(Genital_Helper.average_vagina.label.CapitalizeFirst(), (() => Vaginas = vaginas.average_vagina), MenuOptionPriority.Default),
new FloatMenuOption(Genital_Helper.loose_vagina.label.CapitalizeFirst(), (() => Vaginas = vaginas.loose_vagina), MenuOptionPriority.Default),
new FloatMenuOption(Genital_Helper.gaping_vagina.label.CapitalizeFirst(), (() => Vaginas = vaginas.gaping_vagina), MenuOptionPriority.Default),
new FloatMenuOption(Genital_Helper.slime_vagina.label.CapitalizeFirst(), (() => Vaginas = vaginas.slime_vagina), MenuOptionPriority.Default),
new FloatMenuOption(Genital_Helper.feline_vagina.label.CapitalizeFirst(), (() => Vaginas = vaginas.feline_vagina), MenuOptionPriority.Default),
new FloatMenuOption(Genital_Helper.canine_vagina.label.CapitalizeFirst(), (() => Vaginas = vaginas.canine_vagina), MenuOptionPriority.Default),
new FloatMenuOption(Genital_Helper.equine_vagina.label.CapitalizeFirst(), (() => Vaginas = vaginas.equine_vagina), MenuOptionPriority.Default),
new FloatMenuOption(Genital_Helper.dragon_vagina.label.CapitalizeFirst(), (() => Vaginas = vaginas.dragon_vagina), MenuOptionPriority.Default),
}));
}
switch (Vaginas)
{
case vaginas.none:
bpr = bpr_genitalia;
break;
case vaginas.micro_vagina:
bpr = bpr_genitalia;
hed = Genital_Helper.micro_vagina;
break;
case vaginas.tight_vagina:
bpr = bpr_genitalia;
hed = Genital_Helper.tight_vagina;
break;
case vaginas.average_vagina:
bpr = bpr_genitalia;
hed = Genital_Helper.average_vagina;
break;
case vaginas.loose_vagina:
bpr = bpr_genitalia;
hed = Genital_Helper.loose_vagina;
break;
case vaginas.gaping_vagina:
bpr = bpr_genitalia;
hed = Genital_Helper.gaping_vagina;
break;
case vaginas.slime_vagina:
bpr = bpr_genitalia;
hed = Genital_Helper.slime_vagina;
break;
case vaginas.feline_vagina:
bpr = bpr_genitalia;
hed = Genital_Helper.feline_vagina;
break;
case vaginas.canine_vagina:
bpr = bpr_genitalia;
hed = Genital_Helper.canine_vagina;
break;
case vaginas.equine_vagina:
bpr = bpr_genitalia;
hed = Genital_Helper.equine_vagina;
break;
case vaginas.dragon_vagina:
bpr = bpr_genitalia;
hed = Genital_Helper.dragon_vagina;
break;
default:
break;
}
if (Widgets.ButtonText(button6, "Morph penis"))
{
Find.WindowStack.Add(new FloatMenu(new List<FloatMenuOption>()
{
new FloatMenuOption("none", (() => Penises = penises.none), MenuOptionPriority.Default),
new FloatMenuOption(Genital_Helper.micro_penis.label.CapitalizeFirst(), (() => Penises = penises.micro_penis), MenuOptionPriority.Default),
new FloatMenuOption(Genital_Helper.small_penis.label.CapitalizeFirst(), (() => Penises = penises.small_penis), MenuOptionPriority.Default),
new FloatMenuOption(Genital_Helper.average_penis.label.CapitalizeFirst(), (() => Penises = penises.average_penis), MenuOptionPriority.Default),
new FloatMenuOption(Genital_Helper.big_penis.label.CapitalizeFirst(), (() => Penises = penises.big_penis), MenuOptionPriority.Default),
new FloatMenuOption(Genital_Helper.huge_penis.label.CapitalizeFirst(), (() => Penises = penises.huge_penis), MenuOptionPriority.Default),
new FloatMenuOption(Genital_Helper.slime_penis.label.CapitalizeFirst(), (() => Penises = penises.slime_penis), MenuOptionPriority.Default),
new FloatMenuOption(Genital_Helper.feline_penis.label.CapitalizeFirst(), (() => Penises = penises.feline_penis), MenuOptionPriority.Default),
new FloatMenuOption(Genital_Helper.canine_penis.label.CapitalizeFirst(), (() => Penises = penises.canine_penis), MenuOptionPriority.Default),
new FloatMenuOption(Genital_Helper.equine_penis.label.CapitalizeFirst(), (() => Penises = penises.equine_penis), MenuOptionPriority.Default),
new FloatMenuOption(Genital_Helper.dragon_penis.label.CapitalizeFirst(), (() => Penises = penises.dragon_penis), MenuOptionPriority.Default),
new FloatMenuOption(Genital_Helper.raccoon_penis.label.CapitalizeFirst(), (() => Penises = penises.raccoon_penis), MenuOptionPriority.Default),
new FloatMenuOption(Genital_Helper.hemipenis.label.CapitalizeFirst(), (() => Penises = penises.hemipenis), MenuOptionPriority.Default),
new FloatMenuOption(Genital_Helper.crocodilian_penis.label.CapitalizeFirst(), (() => Penises = penises.crocodilian_penis), MenuOptionPriority.Default),
}));
}
switch (Penises)
{
case penises.none:
bpr = bpr_genitalia;
break;
case penises.micro_penis:
bpr = bpr_genitalia;
hed = Genital_Helper.micro_penis;
break;
case penises.small_penis:
bpr = bpr_genitalia;
hed = Genital_Helper.small_penis;
break;
case penises.average_penis:
bpr = bpr_genitalia;
hed = Genital_Helper.average_penis;
break;
case penises.big_penis:
bpr = bpr_genitalia;
hed = Genital_Helper.big_penis;
break;
case penises.huge_penis:
bpr = bpr_genitalia;
hed = Genital_Helper.huge_penis;
break;
case penises.slime_penis:
bpr = bpr_genitalia;
hed = Genital_Helper.slime_penis;
break;
case penises.feline_penis:
bpr = bpr_genitalia;
hed = Genital_Helper.feline_penis;
break;
case penises.canine_penis:
bpr = bpr_genitalia;
hed = Genital_Helper.canine_penis;
break;
case penises.equine_penis:
bpr = bpr_genitalia;
hed = Genital_Helper.equine_penis;
break;
case penises.dragon_penis:
bpr = bpr_genitalia;
hed = Genital_Helper.dragon_penis;
break;
case penises.raccoon_penis:
bpr = bpr_genitalia;
hed = Genital_Helper.raccoon_penis;
break;
case penises.hemipenis:
bpr = bpr_genitalia;
hed = Genital_Helper.hemipenis;
break;
case penises.crocodilian_penis:
bpr = bpr_genitalia;
hed = Genital_Helper.crocodilian_penis;
break;
default:
break;
}
if (bpr != null)
{
//Log.Message("start ");
if (bpr != bpr_genitalia)
{
if (pawn.needs.TryGetNeed<Need_Food>().CurLevel > 0.5f)
{
pawn.needs.food.CurLevel -= 0.5f;
pawn.health.RestorePart(bpr);
if (hed != null)
pawn.health.AddHediff(hed, bpr);
}
Anuses = anuses.selectone;
Breasts = breasts.selectone;
}
else if (bpr == bpr_genitalia && Vaginas != vaginas.selectone)
{
if (pawn.needs.TryGetNeed<Need_Food>().CurLevel > 0.5f)
{
pawn.needs.food.CurLevel -= 0.5f;
List<Hediff> list = new List<Hediff>();
foreach (Hediff heddif in pawn.health.hediffSet.hediffs.Where(x =>
x.Part == bpr &&
x.def.defName.ToLower().Contains("vagina")))
list.Add(heddif);
foreach (Hediff heddif in list)
pawn.health.hediffSet.hediffs.Remove(heddif);
if (hed != null)
pawn.health.AddHediff(hed, bpr);
}
Vaginas = vaginas.selectone;
}
else if (bpr == bpr_genitalia && Penises != penises.selectone)
{
if (pawn.needs.TryGetNeed<Need_Food>().CurLevel > 0.5f)
{
pawn.needs.food.CurLevel -= 0.5f;
List<Hediff> list = new List<Hediff>();
foreach (Hediff heddif in pawn.health.hediffSet.hediffs.Where(x =>
x.Part == bpr &&
x.def.defName.ToLower().Contains("penis") ||
x.def.defName.ToLower().Contains("tentacle")))
list.Add(heddif);
foreach (Hediff heddif in list)
pawn.health.hediffSet.hediffs.Remove(heddif);
if (hed != null)
pawn.health.AddHediff(hed, bpr);
}
Penises = penises.selectone;
}
//Log.Message("end ");
}
}
}
[SyncMethod]
static void Change_orientation(Pawn pawn, Orientation orientation)
{
CompRJW.Comp(pawn).orientation = orientation;
}
[SyncMethod]
static void Change_Archotechmode(Pawn pawn)
{
BodyPartRecord genitalia = Genital_Helper.get_genitals(pawn);
Hediff blocker = pawn.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("ImpregnationBlocker"));
Hediff enhancer = pawn.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("FertilityEnhancer"));
if (blocker != null)
{
pawn.health.RemoveHediff(blocker);
}
else if (enhancer == null)
{
pawn.health.AddHediff(HediffDef.Named("FertilityEnhancer"), genitalia);
}
else
{
if (enhancer != null)
pawn.health.RemoveHediff(enhancer);
pawn.health.AddHediff(HediffDef.Named("ImpregnationBlocker"), genitalia);
}
}
[SyncMethod]
static void Re_sexualize(Pawn pawn)
{
CompRJW.Comp(pawn).Sexualize(pawn, true);
}
public override void DoWindowContents(Rect inRect)
{
bool flag = false;
soundClose = SoundDefOf.InfoCard_Close;
closeOnClickedOutside = true;
absorbInputAroundWindow = false;
forcePause = true;
preventCameraMotion = false;
if (Event.current.type == EventType.KeyDown && (Event.current.keyCode == KeyCode.Return || Event.current.keyCode == KeyCode.Escape))
{
flag = true;
Event.current.Use();
}
Rect windowRect = inRect.ContractedBy(17f);
Rect mainRect = new Rect(windowRect.x, windowRect.y, windowRect.width, windowRect.height - 20f);
Rect okRect = new Rect(inRect.width / 3, mainRect.yMax + 10f, inRect.width / 3f, 30f);
if (Current.ProgramState == ProgramState.Playing)
{
SexualityCard(mainRect, Find.Selector.SingleSelectedThing as Pawn);
}
else
{
SexualityCard(mainRect, pawn);
}
if (Widgets.ButtonText(okRect, "CloseButton".Translate()) || flag)
{
Close();
}
}
}
}
|
Mewtopian/rjw
|
Source/Harmony/SexualityCardInternal.cs
|
C#
|
mit
| 24,404 |
using Harmony;
using RimWorld;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection.Emit;
using System.Text;
using Verse;
namespace rjw
{
class SocialCardUtilityPatch
{
[HarmonyPatch(typeof(SocialCardUtility))]
[HarmonyPatch("DrawDebugOptions")]
public static class Patch_SocialCardUtility_DrawDebugOptions
{
//Create a new menu option that will contain some of the relevant data for debugging RJW
//Window space is limited, so keep to one line per pawn. Additional data may need a separate menu
static FloatMenuOption newMenuOption(Pawn pawn) {
return new FloatMenuOption("RJW WouldFuck", () =>
{
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.AppendLine();
stringBuilder.AppendLine("canFuck: " + xxx.can_fuck(pawn) + ", canBeFucked: " + xxx.can_be_fucked(pawn) + ", loving: " + xxx.can_do_loving(pawn));
stringBuilder.AppendLine("canRape: " + xxx.can_rape(pawn) + ", canBeRaped: " + xxx.can_get_raped(pawn));
stringBuilder.AppendLine();
stringBuilder.AppendLine("Humans - Colonists:");
foreach (Pawn partner in pawn.Map.mapPawns.AllPawnsSpawned.Where(x => x != pawn && x.RaceProps.Humanlike && x.IsColonist).OrderByDescending(x => xxx.would_fuck(pawn, x)))
{
stringBuilder.AppendLine(partner.LabelShort + " (" + partner.gender.GetLabel() +
", age: " + partner.ageTracker.AgeBiologicalYears +
", " + CompRJW.Comp(partner).orientation +
"): (fuck) " + xxx.would_fuck(pawn, partner).ToString("F3") +
"): (fucked) " + xxx.would_fuck(partner, pawn).ToString("F3") +
": (rape) " + xxx.would_rape(pawn, partner));
}
stringBuilder.AppendLine();
stringBuilder.AppendLine("Humans - Non Colonists:");
foreach (Pawn partner in pawn.Map.mapPawns.AllPawnsSpawned.Where(x => x != pawn && x.RaceProps.Humanlike && !x.IsColonist).OrderByDescending(x => xxx.would_fuck(pawn, x)))
{
stringBuilder.AppendLine(partner.LabelShort + " (" + partner.gender.GetLabel() +
", age: " + partner.ageTracker.AgeBiologicalYears +
", " + CompRJW.Comp(partner).orientation +
"): (fuck) " + xxx.would_fuck(pawn, partner).ToString("F3") +
"): (fucked) " + xxx.would_fuck(partner, pawn).ToString("F3") +
": (rape) " + xxx.would_rape(pawn, partner));
}
stringBuilder.AppendLine();
stringBuilder.AppendLine("Animals:");
foreach (Pawn partner in pawn.Map.mapPawns.AllPawnsSpawned.Where(x => x != pawn && x.RaceProps.Animal).OrderByDescending(x => xxx.would_fuck(pawn, x)))
{
stringBuilder.AppendLine(partner.LabelShort + " (" + partner.gender.GetLabel() +
", age: " + partner.ageTracker.AgeBiologicalYears +
", " + CompRJW.Comp(partner).orientation +
"): (fuck) " + xxx.would_fuck(pawn, partner).ToString("F3") +
"): (fucked) " + xxx.would_fuck(partner, pawn).ToString("F3") +
": (rape) " + xxx.would_rape(pawn, partner));
}
Find.WindowStack.Add(new Dialog_MessageBox(stringBuilder.ToString(), null, null, null, null, null, false, null, null));
}, MenuOptionPriority.Default, null, null, 0.0f, null, null);
}
static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
{
List<CodeInstruction> codes = instructions.ToList();
var addFunc = typeof(List<FloatMenuOption>).GetMethod("Add", new Type[] { typeof(FloatMenuOption) });
//Identify the last time options.Add() is called so we can place our new option afterwards
CodeInstruction lastAdd = codes.FindLast(ins => ins.opcode == OpCodes.Callvirt && ins.operand == addFunc);
for (int i = 0; i < codes.Count; ++i) {
yield return codes[i];
if (codes[i] == lastAdd) {
yield return new CodeInstruction(OpCodes.Ldloc_1);
yield return new CodeInstruction(OpCodes.Ldarg_1);
yield return new CodeInstruction(OpCodes.Call, AccessTools.Method(typeof(Patch_SocialCardUtility_DrawDebugOptions), nameof(newMenuOption)));
yield return new CodeInstruction(OpCodes.Callvirt, addFunc);
}
}
}
}
}
}
|
Mewtopian/rjw
|
Source/Harmony/SocialCardUtilityPatch.cs
|
C#
|
mit
| 4,110 |
using System;
using System.Collections.Generic;
using Harmony;
using RimWorld;
using Verse;
using Verse.AI.Group;
using System.Reflection;
namespace rjw
{
//TODO: Remove this patch for compatibility with other mods and add them to genital helper class.
/*
[HarmonyPatch(typeof(PawnGenerator), "GeneratePawn", new Type[] { typeof(PawnGenerationRequest) })]
internal static class Patches_GenerateRapist
{
public static void Postfix(Pawn __result, ref PawnGenerationRequest request)
{
if (__result == null) return;
if (__result.RaceProps.IsMechanoid)
{
BodyPartRecord genitalPart = __result.RaceProps.body.AllParts.Find(bpr => bpr.def.defName == "Genitals");
__result.health.AddHediff(HediffDef.Named("BionicPenis"), genitalPart);
}
if (PawnGenerationContext.NonPlayer.Includes(request.Context))
{
Need need = __result.needs.TryGetNeed<Need_Sex>();
if (need != null)
{
//need.ForceSetLevel(Rand.Range(0f,1f));
need.ForceSetLevel(Rand.Range(0.01f, 0.2f));
}
}
}
}*/
[HarmonyPatch(typeof(LordJob_AssaultColony), "CreateGraph")]
internal static class Patches_AssaultColonyForRape
{
public static void Postfix(StateGraph __result)
{
//--Log.Message("[ABF]AssaultColonyForRape::CreateGraph");
if (__result == null) return;
//--Log.Message("[RJW]AssaultColonyForRape::CreateGraph");
foreach (var trans in __result.transitions)
{
if (HasDesignatedTransition(trans))
{
foreach (Trigger t in trans.triggers)
{
if (t.filters == null)
{
t.filters = new List<TriggerFilter>() { new Trigger_SexSatisfy(0.3f) };
}
else
{
t.filters.Add(new Trigger_SexSatisfy(0.3f));
}
}
//--Log.Message("[ABF]AssaultColonyForRape::CreateGraph Adding SexSatisfyTrigger to " + trans.ToString());
}
}
}
private static bool HasDesignatedTransition(Transition t)
{
if (t.target == null) return false;
if (t.target.GetType() == typeof(LordToil_KidnapCover)) return true;
foreach (Trigger ta in t.triggers)
{
if (ta.GetType() == typeof(Trigger_FractionColonyDamageTaken)) return true;
}
return false;
}
}
/*
[HarmonyPatch(typeof(JobGiver_Manhunter), "TryGiveJob")]
static class Patches_ABF_MunHunt
{
public static void Postfix(Job __result, ref Pawn pawn)
{
//--Log.Message("[RJW]Patches_ABF_MunHunt::Postfix called");
if (__result == null) return;
if (__result.def == JobDefOf.Wait || __result.def == JobDefOf.Goto) __result = null;
}
}
*/
/*
//temporaly added code. Adding record will make savedata error...
[HarmonyPatch(typeof(DefMap<RecordDef, float>), "ExposeData")]
internal static class Patches_DefMapTweak
{
public static bool Prefix(DefMap<RecordDef, float> __instance)
{
var field = __instance.GetType().GetField("values", BindingFlags.GetField | BindingFlags.SetField | BindingFlags.NonPublic | BindingFlags.Instance);
var l = (field.GetValue(__instance) as List<float>);
while (l.Count < DefDatabase<RecordDef>.DefCount)
{
l.Add(0f);
}
//field.SetValue(__instance, (int)() + 1);
return true;
}
}
[HarmonyPatch(typeof(MemoryThoughtHandler), "TryGainMemory", new Type[]{typeof(Thought_Memory),typeof(Pawn)})]
internal static class Patches_MemoriesDebug
{
public static bool Prefix(MemoryThoughtHandler __instance, ref Thought_Memory newThought, ref Pawn otherPawn)
{
Log.Message(__instance.xxx.get_pawnname(pawn) + " adding " + newThought.LabelCap);
return true;
}
}
*/
[HarmonyPatch(typeof(SkillRecord), "CalculateTotallyDisabled")]
internal static class Patches_SkillRecordDebug
{
public static bool Prefix(SkillRecord __instance,ref bool __result)
{
var field = __instance.GetType().GetField("pawn", BindingFlags.GetField | BindingFlags.SetField | BindingFlags.NonPublic | BindingFlags.Instance);
Pawn pawn = (field.GetValue(__instance) as Pawn);
if (__instance.def == null)
{
Log.Message("no def!");
__result = false;
return false;
}
return true;
}
}
}
|
Mewtopian/rjw
|
Source/Harmony/patch_ABF.cs
|
C#
|
mit
| 4,059 |
using System;
using Harmony;
using Verse;
using Verse.AI;
namespace rjw
{
[HarmonyPatch(typeof(JobDriver), "Cleanup")]
internal static class PATCH_JobDriver_DubsBadHygiene
{
//not very good solution, some other mod can have same named jobdriver but w/e
//Dubs Bad Hygiene washing
private readonly static Type JobDriver_useWashBucket = AccessTools.TypeByName("JobDriver_useWashBucket");
private readonly static Type JobDriver_UseHotTub = AccessTools.TypeByName("JobDriver_UseHotTub");
private readonly static Type JobDriver_takeShower = AccessTools.TypeByName("JobDriver_takeShower");
private readonly static Type JobDriver_takeBath = AccessTools.TypeByName("JobDriver_takeBath");
[HarmonyPrefix]
private static bool on_cleanup_driver(JobDriver __instance, JobCondition condition)
{
if (__instance == null)
return true;
if (condition == JobCondition.Succeeded)
{
Pawn pawn = __instance.pawn;
//Log.Message("[RJW]patches_DubsBadHygiene::on_cleanup_driver" + xxx.get_pawnname(pawn));
if (xxx.DubsBadHygieneIsActive)
//clear one instance of semen
if (
__instance.GetType() == JobDriver_useWashBucket
)
{
Hediff hediff = pawn.health.hediffSet.hediffs.Find(x => ( x.def == RJW_SemenoOverlayHediffDefOf.Hediff_Semen
|| x.def == RJW_SemenoOverlayHediffDefOf.Hediff_InsectSpunk
|| x.def == RJW_SemenoOverlayHediffDefOf.Hediff_MechaFluids
));
if (hediff != null)
{
//Log.Message("[RJW]patches_DubsBadHygiene::" + __instance.GetType() + " clear => " + hediff.Label);
hediff.Severity -= 1f;
}
}
//clear all instance of semen
else if (
__instance.GetType() == JobDriver_UseHotTub ||
__instance.GetType() == JobDriver_takeShower ||
__instance.GetType() == JobDriver_takeBath
)
{
foreach (Hediff hediff in pawn.health.hediffSet.hediffs)
{
if (hediff.def == RJW_SemenoOverlayHediffDefOf.Hediff_Semen ||
hediff.def == RJW_SemenoOverlayHediffDefOf.Hediff_InsectSpunk ||
hediff.def == RJW_SemenoOverlayHediffDefOf.Hediff_MechaFluids
)
{
//Log.Message("[RJW]patches_DubsBadHygiene::" + __instance.GetType() + " clear => " + hediff.Label);
hediff.Severity -= 1f;
}
}
}
}
return true;
}
}
}
|
Mewtopian/rjw
|
Source/Harmony/patch_DubsBadHygiene.cs
|
C#
|
mit
| 2,412 |
using System.Linq;
using Harmony;
using RimWorld;
using Verse;
using System;
using System.Collections.Generic;
namespace rjw
{
// This will generate backstories and traits for the pawns not spawned through the IncidentWorker_NymphJoins
[HarmonyPatch(typeof(PawnGenerator), "GenerateNewPawnInternal")]
internal static class Patch_PawnGenerator_GenerateNewNakedPawn
{
[HarmonyPrefix]
private static void OnBegin_GenerateNewNakedPawn(ref PawnGenerationRequest request)
{
//--Log.Message("[RJW]Patch_PawnGenerator_GenerateNewNakedPawn::OnBegin_GenerateNewNakedPawn is called0");
PawnGenerationRequest PGR = request;
PawnKindDef pkd = PGR.KindDef;
if (pkd != null && pkd.defName == "Nymph")
{
//--Log.Message("[RJW]Patch_PawnGenerator_GenerateNewNakedPawn::OnBegin_GenerateNewNakedPawn is called1");
if (pkd.minGenerationAge != 20)
{
//--Log.Message("[RJW]Patch_PawnGenerator_GenerateNewNakedPawn::OnBegin_GenerateNewNakedPawn is called2");
pkd.minGenerationAge = 20;
pkd.maxGenerationAge = 27;
PGR = new PawnGenerationRequest(pkd,
PGR.Faction,
PGR.Context,
PGR.Tile, // tile(default is -1)
PGR.ForceGenerateNewPawn, // Force generate new pawn
PGR.Newborn, // Newborn
PGR.AllowDead, // Allow dead
PGR.AllowDowned, // Allow downed
PGR.CanGeneratePawnRelations, // Can generate pawn relations
PGR.MustBeCapableOfViolence, // Must be capable of violence
PGR.ColonistRelationChanceFactor, // Colonist relation chance factor
PGR.ForceAddFreeWarmLayerIfNeeded, // Force add free warm layer if needed
PGR.AllowGay, // Allow gay
PGR.AllowFood, // Allow food
PGR.Inhabitant, // Inhabitant
PGR.CertainlyBeenInCryptosleep, // Been in Cryosleep
PGR.ForceRedressWorldPawnIfFormerColonist, //forceRedressWorldPawnIfFormerColonist
PGR.WorldPawnFactionDoesntMatter, //worldPawnFactionDoesntMatter
c => (c.story.bodyType == BodyTypeDefOf.Female) || (c.story.bodyType == BodyTypeDefOf.Thin), // Validator
c => (c.story.bodyType == BodyTypeDefOf.Female) || (c.story.bodyType == BodyTypeDefOf.Thin), // Validator
PGR.MinChanceToRedressWorldPawn,
PGR.FixedBiologicalAge, // Fixed biological age
PGR.FixedChronologicalAge, // Fixed chronological age
Gender.Female, // Fixed gender
PGR.FixedMelanin, // Fixed melanin
PGR.FixedLastName); // Fixed last name
request = PGR;
}
}
//return;
}
}
// This will generate backstories and traits for the pawns not spawned through the IncidentWorker_NymphJoins
[HarmonyPatch(typeof(PawnGenerator), "GenerateTraits")]
internal static class Patch_PawnGenerator_GenerateTraits
{
[HarmonyPostfix]
private static void After_GenerateTraits(Pawn pawn, PawnGenerationRequest request)
{
if (request.KindDef != null && request.KindDef.defName == "Nymph" && request.Faction != Faction.OfPlayer)
{
nymph_generator.set_story(pawn);
}
}
}
}
|
Mewtopian/rjw
|
Source/Harmony/patch_backstory_generator.cs
|
C#
|
mit
| 3,168 |
using System;
using System.Reflection;
using Harmony;
using RimWorld;
using RimWorld.Planet;
using Verse;
using Verse.AI;
namespace rjw
{
[HarmonyPatch(typeof(Pawn_ApparelTracker))]
[HarmonyPatch("Wear")]
internal static class PATCH_Pawn_ApparelTracker_Wear
{
// Prevents pawns from equipping a piece of apparel if it conflicts with some locked apparel that they're already wearing
[HarmonyPrefix]
private static bool prevent_wear_by_gear(Pawn_ApparelTracker __instance, ref Apparel newApparel)
{
var tra = __instance;
// //--Log.Message ("Pawn_ApparelTracker.Wear called for " + newApparel.Label + " on " + tra.xxx.get_pawnname(pawn));
foreach (var app in tra.WornApparel)
if (app.has_lock() && (!ApparelUtility.CanWearTogether(newApparel.def, app.def, tra.pawn.RaceProps.body)))
{
if (PawnUtility.ShouldSendNotificationAbout(tra.pawn))
Messages.Message(xxx.get_pawnname(tra.pawn) + " can't wear " + newApparel.def.label + " (blocked by " + app.def.label + ")", tra.pawn, MessageTypeDefOf.NegativeEvent);
return false;
}
return true;
}
// Add the appropriate hediff when gear is worn
[HarmonyPostfix]
private static void on_wear(Pawn_ApparelTracker __instance, Apparel newApparel)
{
var tra = __instance;
if ((newApparel.def is bondage_gear_def def) &&
(newApparel.Wearer == tra.pawn))
{ // Check that the apparel was actually worn
def.soul.on_wear(tra.pawn, newApparel);
}
}
}
// Remove the hediff when the gear is removed
[HarmonyPatch(typeof(Pawn_ApparelTracker))]
[HarmonyPatch("Notify_ApparelRemoved")]
internal static class PATCH_Pawn_ApparelTracker_Remove
{
[HarmonyPostfix]
private static void on_remove(Pawn_ApparelTracker __instance, Apparel apparel)
{
if (apparel.def is bondage_gear_def def)
{
def.soul.on_remove(apparel, __instance.pawn);
}
}
}
// Patch the TryDrop method so that locked apparel cannot be dropped by JobDriver_RemoveApparel or by stripping
// a corpse or downed pawn
internal static class PATCH_Pawn_ApparelTracker_TryDrop
{
// Can't call MakeByRefType in an attribute, which is why this method is necessary.
private static MethodInfo get_target()
{
return typeof(Pawn_ApparelTracker).GetMethod("TryDrop", new Type[] {
typeof(Apparel),
typeof(Apparel).MakeByRefType (),
typeof(IntVec3),
typeof(bool)
});
}
// Can't just put [HarmonyTargetMethod] on get_target, which is why this method is necessary. BTW I don't
// know why HarmonyTargetMethod wasn't working. I'm sure I had everything set up properly so it might be a
// bug in Harmony itself, but I can't be bothered to look into it in detail.
public static void apply(HarmonyInstance har)
{
var tar = get_target();
var pat = typeof(PATCH_Pawn_ApparelTracker_TryDrop).GetMethod("prevent_locked_apparel_drop");
har.Patch(tar, new HarmonyMethod(pat), null);
}
public static bool prevent_locked_apparel_drop(Pawn_ApparelTracker __instance, ref Apparel ap, ref bool __result)
{
if (!ap.has_lock())
return true;
else
{
__result = false;
return false;
}
}
}
// Prevent locked apparel from being removed from a pawn who's out on a caravan
// TODO: Allow the apparel to be removed if the key is in the caravan's inventory
//[HarmonyPatch (typeof (WITab_Caravan_Gear))]
//[HarmonyPatch ("TryRemoveFromCurrentWearer")]
//static class PATCH_WITab_Caravan_Gear_TryRemoveFromCurrentWearer {
// [HarmonyPrefix]
// static bool prevent_locked_apparel_removal (WITab_Caravan_Gear __instance, Thing t, ref bool __result)
// {
// var app = t as Apparel;
// if ((app == null) || (! app.has_lock ()))
// return true;
// else {
// __result = false;
// return false;
// }
// }
//}
// Check for the special case where a player uses the caravan gear tab to equip a piece of lockable apparel on a pawn that
// is wearing an identical piece of already locked apparel, and make sure that doesn't work or change anything. This is to
// fix a bug where, even though the new apparel would fail to be equipped on the pawn, it would somehow copy the holostamp
// info from the equipped apparel.
[HarmonyPatch(typeof(WITab_Caravan_Gear))]
[HarmonyPatch("TryEquipDraggedItem")]
internal static class PATCH_WITab_Caravan_Gear_TryEquipDraggedItem
{
private static Thing get_dragged_item(WITab_Caravan_Gear tab)
{
return (Thing)typeof(WITab_Caravan_Gear).GetField("draggedItem", xxx.ins_public_or_no).GetValue(tab);
}
private static void set_dragged_item(WITab_Caravan_Gear tab, Thing t)
{
typeof(WITab_Caravan_Gear).GetField("draggedItem", xxx.ins_public_or_no).SetValue(tab, t);
}
[HarmonyPrefix]
private static bool prevent_locked_apparel_conflict(WITab_Caravan_Gear __instance, ref Pawn p)
{
if (__instance == null) return true;
if (get_dragged_item(__instance) is Apparel dragged_app && p.apparel != null && dragged_app.has_lock())
{
foreach (var equipped_app in p.apparel.WornApparel)
{
if (equipped_app.has_lock() && (!ApparelUtility.CanWearTogether(dragged_app.def, equipped_app.def, p.RaceProps.body)))
{
set_dragged_item(__instance, null);
return false;
}
}
}
return true;
}
}
/* GONE IN b19
// Prevent locked apparel from being removed from a corpse
// TODO: Find out when this method is actually called (probably doesn't matter but still)
[HarmonyPatch(typeof(Dialog_FormCaravan))]
[HarmonyPatch("RemoveFromCorpseIfPossible")]
internal static class PATCH_Dialog_FormCaravan_RemoveFromCorpseIfPossible
{
[HarmonyPrefix]
private static bool prevent_locked_apparel_removal(Dialog_FormCaravan __instance, Thing thing)
{
var app = thing as Apparel;
return (app == null) || (!app.has_lock());
}
}
*/
// Patch a method in a pawn gear tab to give the pawn a special job driver if the player tells them to
// drop locked apparel they have equipped
// TODO: Search for the key and, if the pawn can access it, give them a new job that has them go to the key
// and use it to unlock the apparel
[HarmonyPatch(typeof(ITab_Pawn_Gear))]
[HarmonyPatch("InterfaceDrop")]
internal static class PATCH_ITab_Pawn_Gear_InterfaceDrop
{
private static Pawn SelPawnForGear(ITab_Pawn_Gear tab)
{
var pro = typeof(ITab_Pawn_Gear).GetProperty("SelPawnForGear", xxx.ins_public_or_no);
return (Pawn)pro.GetValue(tab, null);
}
[HarmonyPrefix]
private static bool drop_locked_apparel(ITab_Pawn_Gear __instance, Thing t)
{
var tab = __instance;
var app = t as Apparel;
if ((app == null) || (!app.has_lock()))
return true;
else
{
var p = SelPawnForGear(tab);
if ((p.apparel != null) && (p.apparel.WornApparel.Contains(app)))
{
p.jobs.TryTakeOrderedJob(new Job(DefDatabase<JobDef>.GetNamed("StruggleInBondageGear"), app));
return false;
}
else
return true;
}
}
}
// Patch the method that prisoners use to find apparel in their cell so that they don't try to wear
// something that conflicts with locked apparel. The method used to prevent pawns from trying to
// optimize away locked apparel won't work here because prisoners don't check GetSpecialApparelScoreOffset.
[HarmonyPatch(typeof(JobGiver_PrisonerGetDressed))]
[HarmonyPatch("FindGarmentCoveringPart")]
internal static class PATCH_JobGiver_PrisonerGetDressed_FindGarmentCoveringPart
{
private static bool conflicts(Pawn_ApparelTracker tra, Apparel new_app)
{
foreach (var worn_app in tra.WornApparel)
if (worn_app.has_lock() && (!ApparelUtility.CanWearTogether(worn_app.def, new_app.def, tra.pawn.RaceProps.body)))
return true;
return false;
}
[HarmonyPrefix]
private static bool prevent_locked_apparel_conflict(JobGiver_PrisonerGetDressed __instance, Pawn pawn, BodyPartGroupDef bodyPartGroupDef, ref Apparel __result)
{
// If the prisoner is not wearing locked apparel then just run the regular method
if (!pawn.is_wearing_locked_apparel())
return true;
// Otherwise, duplicate the logic in the regular method except with an additional check
// to filter out apparel that conflicts with worn locked apparel.
else
{
var room = pawn.GetRoom();
if (room.isPrisonCell)
foreach (var c in room.Cells)
foreach (var t in c.GetThingList(pawn.Map))
{
if ((t is Apparel app) &&
app.def.apparel.bodyPartGroups.Contains(bodyPartGroupDef) &&
pawn.CanReserve(app) &&
ApparelUtility.HasPartsToWear(pawn, app.def) &&
(!conflicts(pawn.apparel, app)))
{
__result = app;
return false;
}
}
__result = null;
return false;
}
}
}
}
|
Mewtopian/rjw
|
Source/Harmony/patch_bondage_gear.cs
|
C#
|
mit
| 8,702 |
using System;
using System.Reflection;
using Harmony;
using RimWorld;
using Verse;
using Verse.AI;
namespace rjw
{
/// <summary>
/// Patch:
/// Core Loving, Mating
/// Rational Romance LovinCasual
/// CnP, remove pregnancy if rjw human preg enabled
/// </summary>
// Add a fail condition to JobDriver_Lovin that prevents pawns from lovin' if they aren't physically able/have genitals
[HarmonyPatch(typeof(JobDriver_Lovin), "MakeNewToils")]
internal static class PATCH_JobDriver_Lovin_MakeNewToils
{
[HarmonyPrefix]
private static bool on_begin_lovin(JobDriver_Lovin __instance)
{
Pawn pawn = __instance.pawn;
Pawn partner = null;
var any_ins = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;
partner = (Pawn)(__instance.GetType().GetProperty("Partner", any_ins).GetValue(__instance, null));
__instance.FailOn(() => (!(xxx.can_fuck(pawn) || xxx.can_be_fucked(pawn))));
__instance.FailOn(() => (!(xxx.can_fuck(partner) || xxx.can_be_fucked(partner))));
//this breaks job
//Log.Message("[RJW]patches_lovin::would_fuck" + xxx.would_fuck(pawn, partner));
//__instance.FailOn(() => (xxx.would_fuck(pawn, partner) < 0.1f));
return true;
}
}
// Add a fail condition to JobDriver_Mate that prevents animals from lovin' if they aren't physically able/have genitals
[HarmonyPatch(typeof(JobDriver_Mate), "MakeNewToils")]
internal static class PATCH_JobDriver_Mate_MakeNewToils
{
[HarmonyPrefix]
private static bool on_begin_matin(JobDriver_Mate __instance)
{
//only reproductive male starts mating job
__instance.FailOn(() =>
!(Genital_Helper.has_penis(__instance.pawn) || Genital_Helper.has_penis_infertile(__instance.pawn)));
return true;
}
}
//Patch for futa animals(vanialla - only male) to initiate mating
[HarmonyPatch(typeof(JobGiver_Mate), "TryGiveJob")]
internal static class PATCH_JobGiver_Mate_TryGiveJob
{
[HarmonyPostfix]
public static void Postfix(Job __result, Pawn pawn)
{
if (__result == null)
{
if (!(Genital_Helper.has_penis(pawn) || Genital_Helper.has_penis_infertile(pawn)) || !pawn.ageTracker.CurLifeStage.reproductive)
{
__result = null;
}
Predicate<Thing> validator = delegate (Thing t)
{
Pawn pawn3 = t as Pawn;
return !pawn3.Downed && pawn3.CanCasuallyInteractNow(false) && !pawn3.IsForbidden(pawn) && pawn3.Faction == pawn.Faction && PawnUtility.FertileMateTarget(pawn, pawn3);
};
Pawn pawn2 = (Pawn)GenClosest.ClosestThingReachable(pawn.Position, pawn.Map, ThingRequest.ForDef(pawn.def), PathEndMode.Touch, TraverseParms.For(pawn, Danger.Deadly, TraverseMode.ByPawn, false), 30f, validator, null, 0, -1, false, RegionType.Set_Passable, false);
if (pawn2 == null)
{
__result = null;
}
__result = new Job(JobDefOf.Mate, pawn2);
}
}
}
//JobDriver_DoLovinCasual from RomanceDiversified should have handled whether pawns can do casual lovin,
//so I don't bothered to do a check here, unless some bugs occur due to this.
//this prob needs a patch like above, but who cares
// Call xxx.aftersex after pawns have finished lovin'
// You might be thinking, "wouldn't it be easier to add this code as a finish condition to JobDriver_Lovin in the patch above?" I tried that
// at first but it didn't work because the finish condition is always called regardless of how the job ends (i.e. if it's interrupted or not)
// and there's no way to find out from within the finish condition how the job ended. I want to make sure not apply the effects of sex if the
// job was interrupted somehow.
[HarmonyPatch(typeof(JobDriver), "Cleanup")]
internal static class PATCH_JobDriver_Loving_Cleanup
{
//RomanceDiversified lovin
//not very good solution, some other mod can have same named jobdrivers, but w/e
private readonly static Type JobDriverDoLovinCasual = AccessTools.TypeByName("JobDriver_DoLovinCasual");
//vanilla lovin
private readonly static Type JobDriverLovin = typeof(JobDriver_Lovin);
//vanilla mate
private readonly static Type JobDriverMate = typeof(JobDriver_Mate);
[HarmonyPrefix]
private static bool on_cleanup_driver(JobDriver __instance, JobCondition condition)
{
if (__instance == null)
return true;
if (condition == JobCondition.Succeeded)
{
Pawn pawn = __instance.pawn;
Pawn partner = null;
//Log.Message("[RJW]patches_lovin::on_cleanup_driver" + xxx.get_pawnname(pawn));
//[RF] Rational Romance [1.0] loving
if (xxx.RomanceDiversifiedIsActive && __instance.GetType() == JobDriverDoLovinCasual)
{
// not sure RR can even cause pregnancies but w/e
var any_ins = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;
partner = (Pawn)(__instance.GetType().GetProperty("Partner", any_ins).GetValue(__instance, null));
Log.Message("[RJW]patches_lovin::on_cleanup_driver RomanceDiversified/RationalRomance:" + xxx.get_pawnname(pawn) + "+" + xxx.get_pawnname(partner));
}
//Vanilla loving
else if (__instance.GetType() == JobDriverLovin)
{
var any_ins = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;
partner = (Pawn)(__instance.GetType().GetProperty("Partner", any_ins).GetValue(__instance, null));
//CnP loving
if (xxx.RimWorldChildrenIsActive && RJWPregnancySettings.humanlike_pregnancy_enabled && xxx.is_human(pawn) && xxx.is_human(partner))
{
Log.Message("[RJW]patches_lovin:: RimWorldChildren/ChildrenAndPregnancy pregnancy:" + xxx.get_pawnname(pawn) + "+" + xxx.get_pawnname(partner));
PregnancyHelper.cleanup_CnP(pawn);
PregnancyHelper.cleanup_CnP(partner);
}
}
//Vanilla mating
else if (__instance.GetType() == JobDriverMate)
{
var any_ins = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;
partner = (Pawn)(__instance.GetType().GetProperty("Female", any_ins).GetValue(__instance, null));
}
else
return true;
//vanilla will probably be fucked up for non humanlikes... but only humanlikes do loving, right?
//if rjw pregnancy enabled, remove vanilla for:
//human-human
//animal-animal
//bestiality
//always remove when someone is insect or mech
if (RJWPregnancySettings.humanlike_pregnancy_enabled && xxx.is_human(pawn) && xxx.is_human(partner)
|| RJWPregnancySettings.animal_pregnancy_enabled && xxx.is_animal(pawn) && xxx.is_animal(partner)
|| (RJWPregnancySettings.bestial_pregnancy_enabled && xxx.is_human(pawn) && xxx.is_animal(partner)
|| RJWPregnancySettings.bestial_pregnancy_enabled && xxx.is_animal(pawn) && xxx.is_human(partner))
|| xxx.is_insect(pawn) || xxx.is_insect(partner) || xxx.is_mechanoid(pawn) || xxx.is_mechanoid(partner)
)
{
Log.Message("[RJW]patches_lovin::on_cleanup_driver vanilla pregnancy:" + xxx.get_pawnname(pawn) + "+" + xxx.get_pawnname(partner));
PregnancyHelper.cleanup_vanilla(pawn);
PregnancyHelper.cleanup_vanilla(partner);
}
SexUtility.ProcessSex(pawn, partner, false, true);
}
return true;
}
}
}
|
Mewtopian/rjw
|
Source/Harmony/patch_lovin.cs
|
C#
|
mit
| 7,096 |
namespace rjw
{
/*
[HarmonyPatch(typeof(Pawn_NeedsTracker))]
[HarmonyPatch("ShouldHaveNeed")]
static class patches_need
{
[HarmonyPostfix]
static void on_postfix(Pawn_NeedsTracker __instance, NeedDef nd, ref bool __result){
Pawn p=(Pawn)(typeof(Pawn_NeedsTracker).GetField("pawn", xxx.ins_public_or_no).GetValue(__instance));
__result = __result && (nd.defName != "Sex" || (p!=null && p.Map!=null));
}
}
*/
}
|
Mewtopian/rjw
|
Source/Harmony/patch_need.cs
|
C#
|
mit
| 430 |
using Harmony;
using RimWorld;
using RimWorld.Planet;
using UnityEngine;
using Verse;
using Multiplayer.API;
namespace rjw
{
[HarmonyPatch(typeof(Hediff_Pregnant), "DoBirthSpawn")]
internal static class PATCH_Hediff_Pregnant_DoBirthSpawn
{
/// <summary>
/// This one overrides vanilla pregnancy hediff behavior.
/// 0 - try to find suitable father for debug pregnancy
/// 1st part if character pregnant and rjw pregnancies enabled - creates rjw pregnancy and instantly births it instead of vanilla
/// 2nd part if character pregnant with rjw pregnancy - birth it
/// 3rd part - debug - create rjw/vanila pregnancy and birth it
/// </summary>
/// <param name="mother"></param>
/// <param name="father"></param>
/// <returns></returns>
[HarmonyPrefix]
[SyncMethod]
private static bool on_begin_DoBirthSpawn(ref Pawn mother, ref Pawn father)
{
//--Log.Message("patches_pregnancy::PATCH_Hediff_Pregnant::DoBirthSpawn() called");
if (mother == null)
{
Log.Error("Hediff_Pregnant::DoBirthSpawn() - no mother defined -> exit");
return false;
}
//vanilla debug?
if (mother.gender == Gender.Male)
{
Log.Error("Hediff_Pregnant::DoBirthSpawn() - mother is male -> exit");
return false;
}
//Rand.PopState();
//Rand.PushState(RJW_Multiplayer.PredictableSeed());
// get a reference to the hediff we are applying
//do birth for vanilla pregnancy Hediff
//if using rjw pregnancies - add RJW pregnancy Hediff and birth it instead
Hediff_Pregnant self = (Hediff_Pregnant)mother.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("Pregnant"));
if (self != null)
{
if (father == null)
{
father = Hediff_BasePregnancy.Trytogetfather(ref mother);
}
Log.Message("patches_pregnancy::PATCH_Hediff_Pregnant::DoBirthSpawn():Vanilla_pregnancy birthing:" + xxx.get_pawnname(mother));
if (RJWPregnancySettings.animal_pregnancy_enabled && ((father == null || xxx.is_animal(father)) && xxx.is_animal(mother)))
{
//RJW Bestial pregnancy animal-animal
Log.Message(" override as Bestial birthing(animal-animal): Father-" + xxx.get_pawnname(father) + " Mother-" + xxx.get_pawnname(mother));
Hediff_BestialPregnancy.Create(mother, father);
Hediff_BestialPregnancy hediff = (Hediff_BestialPregnancy)mother.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("RJW_pregnancy_beast"));
hediff.Initialize(mother, father);
hediff.GiveBirth();
if (self != null)
mother.health.RemoveHediff(self);
return false;
}
else if (RJWPregnancySettings.bestial_pregnancy_enabled && ((xxx.is_animal(father) && xxx.is_human(mother)) || (xxx.is_human(father) && xxx.is_animal(mother))))
{
//RJW Bestial pregnancy human-animal
Log.Message(" override as Bestial birthing(human-animal): Father-" + xxx.get_pawnname(father) + " Mother-" + xxx.get_pawnname(mother));
Hediff_BestialPregnancy.Create(mother, father);
Hediff_BestialPregnancy hediff = (Hediff_BestialPregnancy)mother.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("RJW_pregnancy_beast"));
hediff.Initialize(mother, father);
hediff.GiveBirth();
if (self != null)
mother.health.RemoveHediff(self);
return false;
}
else if (RJWPregnancySettings.humanlike_pregnancy_enabled && (xxx.is_human(father) && xxx.is_human(mother)))
{
//RJW Humanlike pregnancy
Log.Message(" override as Humanlike birthing: Father-" + xxx.get_pawnname(father) + " Mother-" + xxx.get_pawnname(mother));
Hediff_HumanlikePregnancy.Create(mother, father);
Hediff_HumanlikePregnancy hediff = (Hediff_HumanlikePregnancy)mother.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("RJW_pregnancy"));
hediff.Initialize(mother, father);
hediff.GiveBirth();
if (self != null)
mother.health.RemoveHediff(self);
return false;
}
else
{
Log.Warning("Hediff_Pregnant::DoBirthSpawn() - rjw checks failed, vanilla pregnancy birth");
Log.Warning("Hediff_Pregnant::DoBirthSpawn(): Father-" + xxx.get_pawnname(father) + " Mother-" + xxx.get_pawnname(mother));
//vanilla pregnancy code, no effects on rjw
int num = (mother.RaceProps.litterSizeCurve == null) ? 1 : Mathf.RoundToInt(Rand.ByCurve(mother.RaceProps.litterSizeCurve));
if (num < 1)
{
num = 1;
}
PawnGenerationRequest request = new PawnGenerationRequest(mother.kindDef, mother.Faction, PawnGenerationContext.NonPlayer, -1, forceGenerateNewPawn: false, newborn: true);
Pawn pawn = null;
for (int i = 0; i < num; i++)
{
pawn = PawnGenerator.GeneratePawn(request);
if (PawnUtility.TrySpawnHatchedOrBornPawn(pawn, mother))
{
if (pawn.playerSettings != null && mother.playerSettings != null)
{
pawn.playerSettings.AreaRestriction = mother.playerSettings.AreaRestriction;
}
if (pawn.RaceProps.IsFlesh)
{
pawn.relations.AddDirectRelation(PawnRelationDefOf.Parent, mother);
if (father != null)
{
pawn.relations.AddDirectRelation(PawnRelationDefOf.Parent, father);
}
}
}
else
{
Find.WorldPawns.PassToWorld(pawn, PawnDiscardDecideMode.Discard);
}
TaleRecorder.RecordTale(TaleDefOf.GaveBirth, mother, pawn);
}
if (mother.Spawned)
{
FilthMaker.MakeFilth(mother.Position, mother.Map, ThingDefOf.Filth_AmnioticFluid, mother.LabelIndefinite(), 5);
if (mother.caller != null)
{
mother.caller.DoCall();
}
if (pawn.caller != null)
{
pawn.caller.DoCall();
}
}
if (self != null)
mother.health.RemoveHediff(self);
return false;
}
}
// do birth for existing RJW pregnancies
Hediff_HumanlikePregnancy rjwH = (Hediff_HumanlikePregnancy)mother.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("RJW_pregnancy"));
if (rjwH != null)
{
//RJW Bestial pregnancy
Log.Message("patches_pregnancy::PATCH_Hediff_Pregnant::DoBirthSpawn():RJW_pregnancy birthing:" + xxx.get_pawnname(mother));
rjwH.GiveBirth();
if (self == null)
return false;
}
Hediff_BestialPregnancy rjwB = (Hediff_BestialPregnancy)mother.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("RJW_pregnancy_beast"));
if (rjwB != null)
{
//RJW Humanlike pregnancy
Log.Message("patches_pregnancy::PATCH_Hediff_Pregnant::DoBirthSpawn():RJW_pregnancy_beast birthing:" + xxx.get_pawnname(mother));
rjwB.GiveBirth();
if (self == null)
return false;
}
//debug, add RJW pregnancy and birth it
Log.Message("patches_pregnancy::PATCH_Hediff_Pregnant::DoBirthSpawn():Debug_pregnancy birthing:" + xxx.get_pawnname(mother));
if (father == null)
{
father = Hediff_BasePregnancy.Trytogetfather(ref mother);
}
/*
if (true)
{
//RJW Mech pregnancy
Log.Message(" override as mech birthing:" + xxx.get_pawnname(mother));
Hediff_MechanoidPregnancy.Create(mother, father);
Hediff_MechanoidPregnancy hediff = (Hediff_MechanoidPregnancy)mother.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("RJW_pregnancy_mech"));
hediff.GiveBirth();
return false;
}
*/
if (RJWPregnancySettings.bestial_pregnancy_enabled && ((xxx.is_animal(father) || xxx.is_animal(mother)))
|| (xxx.is_animal(mother) && RJWPregnancySettings.animal_pregnancy_enabled))
{
//RJW Bestial pregnancy
Log.Message(" override as Bestial birthing, mother: " + xxx.get_pawnname(mother));
Hediff_BestialPregnancy.Create(mother, father);
Hediff_BestialPregnancy hediff = (Hediff_BestialPregnancy)mother.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("RJW_pregnancy_beast"));
hediff.GiveBirth();
}
else if (RJWPregnancySettings.humanlike_pregnancy_enabled && ((father == null ||xxx.is_human(father)) && xxx.is_human(mother)))
{
//RJW Humanlike pregnancy
Log.Message(" override as Humanlike birthing, mother: " + xxx.get_pawnname(mother));
Hediff_HumanlikePregnancy.Create(mother, father);
Hediff_HumanlikePregnancy hediff = (Hediff_HumanlikePregnancy)mother.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("RJW_pregnancy"));
hediff.GiveBirth();
}
else
{
Log.Warning("Hediff_Pregnant::DoBirthSpawn() - debug vanilla pregnancy birth");
//vanilla code
int num = (mother.RaceProps.litterSizeCurve == null) ? 1 : Mathf.RoundToInt(Rand.ByCurve(mother.RaceProps.litterSizeCurve));
if (num < 1)
{
num = 1;
}
PawnGenerationRequest request = new PawnGenerationRequest(mother.kindDef, mother.Faction, PawnGenerationContext.NonPlayer, -1, forceGenerateNewPawn: false, newborn: true);
Pawn pawn = null;
for (int i = 0; i < num; i++)
{
pawn = PawnGenerator.GeneratePawn(request);
if (PawnUtility.TrySpawnHatchedOrBornPawn(pawn, mother))
{
if (pawn.playerSettings != null && mother.playerSettings != null)
{
pawn.playerSettings.AreaRestriction = mother.playerSettings.AreaRestriction;
}
if (pawn.RaceProps.IsFlesh)
{
pawn.relations.AddDirectRelation(PawnRelationDefOf.Parent, mother);
if (father != null)
{
pawn.relations.AddDirectRelation(PawnRelationDefOf.Parent, father);
}
}
}
else
{
Find.WorldPawns.PassToWorld(pawn, PawnDiscardDecideMode.Discard);
}
TaleRecorder.RecordTale(TaleDefOf.GaveBirth, mother, pawn);
}
if (mother.Spawned)
{
FilthMaker.MakeFilth(mother.Position, mother.Map, ThingDefOf.Filth_AmnioticFluid, mother.LabelIndefinite(), 5);
if (mother.caller != null)
{
mother.caller.DoCall();
}
if (pawn.caller != null)
{
pawn.caller.DoCall();
}
}
if (self != null)
mother.health.RemoveHediff(self);
}
return false;
}
}
[HarmonyPatch(typeof(Hediff_Pregnant), "Tick")]
class PATCH_Hediff_Pregnant_Tick
{
[HarmonyPrefix]
static bool on_begin_Tick( Hediff_Pregnant __instance )
{
if (__instance.pawn.IsHashIntervalTick(1000))
{
if (!Genital_Helper.has_vagina(__instance.pawn))
{
__instance.pawn.health.RemoveHediff(__instance);
}
}
return true;
}
}
}
|
Mewtopian/rjw
|
Source/Harmony/patch_pregnancy.cs
|
C#
|
mit
| 10,252 |
using System.Linq;
using Verse;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using Harmony;
using Harmony.ILCopying;
using RimWorld;
using UnityEngine;
using Verse.AI;
using Verse.Grammar;
using OpCodes = System.Reflection.Emit.OpCodes;
namespace rjw
{
/// <summary>
/// Patch all races
/// 1) into rjw parts recipes
/// 2) remove bodyparts from non animals and human likes
/// </summary>
[StaticConstructorOnStartup]
public static class HarmonyPatches
{
static HarmonyPatches()
{
//summons carpet bombing
//inject races into rjw recipes
foreach (RecipeDef x in DefDatabase<RecipeDef>.AllDefsListForReading.Where(x => x.IsSurgery && (x.targetsBodyPart || !x.appliedOnFixedBodyParts.NullOrEmpty())))
{
if (x.appliedOnFixedBodyParts.Contains(xxx.genitalsDef)
|| x.appliedOnFixedBodyParts.Contains(xxx.breastsDef)
|| x.appliedOnFixedBodyParts.Contains(xxx.anusDef)
)
foreach (ThingDef thingDef in DefDatabase<ThingDef>.AllDefs.Where(thingDef =>
thingDef.race != null && (
thingDef.race.Humanlike ||
thingDef.race.Animal
)))
{
//filter out something, probably?
//if (thingDef.race. == "Human")
// continue;
if (!x.recipeUsers.Contains(thingDef))
x.recipeUsers.Add(item: thingDef);
}
}
//TODO: fix errors?
/*
//remove rjw bodyparts from non animals and non humanlikes
foreach (ThingDef thingDef in DefDatabase<ThingDef>.AllDefs.Where(thingDef =>
thingDef.race != null && !(
thingDef.race.Humanlike ||
thingDef.race.Animal
)))
{
if (thingDef.race.body.AllParts.Exists(x => x.def == xxx.genitalsDef))
thingDef.race.body.AllParts.Remove(thingDef.race.body.AllParts.Find(bpr => bpr.def.defName == "Genitals"));
if (thingDef.race.body.AllParts.Exists(x => x.def == xxx.breastsDef))
thingDef.race.body.AllParts.Remove(thingDef.race.body.AllParts.Find(bpr => bpr.def.defName == "Chest"));
if (thingDef.race.body.AllParts.Exists(x => x.def == xxx.anusDef))
thingDef.race.body.AllParts.Remove(thingDef.race.body.AllParts.Find(bpr => bpr.def.defName == "Anus"));
}
*/
}
}
}
|
Mewtopian/rjw
|
Source/Harmony/patch_races.cs
|
C#
|
mit
| 2,311 |
using Harmony;
using RimWorld;
using Verse;
namespace rjw
{
///<summary>
///RJW Designators checks/update
///update designators only for selected pawn, once, instead of every tick(60 times per sec)
///</summary>
[HarmonyPatch(typeof(Selector), "Select")]
[StaticConstructorOnStartup]
static class PawnSelect
{
[HarmonyPrefix]
private static bool pawnSelect(Selector __instance, ref object obj)
{
if (obj is Pawn)
{
//Log.Message("[rjw]Selector patch");
Pawn pawn = (Pawn)obj;
//Log.Message("[rjw]pawn: " + xxx.get_pawnname(pawn));
pawn.UpdateCanChangeDesignationPrisoner();
pawn.UpdateCanChangeDesignationColonist();
pawn.UpdateCanDesignateService();
pawn.UpdateCanDesignateComfort();
pawn.UpdateCanDesignateBreedingAnimal();
pawn.UpdateCanDesignateBreeding();
pawn.UpdateCanDesignateHero();
}
return true;
}
}
}
|
Mewtopian/rjw
|
Source/Harmony/patch_selector.cs
|
C#
|
mit
| 883 |
using System.Collections.Generic;
using Verse;
using Harmony;
using UnityEngine;
using System;
using RimWorld;
using Multiplayer.API;
namespace rjw
{
[HarmonyPatch(typeof(RimWorld.PawnWoundDrawer))]
[HarmonyPatch("RenderOverBody")]
[HarmonyPatch(new Type[] { typeof(Vector3), typeof(Mesh), typeof(Quaternion), typeof(bool) })]
class patch_semenOverlay
{
static void Postfix(RimWorld.PawnWoundDrawer __instance, Vector3 drawLoc, Mesh bodyMesh, Quaternion quat, bool forPortrait)
{
Pawn pawn = Traverse.Create(__instance).Field("pawn").GetValue<Pawn>();//get local variable
//TODO add support for animals? unlikely as they has weird meshes
//for now, only draw humans
if (pawn.RaceProps.Humanlike && RJWSettings.cum_overlays)
{
//find bukkake hediff. if it exists, use its draw function
List<Hediff> hediffs = pawn.health.hediffSet.hediffs;
if (hediffs.Exists(x => x.def == RJW_SemenoOverlayHediffDefOf.Hediff_Bukkake))
{
Hediff_Bukkake h = hediffs.Find(x => x.def == RJW_SemenoOverlayHediffDefOf.Hediff_Bukkake) as Hediff_Bukkake;
quat.ToAngleAxis(out float angle, out Vector3 axis);//angle changes when pawn is e.g. downed
//adjustments if the pawn is sleeping in a bed:
bool inBed = false;
Building_Bed building_Bed = pawn.CurrentBed();
if (building_Bed != null)
{
inBed = !building_Bed.def.building.bed_showSleeperBody;
AltitudeLayer altLayer = (AltitudeLayer)Mathf.Max((int)building_Bed.def.altitudeLayer, 15);
Vector3 vector2 = pawn.Position.ToVector3ShiftedWithAltitude(altLayer);
vector2.y += 0.02734375f+0.01f;//just copied from rimworld code+0.01f
drawLoc.y = vector2.y;
}
h.DrawSemen(drawLoc, quat, forPortrait, angle);
}
}
}
}
//adds new gizmo for adding semen for testing
[HarmonyPatch(typeof(Pawn))]
[HarmonyPatch("GetGizmos")]
class Patch_AddGizmo
{
static void Postfix(Pawn __instance, ref IEnumerable<Gizmo> __result)
{
List<Gizmo> NewList = new List<Gizmo>();
// copy vanilla entries into the new list
foreach (Gizmo entry in __result)
{
NewList.Add(entry);
}
if (Prefs.DevMode && RJWSettings.DevMode && !MP.IsInMultiplayer)
{
Command_Action addSemen = new Command_Action();
addSemen.defaultDesc = "AddSemenHediff";
addSemen.defaultLabel = "AddSemen";
addSemen.action = delegate ()
{
Addsemen(__instance);
};
NewList.Add(addSemen);
}
IEnumerable<Gizmo> output = NewList;
// make caller use the list
__result = output;
}
[SyncMethod]
static void Addsemen(Pawn pawn)
{
//Log.Message("add semen button is pressed for " + pawn);
if (!pawn.Dead && pawn.records != null)
{
//get all acceptable body parts:
IEnumerable<BodyPartRecord> filteredParts = SemenHelper.getAvailableBodyParts(pawn);
//select random part:
BodyPartRecord randomPart;
//filteredParts.TryRandomElement<BodyPartRecord>(out randomPart);
//for testing - choose either genitals or anus:
//Rand.PopState();
//Rand.PushState(RJW_Multiplayer.PredictableSeed());
if (Rand.Value > 0.5f)
{
randomPart = pawn.RaceProps.body.AllParts.Find(x => x.def == xxx.anusDef);
}
else
{
randomPart = pawn.RaceProps.body.AllParts.Find(x => x.def == xxx.genitalsDef);
}
if (randomPart != null)
{
SemenHelper.cumOn(pawn, randomPart, 0.2f, null, SemenHelper.CUM_NORMAL);
}
};
}
}
}
|
Mewtopian/rjw
|
Source/Harmony/patch_semenOverlay.cs
|
C#
|
mit
| 3,468 |
using System.Linq;
using Verse;
using System.Collections.Generic;
using Harmony;
using RimWorld;
namespace rjw
{
/// <summary>
/// Patch ui for hero mode
/// - disable pawn control for non owned hero
/// - disable equipment management for non owned hero
/// hardcore mode:
/// - disable equipment management for non hero
/// - disable pawn rmb menu for non hero
/// - remove drafting widget for non hero
/// </summary>
//disable forced works
[HarmonyPatch(typeof(FloatMenuMakerMap), "CanTakeOrder")]
[StaticConstructorOnStartup]
static class disable_FloatMenuMakerMap
{
[HarmonyPostfix]
static void this_is_postfix(ref bool __result, Pawn pawn)
{
if (RJWSettings.RPG_hero_control)
{
if ((pawn.IsDesignatedHero() && !pawn.IsHeroOwner()))
{
__result = false; //not hero owner, disable menu
return;
}
if (!pawn.IsDesignatedHero() && RJWSettings.RPG_hero_control_HC)
{
if (pawn.Drafted && pawn.CanChangeDesignationPrisoner() && pawn.CanChangeDesignationColonist())
{
//allow control over drafted pawns, this is limited by below disable_Gizmos patch
}
else
{
__result = false; //not hero, disable menu
}
}
}
}
}
//TODO: disable equipment management
/*
//disable equipment management
[HarmonyPatch(typeof(ITab_Pawn_Gear), "CanControl")]
static class disable_equipment_management
{
[HarmonyPostfix]
static bool this_is_postfix(ref bool __result, Pawn selPawnForGear)
{
Pawn pawn = selPawnForGear;
if (RJWSettings.RPG_hero_control)
{
if ((pawn.IsDesignatedHero() && !pawn.IsHeroOwner())) //not hero owner, disable drafting
{
__result = false; //not hero owner, disable menu
}
else if (!pawn.IsDesignatedHero() && RJWSettings.RPG_hero_control_HC) //not hero, disable drafting
{
if (false)
{
//add some filter for bots and stuff? if there is such stuff
//so it can be drafted and controlled for fighting
}
else
{
__result = false; //not hero, disable menu
}
}
}
return true;
}
}
*/
//TODO: fix error
//TODO: allow shared control over non colonists(droids, etc)?
//disable drafting
[HarmonyPatch(typeof(Pawn), "GetGizmos")]
[StaticConstructorOnStartup]
static class disable_Gizmos
{
[HarmonyPostfix]
static void this_is_postfix(ref IEnumerable<Gizmo> __result, ref Pawn __instance)
{
Pawn pawn = __instance;
List<Gizmo> gizmos = __result.ToList();
if (RJWSettings.RPG_hero_control)
{
if ((pawn.IsDesignatedHero() && !pawn.IsHeroOwner())) //not hero owner, disable drafting
{
foreach (var x in __result.ToList())
{
try
{
//Log.Message("disable_drafter gizmos: " + x);
if ((x as Command).defaultLabel == "Draft")
gizmos.Remove(x as Gizmo);
}
catch
{ }
};
}
else if (!pawn.IsDesignatedHero() && RJWSettings.RPG_hero_control_HC) //not hero, disable drafting
{
//no permission to change designation for NON prisoner hero/ other player
if (pawn.CanChangeDesignationPrisoner() && pawn.CanChangeDesignationColonist()
&& (pawn.kindDef.race.defName.Contains("AIRobot")
|| (pawn.kindDef.race.defName.Contains("Droid") && !pawn.kindDef.race.defName.Contains("AndDroid"))
|| pawn.kindDef.race.defName.Contains("RPP_Bot")
))
//if (false)
{
//add some filter for bots and stuff? if there is such stuff
//so it can be drafted and controlled for fighting
}
else
{
foreach (var x in __result.ToList())
{
try
{
//this may cause error
//ie pawn with shield, or maybe other equipment added gizmos
//maybe because they are not Command?
//w/e just catch error and ignore
//Log.Message("disable_drafter gizmos: " + x);
if ((x as Command).defaultLabel == "Draft")
gizmos.Remove(x);
}
catch
{ }
};
}
}
}
__result = gizmos.AsEnumerable();
}
}
}
|
Mewtopian/rjw
|
Source/Harmony/patch_ui_hero.cs
|
C#
|
mit
| 4,063 |
using System.Collections.Generic;
using System.Linq;
using Harmony;
using RimWorld;
using Verse;
using UnityEngine;
using Multiplayer.API;
namespace rjw
{
/// <summary>
/// Harmony patch to toggle the RJW designation box showing
/// </summary>
[HarmonyPatch(typeof(PlaySettings), "DoPlaySettingsGlobalControls")]
[StaticConstructorOnStartup]
public static class RJW_corner_toggle
{
static readonly Texture2D icon = ContentFinder<Texture2D>.Get("UI/Commands/ComfortPrisoner_off");
[HarmonyPostfix]
public static void adding_RJW_toggle(WidgetRow row, bool worldView)
{
if (worldView) return;
row.ToggleableIcon(ref RJWSettings.show_RJW_designation_box, icon, "RJW_designation_box_desc".Translate());
}
}
///<summary>
///Compact button group containing rjw designations on pawn
///</summary>
[HarmonyPatch(typeof(Pawn), "GetGizmos")]
[StaticConstructorOnStartup]
static class Rjw_buttons
{
[HarmonyPostfix]
static void this_is_postfix(ref IEnumerable<Gizmo> __result, ref Pawn __instance)
{
if (!RJWSettings.show_RJW_designation_box) return;
if (__instance.Faction == null) return;
if (!(__instance.Faction == Faction.OfPlayer || __instance.IsPrisonerOfColony)) return;
//Log.Message("[rjw]Harmony patch submit_button is called");
var pawn = __instance;
var gizmos = __result.ToList();
gizmos.Add(new RJWdesignations(pawn));
__result = gizmos.AsEnumerable();
}
}
///<summary>
///Submit gizmo
///</summary>
[HarmonyPatch(typeof(Pawn), "GetGizmos")]
[StaticConstructorOnStartup]
static class submit_button
{
[HarmonyPostfix]
static void this_is_postfix(ref IEnumerable<Gizmo> __result, ref Pawn __instance)
{
//Log.Message("[rjw]Harmony patch submit_button is called");
var pawn = __instance;
var gizmos = __result.ToList();
var enabled = RJWSettings.submit_button_enabled;
if (enabled && pawn.IsColonistPlayerControlled && pawn.Drafted)
if (pawn.CanChangeDesignationColonist())
if (!(pawn.kindDef.race.defName.Contains("Droid") && !AndroidsCompatibility.IsAndroid(pawn)))
{
gizmos.Add(new Command_Action
{
defaultLabel = "CommandSubmit".Translate(),
icon = submit_icon,
defaultDesc = "CommandSubmitDesc".Translate(),
action = delegate
{
LayDownAndAccept(pawn);
},
hotKey = KeyBindingDefOf.Misc3
});
}
__result = gizmos.AsEnumerable();
}
static Texture2D submit_icon = ContentFinder<Texture2D>.Get("UI/Commands/Submit", true);
static HediffDef submit_hediff = HediffDef.Named("Hediff_Submitting");
[SyncMethod]
static void LayDownAndAccept(Pawn pawn)
{
//Log.Message("Submit button is pressed for " + pawn);
pawn.health.AddHediff(submit_hediff);
}
}
}
|
Mewtopian/rjw
|
Source/Harmony/patch_ui_rjw_buttons.cs
|
C#
|
mit
| 2,764 |
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Verse;
namespace rjw
{
public class HediffCompProperties_SeverityPerDayIfRest : HediffCompProperties
{
public HediffCompProperties_SeverityPerDayIfRest()
{
this.compClass = typeof(HediffComp_SeverityPerDayIfRest);
}
public SimpleCurve severityPerDayByRestDays;
}
class HediffComp_SeverityPerDayIfRest : HediffComp_SeverityPerDay
{
private HediffCompProperties_SeverityPerDayIfRest Props
{
get
{
return (HediffCompProperties_SeverityPerDayIfRest)this.props;
}
}
public override void CompPostTick(ref float severityAdjustment)
{
base.CompPostTick(ref severityAdjustment);
if (base.Pawn.IsHashIntervalTick(SeverityUpdateInterval))
{
float num = this.SeverityChangePerDay();
num *= 0.00333333341f;
severityAdjustment += num;
}
}
protected override float SeverityChangePerDay()
{
return this.Props.severityPerDayByRestDays.Evaluate(this.parent.ageTicks / 60000f);
}
}
public class HediffCompProperties_WhenRapid : HediffCompProperties
{
public HediffCompProperties_WhenRapid()
{
this.compClass = typeof(HediffComp_WhenRapid);
}
public SimpleCurve severityRateByRestDays;
}
class HediffComp_WhenRapid : AdvancedHediffComp
{
private HediffCompProperties_WhenRapid Props
{
get
{
return (HediffCompProperties_WhenRapid)this.props;
}
}
public override void CompPostMerged(Hediff other)
{
other.Severity *= Props.severityRateByRestDays.Evaluate(this.parent.ageTicks / 60000f);
}
}
public class AdvancedHediffWithComps : HediffWithComps
{
public override bool TryMergeWith(Hediff other)
{
for (int i = 0; i < this.comps.Count; i++)
{
if(this.comps[i] is AdvancedHediffComp) ((AdvancedHediffComp)this.comps[i]).CompBeforeMerged(other);
}
return base.TryMergeWith(other);
}
}
public class AdvancedHediffComp : HediffComp
{
public virtual void CompBeforeMerged(Hediff other)
{
}
}
}
|
Mewtopian/rjw
|
Source/Hediffs/HediffComp_SeverityPerDayIfRest.cs
|
C#
|
mit
| 2,023 |
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));
TryHealWounds();
TryFeed();
SetNextTick();
}
}
public void TryHealWounds()
{
IEnumerable<Hediff> enumerable = from hd in pawn.health.hediffSet.hediffs
where !hd.IsTended()
select hd;
if (enumerable != null)
{
foreach (Hediff item in enumerable)
{
HediffWithComps val = item as HediffWithComps;
if (val != null && val.TendableNow())
if (val.Bleeding)
{
//Log.Message("TrySealWounds " + xxx.get_pawnname(pawn) + ", Bleeding " + item.Label);
HediffComp_TendDuration val2 = HediffUtility.TryGetComp<HediffComp_TendDuration>(val);
val2.tendQuality = 2f;
val2.tendTicksLeft = Find.TickManager.TicksGame;
pawn.health.Notify_HediffChanged(item);
}
// infections etc
else// if (val.def.lethalSeverity > 0f)
{
//Log.Message("TryHeal " + xxx.get_pawnname(pawn) + ", infection(?) " + item.Label);
HediffComp_TendDuration val2 = HediffUtility.TryGetComp<HediffComp_TendDuration>(val);
val2.tendQuality = 2f;
val2.tendTicksLeft = Find.TickManager.TicksGame;
pawn.health.Notify_HediffChanged(item);
}
}
}
}
public void TryFeed()
{
Need_Food need = pawn.needs.TryGetNeed<Need_Food>();
if (need == null)
{
return;
}
if (need.CurLevel < 0.10f)
{
//Log.Message("Cocoon::TryFeed() " + xxx.get_pawnname(pawn) + " need to be fed");
float nutrition_amount = need.MaxLevel / 5f;
pawn.needs.food.CurLevel += nutrition_amount;
}
}
public void SetNextTick()
{
//make actual tick every 16.6 sec
tickNext = Find.TickManager.TicksGame + 1000;
//Log.Message("Cocoon::SetNextTick() " + tickNext);
}
}
}
|
Mewtopian/rjw
|
Source/Hediffs/Hediff_Cocoon.cs
|
C#
|
mit
| 2,256 |
using Verse;
namespace rjw
{
public class Hediff_ID : Hediff
{
public override string LabelBase
{
get
{
if (!pawn.health.hediffSet.HasHediff(std.hiv.hediff_def))
return base.LabelBase;
else
return "AIDS";
}
}
}
}
|
Mewtopian/rjw
|
Source/Hediffs/Hediff_ID.cs
|
C#
|
mit
| 252 |
using Verse;
using RimWorld;
using System.Text;
namespace rjw
{
public class HediffDef_PartBase : Hediff_Implant
{
public override void ExposeData()
{
base.ExposeData();
}
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 this.def.label;
}
}
public override string LabelInBrackets
{
get
{
/* penis
string size = "Average";
if (Severity < 0.1f)
size = "Micro";
if (Severity < 0.25f)
size = "Small";
if (Severity > 0.75f)
size = "Big";
if (Severity > 0.9f)
size = "Huge";
return size;
*/
return (this.CurStage != null && !this.CurStage.label.NullOrEmpty()) ? this.CurStage.label : null;
}
}
//stack hediff in health tab
public override int UIGroupKey
{
get
{
if (RJWSettings.StackRjwParts)
//(Label x count)
return this.Label.GetHashCode();
else
//dont
return loadID;
}
}
public override string TipStringExtra
{
get
{
StringBuilder stringBuilder = new StringBuilder();
foreach (StatDrawEntry current in HediffStatsUtility.SpecialDisplayStats(this.CurStage, this))
{
if (current.ShouldDisplay)
{
stringBuilder.AppendLine(current.LabelCap + ": " + current.ValueString);
}
}
//stringBuilder.AppendLine("1");// size?
//stringBuilder.AppendLine("2");// erm something?
return stringBuilder.ToString();
}
}
//do not merge same rjw parts into one
public override bool TryMergeWith(Hediff other)
{
return false;
}
public override bool Visible
{
get
{
//TODO:
//show parts
//show discovered parts(naked, etc)
//dont show parts
return xxx.config.show_regular_dick_and_vag;
}
}
}
}
|
Mewtopian/rjw
|
Source/Hediffs/Hediff_PartBase.cs
|
C#
|
mit
| 2,066 |
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;
}
}
}
}
|
Mewtopian/rjw
|
Source/Hediffs/Hediff_Submitting.cs
|
C#
|
mit
| 364 |
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)
{
//add something fancy here later?
letterText = null;
letterLabel = null;
letterDef = null;
//Find.LetterStack.ReceiveLetter("Rape attempt", "A wandering nymph has decided to join your colony.", LetterDefOf.NegativeEvent, recipient);
if (initiator == null || recipient == null)
return;
//--Log.Message("[RJW] 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)
{
//add something fancy here later?
letterText = null;
letterLabel = null;
letterDef = null;
//Find.LetterStack.ReceiveLetter("Rape attempt", "A wandering nymph has decided to join your colony.", LetterDefOf.NegativeEvent, recipient);
if (initiator == null || recipient == null)
return;
//--Log.Message("[RJW] 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)
{
//add something fancy here later?
letterText = null;
letterLabel = null;
letterDef = null;
//Find.LetterStack.ReceiveLetter("Rape attempt", "A wandering nymph has decided to join your colony.", LetterDefOf.NegativeEvent, recipient);
if (initiator == null || recipient == null)
return;
//--Log.Message("[RJW] InteractionWorker_AnalRapeAttempt::Interacted( " + xxx.get_pawnname(initiator) + ", " + xxx.get_pawnname(recipient) + " ) called");
AttemptAnalSex(initiator, recipient);
}
}
}
|
Mewtopian/rjw
|
Source/Interactions/InteractionWorker_SexAttempt.cs
|
C#
|
mit
| 3,993 |
using System.Collections.Generic;
using RimWorld;
using Verse;
using Verse.AI;
using Multiplayer.API;
namespace rjw
{
public class JobDriver_BestialityForFemale : JobDriver
{
private readonly TargetIndex PartnerInd = TargetIndex.A;
private readonly TargetIndex BedInd = TargetIndex.B;
private readonly TargetIndex SlotInd = TargetIndex.C;
private int ticks_left = 200;
private const int ticks_between_hearts = 100;
public Pawn Actor => GetActor();
public Pawn Partner => (Pawn)(job.GetTarget(PartnerInd));
public Building_Bed Bed => (Building_Bed)(job.GetTarget(BedInd));
public IntVec3 SleepSpot => (IntVec3)job.GetTarget(SlotInd);
public override void ExposeData()
{
base.ExposeData();
Scribe_Values.Look(ref ticks_left, "ticksLeft", 0, false);
}
private 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 pawn.Reserve(Partner, job, 1, 0, null, errorOnFailed);
}
[SyncMethod]
protected override IEnumerable<Toil> MakeNewToils()
{
this.FailOnDespawnedOrNull(PartnerInd);
this.FailOnDespawnedNullOrForbidden(BedInd);
this.FailOn(() => Actor is null || !Actor.CanReserveAndReach(Partner, PathEndMode.Touch, Danger.Deadly));
this.FailOn(() => pawn.Drafted);
yield return Toils_Reserve.Reserve(PartnerInd, 1, 0);
//yield return Toils_Reserve.Reserve(BedInd, Bed.SleepingSlotsCount, 0);
Toil gotoAnimal = Toils_Goto.GotoThing(PartnerInd, PathEndMode.Touch);
yield return gotoAnimal;
bool partnerHasPenis = Genital_Helper.has_penis(Partner) || Genital_Helper.has_penis_infertile(Partner);
Toil gotoBed = new Toil
{
initAction = delegate
{
Actor.pather.StartPath(SleepSpot, PathEndMode.OnCell);
Partner.pather.StartPath(SleepSpot, PathEndMode.OnCell);
},
defaultCompleteMode = ToilCompleteMode.PatherArrival
};
gotoBed.FailOnBedNoLongerUsable(BedInd);
gotoBed.AddFailCondition(() => Partner.Downed);
yield return gotoBed;
gotoBed.AddFinishAction(delegate
{
var gettin_loved = new Job(xxx.gettin_loved, Actor, Bed);
Partner.jobs.StartJob(gettin_loved, JobCondition.InterruptForced, null, false, true, null);
});
Toil waitInBed = new Toil
{
initAction = delegate
{
//Rand.PopState();
//Rand.PushState(RJW_Multiplayer.PredictableSeed());
ticksLeftThisToil = 5000;
ticks_left = (int)(2000.0f * Rand.Range(0.30f, 1.30f));
},
tickAction = delegate
{
Actor.GainComfortFromCellIfPossible();
if (IsInOrByBed(Bed, Partner))
{
ticksLeftThisToil = 0;
}
},
defaultCompleteMode = ToilCompleteMode.Delay,
};
waitInBed.FailOn(() => pawn.GetRoom(RegionType.Set_Passable) == null);
yield return waitInBed;
Toil loveToil = new Toil
{
initAction = delegate
{
if (!partnerHasPenis)
Actor.rotationTracker.Face(Partner.DrawPos);
},
defaultCompleteMode = ToilCompleteMode.Never, //Changed from Delay
};
loveToil.AddPreTickAction(delegate
{
//Actor.Reserve(Partner, 1, 0);
--ticks_left;
xxx.reduce_rest(Actor, 1);
xxx.reduce_rest(Partner, 2);
if (ticks_left <= 0)
ReadyForNextToil();
else if (pawn.IsHashIntervalTick(ticks_between_hearts))
{
MoteMaker.ThrowMetaIcon(Actor.Position, Actor.Map, ThingDefOf.Mote_Heart);
}
Actor.GainComfortFromCellIfPossible();
Partner.GainComfortFromCellIfPossible();
});
loveToil.AddFailCondition(() => Partner.Dead || !IsInOrByBed(Bed, Partner));
loveToil.socialMode = RandomSocialMode.Off;
yield return loveToil;
Toil afterSex = new Toil
{
initAction = delegate
{
//Log.Message("JobDriver_BestialityForFemale::MakeNewToils() - Calling aftersex");
// Trying to add some interactions and social logs
SexUtility.ProcessSex(Partner, pawn);
},
defaultCompleteMode = ToilCompleteMode.Instant
};
yield return afterSex;
}
}
}
|
Mewtopian/rjw
|
Source/JobDrivers/JobDriver_BestialityForFemale.cs
|
C#
|
mit
| 4,156 |
using System.Collections.Generic;
using System.Linq;
using RimWorld;
using Verse;
using Verse.AI;
using Multiplayer.API;
namespace rjw
{
public class JobDriver_BestialityForMale : JobDriver
{
private int duration;
private int ticks_between_hearts;
private int ticks_between_hits = 50;
private int ticks_between_thrusts;
protected TargetIndex target_animal = TargetIndex.A;
protected Pawn animal => (Pawn)(job.GetTarget(target_animal));
public override bool TryMakePreToilReservations(bool errorOnFailed)
{
return pawn.Reserve(animal, job, 1, 0, null, errorOnFailed);
}
[SyncMethod]
protected override IEnumerable<Toil> MakeNewToils()
{
//--Log.Message("[RJW] JobDriver_BestialityForMale::MakeNewToils() called");
//Rand.PopState();
//Rand.PushState(RJW_Multiplayer.PredictableSeed());
duration = (int)(2500.0f * Rand.Range(0.50f, 0.90f));
ticks_between_hearts = Rand.RangeInclusive(70, 130);
ticks_between_hits = Rand.Range(xxx.config.min_ticks_between_hits, xxx.config.max_ticks_between_hits);
ticks_between_thrusts = 100;
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);
//this.FailOn (() => (!animal.health.capacities.CanBeAwake) || (!comfort_prisoners.is_designated (animal)));
// Fail if someone else reserves the prisoner before the pawn arrives or colonist can't reach animal
this.FailOn(() => !pawn.CanReserveAndReach(animal, PathEndMode.Touch, Danger.Deadly));
this.FailOn(() => animal.HostileTo(pawn));
this.FailOnDespawnedNullOrForbidden(target_animal);
this.FailOn(() => pawn.Drafted);
yield return Toils_Reserve.Reserve(target_animal, 1, 0);
//Log.Message("[RJW] JobDriver_BestialityForMale::MakeNewToils() - moving towards animal");
yield return Toils_Goto.GotoThing(target_animal, PathEndMode.Touch);
yield return Toils_Interpersonal.WaitToBeAbleToInteract(pawn);
yield return Toils_Interpersonal.GotoInteractablePosition(target_animal);
if (xxx.is_kind(pawn)
|| (xxx.CTIsActive && xxx.has_traits(pawn) && pawn.story.traits.HasTrait(TraitDef.Named("RCT_AnimalLover"))))
{
yield return TalkToAnimal(pawn, animal);
yield return TalkToAnimal(pawn, animal);
}
if (Rand.Chance(0.6f))
yield return TalkToAnimal(pawn, animal);
yield return Toils_Goto.GotoThing(target_animal, PathEndMode.OnCell);
SexUtility.RapeAttemptAlert(pawn, animal);
Toil rape = new Toil();
rape.initAction = delegate
{
//--Log.Message("[RJW] JobDriver_BestialityForMale::MakeNewToils() - reserving animal");
//--Log.Message("[RJW] JobDriver_BestialityForMale::MakeNewToils() - Setting animal job driver");
if (!(animal.jobs.curDriver is JobDriver_GettinRaped dri))
{
//wild animals may flee or attack
if (pawn.Faction != animal.Faction && animal.RaceProps.wildness > Rand.Range(0.22f, 1.0f)
&& !(pawn.TicksPerMoveCardinal < (animal.TicksPerMoveCardinal / 2) && !animal.Downed && xxx.is_not_dying(animal)))
{
animal.jobs.StopAll(); // Wake up if sleeping.
float aggro = animal.kindDef.RaceProps.manhunterOnTameFailChance;
if (animal.kindDef.RaceProps.predator)
aggro += 0.2f;
else
aggro -= 0.1f;
if (Rand.Chance(aggro) && animal.CanSee(pawn))
{
animal.rotationTracker.FaceTarget(pawn);
LifeStageUtility.PlayNearestLifestageSound(animal, (ls) => ls.soundAngry, 1.4f);
MoteMaker.ThrowMetaIcon(animal.Position, animal.Map, ThingDefOf.Mote_IncapIcon);
MoteMaker.ThrowMetaIcon(pawn.Position, pawn.Map, ThingDefOf.Mote_ColonistFleeing); //red '!'
animal.mindState.mentalStateHandler.TryStartMentalState(MentalStateDefOf.Manhunter);
if (animal.kindDef.RaceProps.herdAnimal && Rand.Chance(0.2f))
{ // 20% chance of turning the whole herd hostile...
List<Pawn> packmates = animal.Map.mapPawns.AllPawnsSpawned.Where(x =>
x != animal && x.def == animal.def && x.Faction == animal.Faction &&
x.Position.InHorDistOf(animal.Position, 24f) && x.CanSee(animal)).ToList();
foreach (Pawn packmate in packmates)
{
packmate.mindState.mentalStateHandler.TryStartMentalState(MentalStateDefOf.Manhunter);
}
}
Messages.Message(pawn.Name.ToStringShort + " is being attacked by " + xxx.get_pawnname(animal) + ".", pawn, MessageTypeDefOf.ThreatSmall);
}
else
{
MoteMaker.ThrowMetaIcon(animal.Position, animal.Map, ThingDefOf.Mote_ColonistFleeing);
LifeStageUtility.PlayNearestLifestageSound(animal, (ls) => ls.soundCall);
animal.mindState.StartFleeingBecauseOfPawnAction(pawn);
animal.mindState.mentalStateHandler.TryStartMentalState(DefDatabase<MentalStateDef>.GetNamed("PanicFlee"));
}
pawn.jobs.EndCurrentJob(JobCondition.Incompletable);
}
else
{
Job gettin_bred = new Job(xxx.gettin_bred, pawn, animal);
animal.jobs.StartJob(gettin_bred, JobCondition.InterruptForced, null, true);
(animal.jobs.curDriver as JobDriver_GettinRaped)?.increase_time(duration);
}
}
else
{
dri.rapist_count += 1;
dri.increase_time(duration);
}
};
rape.tickAction = delegate
{
if (pawn.IsHashIntervalTick(ticks_between_hearts))
MoteMaker.ThrowMetaIcon(pawn.Position, pawn.Map, ThingDefOf.Mote_Heart);
if (pawn.IsHashIntervalTick(ticks_between_thrusts))
xxx.sexTick(pawn, animal, false);
/*
if (pawn.IsHashIntervalTick (ticks_between_hits))
roll_to_hit (pawn, animal);
*/
xxx.reduce_rest(animal, 1);
xxx.reduce_rest(pawn, 2);
};
rape.AddFinishAction(delegate
{
//--Log.Message("[RJW] JobDriver_BestialityForMale::MakeNewToils() - finished violating");
if (animal.jobs?.curDriver is JobDriver_GettinRaped)
(animal.jobs.curDriver as JobDriver_GettinRaped).rapist_count -= 1;
if (xxx.is_human(pawn))
pawn.Drawer.renderer.graphics.ResolveApparelGraphics();
});
rape.defaultCompleteMode = ToilCompleteMode.Delay;
rape.defaultDuration = duration;
yield return rape;
yield return new Toil
{
initAction = delegate
{
//Log.Message("[RJW] JobDriver_BestialityForMale::MakeNewToils() - creating aftersex toil");
SexUtility.ProcessSex(pawn, animal);
},
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;
}
}
}
|
Mewtopian/rjw
|
Source/JobDrivers/JobDriver_BestialityForMale.cs
|
C#
|
mit
| 6,877 |
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
{
protected TargetIndex PartnerIndex = TargetIndex.A;
public Pawn Target => (Pawn)(job.GetTarget(PartnerIndex));
public override bool TryMakePreToilReservations(bool errorOnFailed)
{
return pawn.Reserve(Target, job, BreederHelper.max_animals_at_once, 0);
}
[SyncMethod]
public virtual void roll_to_hit(Pawn pawn, Pawn partner)
{
if (!RJWSettings.rape_beating || !xxx.is_human(pawn))
return;
//Rand.PopState();
//Rand.PushState(RJW_Multiplayer.PredictableSeed());
float rand_value = Rand.Value;
float victim_pain = partner.health.hediffSet.PainTotal;
float chance_to_hit = xxx.config.base_chance_to_hit_prisoner/5;
float threshold = xxx.config.minor_pain_threshold;
if ((victim_pain < threshold && rand_value < chance_to_hit))
{
if (InteractionUtility.TryGetRandomVerbForSocialFight(pawn, out Verb v))
pawn.meleeVerbs.TryMeleeAttack(partner, v);
}
}
[SyncMethod]
protected override IEnumerable<Toil> MakeNewToils()
{
//Rand.PopState();
//Rand.PushState(RJW_Multiplayer.PredictableSeed());
int duration = (int)(2000.0f * Rand.Range(0.50f, 0.90f));
int ticks_between_hearts = Rand.RangeInclusive(70, 130);
int ticks_between_hits = Rand.Range(xxx.config.min_ticks_between_hits, xxx.config.max_ticks_between_hits);
int ticks_between_thrusts = 100;
//--Log.Message("JobDriver_ComfortPrisonerRapin::MakeNewToils() - setting fail conditions");
this.FailOnDespawnedNullOrForbidden(PartnerIndex);
this.FailOn(() => !pawn.CanReserve(Target, BreederHelper.max_animals_at_once, 0)); // Fail if someone else reserves the target before the animal arrives.
this.FailOn(() => !pawn.CanReach(Target, PathEndMode.Touch, Danger.Some)); // Fail if animal cannot reach target.
this.FailOn(() => !(Target.IsDesignatedBreeding() || (RJWSettings.animal_on_animal_enabled && xxx.is_animal(Target)))); // Fail if not designated and not animal-on-animal
this.FailOn(() => Target.CurJob == null);
this.FailOn(() => pawn.Drafted);
// Path to target
yield return Toils_Goto.GotoThing(PartnerIndex, PathEndMode.OnCell);
SexUtility.RapeAttemptAlert(pawn, Target);
// Breed target
var breed = new Toil();
breed.initAction = delegate
{
//Log.Message("JobDriver_ComfortPrisonerRapin::MakeNewToils() - Setting victim job driver");
Job currentJob = Target.jobs.curJob;
if (currentJob.def != xxx.gettin_raped)
{
Job gettin_raped = new Job(xxx.gettin_raped, pawn, Target);
Building_Bed Bed = null;
//Log.Message(xxx.get_pawnname(pawn) + " LayingInBed:" + pawn.GetPosture());
//Log.Message(xxx.get_pawnname(Target) + " LayingInBed:" + Target.GetPosture());
if (Target.GetPosture() == PawnPosture.LayingInBed)
{
Bed = Target.CurrentBed();
//Log.Message(xxx.get_pawnname(Target) + ": bed:" + Bed);
}
Target.jobs.StartJob(gettin_raped, JobCondition.InterruptForced);
//var dri = Target.jobs.curDriver as JobDriver_GettinRaped;
//if (xxx.is_animal(pawn) && xxx.is_animal(Target)) // No alert spam for animal-on-animal
//dri.disable_alert = true;
(Target.jobs.curDriver as JobDriver_GettinRaped).increase_time(duration);
if (Bed != null)
(Target.jobs.curDriver as JobDriver_GettinRaped)?.set_bed(Bed);
}
else
{
if (Target.jobs.curDriver is JobDriver_GettinRaped dri)
{
dri.rapist_count += 1;
dri.increase_time(duration);
}
}
};
breed.tickAction = delegate
{
if (pawn.IsHashIntervalTick(ticks_between_hearts))
MoteMaker.ThrowMetaIcon(pawn.Position, pawn.Map, ThingDefOf.Mote_Heart);
if (pawn.IsHashIntervalTick(ticks_between_thrusts))
xxx.sexTick(pawn, Target);
if (!xxx.is_zoophile(Target) && pawn.IsHashIntervalTick(ticks_between_hits))
roll_to_hit(pawn, Target);
if (!Target.Dead)
xxx.reduce_rest(Target, 1);
xxx.reduce_rest(pawn, 2);
if (Genital_Helper.has_penis(pawn) || Genital_Helper.has_penis_infertile(pawn))
{
// Face same direction, most of animal sex is likely doggystyle.
Target.Rotation = pawn.Rotation;
}
};
breed.AddFinishAction(delegate
{
if ((Target.jobs != null)
&& (Target.jobs.curDriver != null)
&& (Target.jobs.curDriver as JobDriver_GettinRaped != null))
{
(Target.jobs.curDriver as JobDriver_GettinRaped).rapist_count -= 1;
}
pawn.stances.StaggerFor(Rand.Range(0,50));
Target.stances.StaggerFor(Rand.Range(10,300));
});
breed.defaultCompleteMode = ToilCompleteMode.Delay;
breed.defaultDuration = duration;
yield return breed;
yield return new Toil
{
initAction = delegate
{
//Log.Message("JobDriver_Breeding::MakeNewToils() - Calling aftersex");
//// Trying to add some interactions and social logs
bool violent = !(pawn.relations.DirectRelationExists(PawnRelationDefOf.Bond, Target) ||
(xxx.is_animal(pawn) && (pawn.RaceProps.wildness - pawn.RaceProps.petness + 0.18f) > Rand.Range(0.36f, 1.8f)));
SexUtility.ProcessSex(pawn, Target, violent);
},
defaultCompleteMode = ToilCompleteMode.Instant
};
}
}
}
|
Mewtopian/rjw
|
Source/JobDrivers/JobDriver_Breeding.cs
|
C#
|
mit
| 5,421 |
using System.Collections.Generic;
using RimWorld;
using Verse;
using Verse.AI;
using Multiplayer.API;
namespace rjw
{
public class JobDriver_Fappin : JobDriver
{
private const int ticks_between_hearts = 100;
private int ticks_left;
private readonly TargetIndex ibed = TargetIndex.A;
private Building_Bed Bed => (Building_Bed)((Thing)job.GetTarget(ibed));
public override bool TryMakePreToilReservations(bool errorOnFailed)
{
return pawn.Reserve(Bed, job, Bed.SleepingSlotsCount, 0, null, errorOnFailed);
}
[SyncMethod]
protected override IEnumerable<Toil> MakeNewToils()
{
// Faster fapping when frustrated.
//Rand.PopState();
//Rand.PushState(RJW_Multiplayer.PredictableSeed());
ticks_left = (int)(xxx.need_some_sex(pawn) > 2f ? 2500.0f * Rand.Range(0.2f, 0.7f) : 2500.0f * Rand.Range(0.2f, 0.4f));
this.FailOnDespawnedOrNull(ibed);
this.FailOn(() => pawn.Drafted);
this.KeepLyingDown(ibed);
yield return Toils_Bed.ClaimBedIfNonMedical(ibed);
yield return Toils_Bed.GotoBed(ibed);
Toil do_fappin = Toils_LayDown.LayDown(ibed, true, false, false, false);
do_fappin.AddPreTickAction(delegate
{
--ticks_left;
xxx.reduce_rest(pawn, 1);
if (ticks_left <= 0)
ReadyForNextToil();
else if (pawn.IsHashIntervalTick(ticks_between_hearts))
MoteMaker.ThrowMetaIcon(pawn.Position, pawn.Map, ThingDefOf.Mote_Heart);
});
do_fappin.AddFinishAction(delegate
{
//Moved satisfy and tick increase to aftersex, since it works with solo acts now.
SexUtility.Aftersex(pawn, xxx.rjwSextype.Masturbation);
if (SexUtility.ConsiderCleaning(pawn))
{
LocalTargetInfo own_cum = pawn.PositionHeld.GetFirstThing<Filth>(pawn.Map);
Job clean = new Job(JobDefOf.Clean);
clean.AddQueuedTarget(TargetIndex.A, own_cum);
pawn.jobs.jobQueue.EnqueueFirst(clean);
}
});
do_fappin.socialMode = RandomSocialMode.Off;
yield return do_fappin;
}
}
}
|
Mewtopian/rjw
|
Source/JobDrivers/JobDriver_Fappin.cs
|
C#
|
mit
| 1,964 |
using System.Collections.Generic;
using RimWorld;
using Verse;
using Verse.AI;
namespace rjw
{
public class JobDriver_GettinLoved : JobDriver
{
private TargetIndex ipartner = TargetIndex.A;
private TargetIndex ibed = TargetIndex.B;
private int tick_interval = 100;
protected Pawn Partner => (Pawn)(job.GetTarget(ipartner));
protected Building_Bed Bed => (Building_Bed)(job.GetTarget(ibed));
public override bool TryMakePreToilReservations(bool errorOnFailed)
{
return true;
//return this.pawn.Reserve(this.Partner, this.job, 1, 0, null) && this.pawn.Reserve(this.Bed, this.job, 1, 0, null);
}
public float CalculateSatisfactionPerTick()
{
return 1.0f;
}
protected override IEnumerable<Toil> MakeNewToils()
{
//--Log.Message("[RJW]JobDriver_GettinLoved::MakeNewToils is called");
float partner_ability = xxx.get_sex_ability(Partner);
// More/less hearts based on partner ability.
if (partner_ability < 0.8f)
tick_interval += 100;
else if (partner_ability > 2.0f)
tick_interval -= 25;
// More/less hearts based on opinion.
if (pawn.relations.OpinionOf(Partner) < 0)
tick_interval += 50;
else if (pawn.relations.OpinionOf(Partner) > 60)
tick_interval -= 25;
if (Partner.CurJob.def == xxx.casual_sex)
{
this.FailOnDespawnedOrNull(ipartner);
this.FailOn(() => !Partner.health.capacities.CanBeAwake);
this.FailOn(() => pawn.Drafted);
this.KeepLyingDown(ibed);
yield return Toils_Reserve.Reserve(ipartner, 1, 0);
yield return Toils_Reserve.Reserve(ibed, Bed.SleepingSlotsCount, 0);
Toil get_loved = Toils_LayDown.LayDown(ibed, true, false, false, false);
get_loved.FailOn(() => Partner.CurJob == null || Partner.CurJob.def != xxx.casual_sex);
get_loved.defaultCompleteMode = ToilCompleteMode.Never;
get_loved.AddPreTickAction(delegate
{
if (pawn.IsHashIntervalTick(tick_interval))
{
MoteMaker.ThrowMetaIcon(pawn.Position, pawn.Map, ThingDefOf.Mote_Heart);
xxx.sexTick(pawn, Partner);
}
});
get_loved.socialMode = RandomSocialMode.Off;
yield return get_loved;
}
else if (Partner.CurJob.def == xxx.whore_is_serving_visitors)
{
this.FailOnDespawnedOrNull(ipartner);
this.FailOn(() => !Partner.health.capacities.CanBeAwake || Partner.CurJob == null);
yield return Toils_Goto.GotoThing(ipartner, PathEndMode.OnCell);
yield return Toils_Reserve.Reserve(ipartner, 1, 0);
Toil get_loved = new Toil();
get_loved.FailOn(() => (Partner.CurJob.def != xxx.whore_is_serving_visitors));
get_loved.defaultCompleteMode = ToilCompleteMode.Never;
get_loved.initAction = delegate
{
//--Log.Message("[RJW]JobDriver_GettinLoved::MakeNewToils - whore section is called");
};
get_loved.AddPreTickAction(delegate
{
if (pawn.IsHashIntervalTick(tick_interval))
{
MoteMaker.ThrowMetaIcon(pawn.Position, pawn.Map, ThingDefOf.Mote_Heart);
xxx.sexTick(pawn, Partner);
}
});
get_loved.socialMode = RandomSocialMode.Off;
yield return get_loved;
}
else if (Partner.CurJob.def == xxx.bestialityForFemale)
{
this.FailOnDespawnedOrNull(ipartner);
this.FailOn(() => !Partner.health.capacities.CanBeAwake || Partner.CurJob == null);
yield return Toils_Goto.GotoThing(ipartner, PathEndMode.OnCell);
yield return Toils_Reserve.Reserve(ipartner, 1, 0);
Toil get_loved = new Toil();
get_loved.FailOn(() => (Partner.CurJob.def != xxx.bestialityForFemale));
get_loved.defaultCompleteMode = ToilCompleteMode.Never;
get_loved.initAction = delegate
{
//--Log.Message("[RJW]JobDriver_GettinLoved::MakeNewToils - bestialityForFemale section is called");
};
get_loved.AddPreTickAction(delegate
{
if (pawn.IsHashIntervalTick(tick_interval))
{
MoteMaker.ThrowMetaIcon(pawn.Position, pawn.Map, ThingDefOf.Mote_Heart);
xxx.sexTick(pawn, Partner);
}
});
get_loved.socialMode = RandomSocialMode.Off;
yield return get_loved;
}
}
}
}
|
Mewtopian/rjw
|
Source/JobDrivers/JobDriver_GettinLoved.cs
|
C#
|
mit
| 4,051 |
using System;
using System.Collections.Generic;
using System.Linq;
using RimWorld;
using Verse;
using Verse.AI;
namespace rjw
{
public class JobDriver_GettinRaped : JobDriver
{
private int ticks_between_hearts;
private int ticks_remaining = 10;
public int rapist_count = 1; // Defaults to 1 so the first rapist doesn't have to add themself
private Pawn Initiator => (Pawn)(job.GetTarget(TargetIndex.A));
private Pawn Receiver => (Pawn)(job.GetTarget(TargetIndex.B));
//private bool was_laying_down;
private Building_Bed Bed;
public void increase_time(int min_ticks_remaining)
{
if (min_ticks_remaining > ticks_remaining)
ticks_remaining = min_ticks_remaining;
}
public void set_bed(Building_Bed newBed)
{
Bed = newBed;
}
public override bool TryMakePreToilReservations(bool errorOnFailed)
{
return true;
}
private void RapeAlert(bool silent = false)
{
if (!silent)
Messages.Message(xxx.get_pawnname(Receiver) + " is getting raped.", Receiver, MessageTypeDefOf.NegativeEvent);
else
Messages.Message(xxx.get_pawnname(Receiver) + " is getting raped.", Receiver, MessageTypeDefOf.SilentInput);
}
public float CalculateSatisfactionPerTick()
{
return 1.0f;
}
protected override IEnumerable<Toil> MakeNewToils()
{
//Rand.PopState();
//Rand.PushState(RJW_Multiplayer.PredictableSeed());
ticks_between_hearts = Rand.RangeInclusive(70, 130);
//was_laying_down = pawn.GetPosture() != PawnPosture.Standing;
//Log.Message(xxx.get_pawnname(Initiator) + ": was_laying_down:" + was_laying_down + " LayingInBed:" + Initiator.GetPosture());
//Log.Message(xxx.get_pawnname(Receiver) + ": was_laying_down:" + was_laying_down + " LayingInBed:" + Receiver.GetPosture());
//was_laying_down = (pawn.jobs.curDriver != null) && pawn.GetPosture() != PawnPosture.Standing;
//Log.Message(xxx.get_pawnname(pawn) + ": bed:" + Bed);
var get_raped = new Toil();
get_raped.defaultCompleteMode = ToilCompleteMode.Never;
get_raped.initAction = delegate
{
pawn.pather.StopDead();
//pawn.jobs.posture = PawnPosture.Standing;
pawn.jobs.curDriver.asleep = false;
switch (RJWPreferenceSettings.rape_alert_sound)
{
case RJWPreferenceSettings.RapeAlert.Enabled:
RapeAlert();
break;
case RJWPreferenceSettings.RapeAlert.Humanlikes:
if (xxx.is_human(Receiver))
RapeAlert();
else
RapeAlert(true);
break;
case RJWPreferenceSettings.RapeAlert.Colonists:
if (Receiver.Faction == Faction.OfPlayer)
RapeAlert();
else
RapeAlert(true);
break;
default:
RapeAlert(true);
break;
}
//Messages.Message("GetinRapedNow".Translate(new object[] { pawn.LabelIndefinite() }).CapitalizeFirst(), pawn, MessageTypeDefOf.NegativeEvent);
if (Initiator == null || Receiver == null) return;
bool partnerHasHands = Receiver.health.hediffSet.GetNotMissingParts().Any(part => part.IsInGroup(BodyPartGroupDefOf.RightHand) || part.IsInGroup(BodyPartGroupDefOf.LeftHand));
// Hand check is for monstergirls and other bipedal 'animals'.
if ((!xxx.is_animal(Initiator) && partnerHasHands) || Rand.Chance(0.3f)) // 30% chance of face-to-face regardless, for variety.
{ // Face-to-face
Initiator.rotationTracker.Face(Receiver.DrawPos);
Receiver.rotationTracker.Face(Initiator.DrawPos);
}
else
{ // From behind / animal stuff should mostly use this
Initiator.rotationTracker.Face(Receiver.DrawPos);
Receiver.Rotation = Initiator.Rotation;
}
// TODO: The above works, but something is forcing the partners to face each other during sex. Need to figure it out.
//prevent Receiver standing up and interrupting rape, probably
if (Receiver.health.hediffSet.HasHediff(HediffDef.Named("Hediff_Submitting")))
Receiver.health.AddHediff(HediffDef.Named("Hediff_Submitting"));
};
get_raped.tickAction = delegate
{
--ticks_remaining;
/*
if ((ticks_remaining <= 0) || (rapist_count <= 0))
ReadyForNextToil();
*/
if ((rapist_count > 0) && (pawn.IsHashIntervalTick(ticks_between_hearts / rapist_count)))
MoteMaker.ThrowMetaIcon(pawn.Position, pawn.Map, xxx.mote_noheart);
};
get_raped.AddEndCondition(new Func<JobCondition>(() =>
{
if ((ticks_remaining <= 0) || (rapist_count <= 0))
return JobCondition.Succeeded;
return JobCondition.Ongoing;
}));
get_raped.AddFinishAction(delegate
{
if (Bed != null && pawn.Downed)
{
Job tobed = new Job(JobDefOf.Rescue, pawn, Bed);
tobed.count = 1;
Initiator.jobs.jobQueue.EnqueueFirst(tobed);
//Log.Message(xxx.get_pawnname(Initiator) + ": job tobed:" + tobed);
}
});
get_raped.socialMode = RandomSocialMode.Off;
yield return get_raped;
}
}
}
|
Mewtopian/rjw
|
Source/JobDrivers/JobDriver_GettinRaped.cs
|
C#
|
mit
| 4,840 |
using System.Collections.Generic;
using RimWorld;
using Verse;
using Verse.AI;
using Multiplayer.API;
namespace rjw
{
public class JobDriver_JoinInBed : JobDriver
{
private const int ticks_between_hearts = 100;
private int ticks_left;
private readonly TargetIndex ipawn = TargetIndex.A;
private readonly TargetIndex ipartner = TargetIndex.B;
private readonly TargetIndex ibed = TargetIndex.C;
protected Pawn Top => (Pawn)(job.GetTarget(ipawn));
protected Pawn Partner => (Pawn)(job.GetTarget(ipartner));
protected Building_Bed Bed => (Building_Bed)(job.GetTarget(ibed));
public override bool TryMakePreToilReservations(bool errorOnFailed)
{
return Top.Reserve(Partner, job, xxx.max_rapists_per_prisoner, 0, null, errorOnFailed);
}
[SyncMethod]
protected override IEnumerable<Toil> MakeNewToils()
{
//--Log.Message("JobDriver_JoinInBed::MakeNewToils() called");
this.FailOnDespawnedOrNull(ipartner);
this.FailOnDespawnedOrNull(ibed);
this.FailOn(() => !Partner.health.capacities.CanBeAwake);
this.FailOn(() => !(Partner.InBed() || xxx.in_same_bed(Partner, Top)));
this.FailOn(() => pawn.Drafted);
yield return Toils_Reserve.Reserve(ipartner, xxx.max_rapists_per_prisoner, 0);
yield return Toils_Goto.GotoThing(ipartner, PathEndMode.OnCell);
yield return new Toil
{
initAction = delegate
{
//--Log.Message("JobDriver_JoinInBed::MakeNewToils() - setting initAction");
//Rand.PopState();
//Rand.PushState(RJW_Multiplayer.PredictableSeed());
ticks_left = (int)(2500.0f * Rand.Range(0.30f, 1.30f));
Job gettin_loved = new Job(xxx.gettin_loved, Top, Bed);
Partner.jobs.StartJob(gettin_loved, JobCondition.InterruptForced);
},
defaultCompleteMode = ToilCompleteMode.Instant
};
Toil do_lovin = new Toil {defaultCompleteMode = ToilCompleteMode.Never};
do_lovin.FailOn(() => (Partner.CurJob == null) || (Partner.CurJob.def != xxx.gettin_loved));
do_lovin.AddPreTickAction(delegate
{
--ticks_left;
xxx.reduce_rest(Partner, 1);
xxx.reduce_rest(Top, 2);
if (ticks_left <= 0)
ReadyForNextToil();
else if (Top.IsHashIntervalTick(ticks_between_hearts))
MoteMaker.ThrowMetaIcon(Top.Position, Top.Map, ThingDefOf.Mote_Heart);
});
do_lovin.socialMode = RandomSocialMode.Off;
yield return do_lovin;
yield return new Toil
{
initAction = delegate
{
// Trying to add some interactions and social logs
SexUtility.ProcessSex(Top, Partner, false /*rape*/, false/*isCoreLovin*/, false /*whoring*/);
},
defaultCompleteMode = ToilCompleteMode.Instant
};
}
}
}
|
Mewtopian/rjw
|
Source/JobDrivers/JobDriver_JoinInBed.cs
|
C#
|
mit
| 2,636 |
using System;
using System.Collections.Generic;
using RimWorld;
using Verse;
using Verse.AI;
using Multiplayer.API;
namespace rjw
{
public class JobDriver_PrisonerComfortRapin : JobDriver
{
protected int duration;
protected int ticks_between_hearts;
protected int ticks_between_hits = 50;
protected int ticks_between_thrusts;
protected TargetIndex iprisoner = TargetIndex.A;
protected virtual float chance_to_hit_prisoner => xxx.config.base_chance_to_hit_prisoner;
protected Pawn Target => (Pawn)(job.GetTarget(iprisoner));
public override bool TryMakePreToilReservations(bool errorOnFailed)
{
return pawn.Reserve(Target, job, xxx.max_rapists_per_prisoner, 0, null, errorOnFailed);
}
[SyncMethod]
public virtual void roll_to_hit(Pawn rapist, Pawn p)
{
if (!RJWSettings.rape_beating)
{
return;
}
//Rand.PopState();
//Rand.PushState(RJW_Multiplayer.PredictableSeed());
float rand_value = Rand.Value;
float victim_pain = p.health.hediffSet.PainTotal;
// bloodlust makes the aggressor more likely to hit the prisoner
float beating_chance = chance_to_hit_prisoner * (xxx.is_bloodlust(rapist) ? 1.25f : 1.0f);
// psychopath makes the aggressor more likely to hit the prisoner past the significant_pain_threshold
float beating_threshold = xxx.is_psychopath(rapist) ? xxx.config.extreme_pain_threshold : xxx.config.significant_pain_threshold;
//--Log.Message("roll_to_hit: rand = " + rand_value + ", beating_chance = " + beating_chance + ", victim_pain = " + victim_pain + ", beating_threshold = " + beating_threshold);
//if ((victim_pain < beating_threshold && rand_value < beating_chance) || (rand_value < (beating_chance / 2)))
if ((victim_pain < beating_threshold && rand_value < beating_chance) || (rand_value < (beating_chance / 2) && xxx.is_bloodlust(rapist)))
{
//--Log.Message(" done told her twice already...");
if (InteractionUtility.TryGetRandomVerbForSocialFight(rapist, out Verb v))
{
rapist.meleeVerbs.TryMeleeAttack(p, v);
}
}
/*
//if (p.health.hediffSet.PainTotal < xxx.config.significant_pain_threshold)
if ((Rand.Value < 0.50f) &&
((Rand.Value < 0.33f) || (p.health.hediffSet.PainTotal < xxx.config.significant_pain_threshold) ||
(xxx.is_bloodlust (rapist) || xxx.is_psychopath (rapist)))) {
Verb v;
if (InteractionUtility.TryGetRandomVerbForSocialFight (rapist, out v))
rapist.meleeVerbs.TryMeleeAttack (p, v);
}
*/
}
[SyncMethod]
protected override IEnumerable<Toil> MakeNewToils()
{
//Rand.PopState();
//Rand.PushState(RJW_Multiplayer.PredictableSeed());
duration = (int)(2000.0f * Rand.Range(0.50f, 0.90f));
ticks_between_hearts = Rand.RangeInclusive(70, 130);
ticks_between_hits = Rand.Range(xxx.config.min_ticks_between_hits, xxx.config.max_ticks_between_hits);
ticks_between_thrusts = 100;
bool pawnHasPenis = Genital_Helper.has_penis(pawn) || Genital_Helper.has_penis_infertile(pawn);
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);
//--Log.Message("JobDriver_ComfortPrisonerRapin::MakeNewToils() - setting fail conditions");
this.FailOnDespawnedNullOrForbidden(iprisoner);
//this.FailOn(() => (!Target.health.capacities.CanBeAwake) || (!comfort_prisoners.is_designated(Target)));//this is wrong
this.FailOn(() => (!Target.IsDesignatedComfort()));
this.FailOn(() => !pawn.CanReserve(Target, 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(iprisoner, PathEndMode.OnCell);
SexUtility.RapeAttemptAlert(pawn, Target);
Toil rape = new Toil();
rape.initAction = delegate
{
//--Log.Message("JobDriver_ComfortPrisonerRapin::MakeNewToils() - reserving prisoner");
//pawn.Reserve(Target, comfort_prisoners.max_rapists_per_prisoner, 0);
if (!pawnHasPenis)
Target.rotationTracker.Face(pawn.DrawPos);
//--Log.Message("JobDriver_ComfortPrisonerRapin::MakeNewToils() - Setting victim job driver");
JobDriver_GettinRaped dri = Target.jobs.curDriver as JobDriver_GettinRaped;
if (dri == null)
{
Job gettin_raped = new Job(xxx.gettin_raped, pawn, Target);
Building_Bed Bed = null;
//Log.Message(xxx.get_pawnname(pawn) + " LayingInBed:" + pawn.GetPosture());
//Log.Message(xxx.get_pawnname(Target) + " LayingInBed:" + Target.GetPosture());
if (Target.GetPosture() == PawnPosture.LayingInBed)
{
Bed = Target.CurrentBed();
//Log.Message(xxx.get_pawnname(Target) + ": bed:" + Bed);
}
Target.jobs.StartJob(gettin_raped, JobCondition.InterruptForced, null, false, true, null);
(Target.jobs.curDriver as JobDriver_GettinRaped)?.increase_time(duration);
if (Bed != null)
(Target.jobs.curDriver as JobDriver_GettinRaped)?.set_bed(Bed);
}
else
{
dri.rapist_count += 1;
dri.increase_time(duration);
}
};
rape.tickAction = delegate
{
if (pawn.IsHashIntervalTick(ticks_between_hearts))
MoteMaker.ThrowMetaIcon(pawn.Position, pawn.Map, ThingDefOf.Mote_Heart);
if (pawn.IsHashIntervalTick(ticks_between_thrusts))
xxx.sexTick(pawn, Target);
if (pawn.IsHashIntervalTick(ticks_between_hits))
roll_to_hit(pawn, Target);
xxx.reduce_rest(Target, 1);
xxx.reduce_rest(pawn, 2);
};
rape.AddFinishAction(delegate
{
//Log.Message("JobDriver_ComfortPrisonerRapin::MakeNewToils() - Clearing victim job");
if (Target.jobs?.curDriver is JobDriver_GettinRaped)
{
//Log.Message("JobDriver_ComfortPrisonerRapin::MakeNewToils() - Victim present");
(Target.jobs.curDriver as JobDriver_GettinRaped).rapist_count -= 1;
}
});
rape.defaultCompleteMode = ToilCompleteMode.Delay;
rape.defaultDuration = duration;
yield return rape;
yield return new Toil
{
initAction = delegate
{
// Trying to add some interactions and social logs
SexUtility.ProcessSex(pawn, Target, true);
Target.records.Increment(xxx.GetRapedAsComfortPrisoner);
},
defaultCompleteMode = ToilCompleteMode.Instant
};
}
}
}
|
Mewtopian/rjw
|
Source/JobDrivers/JobDriver_PrisonerComfortRapin.cs
|
C#
|
mit
| 6,288 |
using System.Collections.Generic;
using RimWorld;
using Verse;
using Verse.AI;
using Multiplayer.API;
namespace rjw
{
public class JobDriver_QuickFap : JobDriver
{
private const int ticks_between_hearts = 100;
private int ticks_left;
public IntVec3 cell => (IntVec3)job.GetTarget(TargetIndex.A);
public override bool TryMakePreToilReservations(bool errorOnFailed)
{
return true; // No reservations needed.
}
[SyncMethod]
protected override IEnumerable<Toil> MakeNewToils()
{
//this.FailOn(() => PawnUtility.PlayerForcedJobNowOrSoon(pawn));
this.FailOn(() => pawn.health.Downed);
this.FailOn(() => pawn.IsBurning());
this.FailOn(() => pawn.IsFighting());
this.FailOn(() => pawn.Drafted);
//Rand.PopState();
//Rand.PushState(RJW_Multiplayer.PredictableSeed());
// Faster fapping when frustrated.
ticks_left = (int)(xxx.need_some_sex(pawn) > 2f ? 2500.0f * Rand.Range(0.2f, 0.7f) : 2500.0f * Rand.Range(0.2f, 0.4f));
Toil findfapspot = new Toil
{
initAction = delegate
{
pawn.pather.StartPath(cell, PathEndMode.OnCell);
},
defaultCompleteMode = ToilCompleteMode.PatherArrival
};
yield return findfapspot;
//Log.Message("[RJW] Making new toil for QuickFap.");
Toil fap = Toils_General.Wait(ticks_left);
fap.tickAction = delegate
{
--ticks_left;
xxx.reduce_rest(pawn, 1);
if (ticks_left <= 0)
ReadyForNextToil();
else if (pawn.IsHashIntervalTick(ticks_between_hearts))
MoteMaker.ThrowMetaIcon(pawn.Position, pawn.Map, ThingDefOf.Mote_Heart);
};
fap.AddFinishAction(delegate
{
SexUtility.Aftersex(pawn, xxx.rjwSextype.Masturbation);
if (!SexUtility.ConsiderCleaning(pawn)) return;
LocalTargetInfo own_cum = pawn.PositionHeld.GetFirstThing<Filth>(pawn.Map);
Job clean = new Job(JobDefOf.Clean);
clean.AddQueuedTarget(TargetIndex.A, own_cum);
pawn.jobs.jobQueue.EnqueueFirst(clean);
});
yield return fap;
}
}
}
|
Mewtopian/rjw
|
Source/JobDrivers/JobDriver_QuickFap.cs
|
C#
|
mit
| 1,978 |
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.
}
}
|
Mewtopian/rjw
|
Source/JobDrivers/JobDriver_RandomRape.cs
|
C#
|
mit
| 256 |
using System;
using System.Collections.Generic;
using RimWorld;
using Verse;
using Verse.AI;
using Multiplayer.API;
namespace rjw
{
public class JobDriver_Rape : JobDriver
{
protected int duration;
protected int ticks_between_hearts;
protected int ticks_between_hits = 50;
protected int ticks_between_thrusts;
protected TargetIndex iTarget = TargetIndex.A;
public Pawn Target => (Pawn)(job.GetTarget(iTarget));
public override bool TryMakePreToilReservations(bool errorOnFailed)
{
return pawn.Reserve(Target, job, xxx.max_rapists_per_prisoner, 0, null, errorOnFailed);
}
[SyncMethod]
public static void roll_to_hit(Pawn rapist, Pawn p)
{
if (!RJWSettings.rape_beating)
return;
//Rand.PopState();
//Rand.PushState(RJW_Multiplayer.PredictableSeed());
float rand_value = Rand.Value;
float victim_pain = p.health.hediffSet.PainTotal;
// bloodlust makes the aggressor more likely to hit the prisoner
float beating_chance = xxx.config.base_chance_to_hit_prisoner * (xxx.is_bloodlust(rapist) ? 1.25f : 1.0f);
// psychopath makes the aggressor more likely to hit the prisoner past the significant_pain_threshold
float beating_threshold = xxx.is_psychopath(rapist) ? xxx.config.extreme_pain_threshold : xxx.config.significant_pain_threshold;
//--Log.Message("roll_to_hit: rand = " + rand_value + ", beating_chance = " + beating_chance + ", victim_pain = " + victim_pain + ", beating_threshold = " + beating_threshold);
if ((victim_pain < beating_threshold && rand_value < beating_chance) || (rand_value < (beating_chance / 2) && xxx.is_bloodlust(rapist)))
{
//--Log.Message(" done told her twice already...");
if (InteractionUtility.TryGetRandomVerbForSocialFight(rapist, out Verb v))
{
rapist.meleeVerbs.TryMeleeAttack(p, v);
}
}
/*
//if (p.health.hediffSet.PainTotal < xxx.config.significant_pain_threshold)
if ((Rand.Value < 0.50f) &&
((Rand.Value < 0.33f) || (p.health.hediffSet.PainTotal < xxx.config.significant_pain_threshold) ||
(xxx.is_bloodlust (rapist) || xxx.is_psychopath (rapist)))) {
Verb v;
if (InteractionUtility.TryGetRandomVerbForSocialFight (rapist, out v))
rapist.meleeVerbs.TryMeleeAttack (p, v);
}
*/
}
[SyncMethod]
protected override IEnumerable<Toil> MakeNewToils()
{
//Rand.PopState();
//Rand.PushState(RJW_Multiplayer.PredictableSeed());
//Log.Message("[RJW]" + this.GetType().ToString() + "::MakeNewToils() called");
duration = (int)(2000.0f * Rand.Range(0.50f, 0.90f));
ticks_between_hearts = Rand.RangeInclusive(70, 130);
ticks_between_hits = Rand.Range(xxx.config.min_ticks_between_hits, xxx.config.max_ticks_between_hits);
ticks_between_thrusts = 100;
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);
this.FailOnDespawnedNullOrForbidden(iTarget);
this.FailOn(() => !pawn.CanReserve(Target, xxx.max_rapists_per_prisoner, 0)); // Fail if someone else reserves the prisoner before the pawn arrives
this.FailOn(() => pawn.IsFighting());
this.FailOn(() => Target.IsFighting());
this.FailOn(() => pawn.Drafted);
yield return Toils_Goto.GotoThing(iTarget, PathEndMode.OnCell);
SexUtility.RapeAttemptAlert(pawn, Target);
//Log.Message("[RJW] JobDriver_Rape::make toils() called");
var rape = new Toil();
rape.initAction = delegate
{
//Log.Message("[RJW]" + this.GetType().ToString() + "::initAction() called");
//pawn.Reserve(Target, comfort_prisoners.max_rapists_per_prisoner, 0);
//if (!pawnHasPenis)
// Target.rotationTracker.Face(pawn.DrawPos);
JobDriver_GettinRaped dri = Target.jobs.curDriver as JobDriver_GettinRaped;
if (dri == null)
{
Job gettin_raped = new Job(xxx.gettin_raped, pawn, Target);
Building_Bed Bed = null;
//Log.Message(xxx.get_pawnname(pawn) + " LayingInBed:" + pawn.GetPosture());
//Log.Message(xxx.get_pawnname(Target) + " LayingInBed:" + Target.GetPosture());
if (Target.GetPosture() == PawnPosture.LayingInBed)
{
Bed = Target.CurrentBed();
//Log.Message(xxx.get_pawnname(Target) + ": bed:" + Bed);
}
Target.jobs.StartJob(gettin_raped, JobCondition.InterruptForced, null, false, true, null);
(Target.jobs.curDriver as JobDriver_GettinRaped)?.increase_time(duration);
if (Bed !=null)
(Target.jobs.curDriver as JobDriver_GettinRaped)?.set_bed(Bed);
}
else
{
dri.rapist_count += 1;
dri.increase_time(duration);
}
rape.FailOn(() => Target.CurJob == null || Target.CurJob.def != xxx.gettin_raped || Target.IsFighting() || pawn.IsFighting());
};
rape.tickAction = delegate
{
//Log.Message("[RJW] JobDriver_Rape::tickAction() called");
if (pawn.IsHashIntervalTick(ticks_between_hearts))
MoteMaker.ThrowMetaIcon(pawn.Position, pawn.Map, ThingDefOf.Mote_Heart);
if (pawn.IsHashIntervalTick(ticks_between_thrusts))
xxx.sexTick(pawn, Target, false);
if (pawn.IsHashIntervalTick(ticks_between_hits))
roll_to_hit(pawn, Target);
xxx.reduce_rest(Target, 1);
xxx.reduce_rest(pawn, 2);
};
rape.AddFinishAction(delegate
{
if (Target.jobs?.curDriver is JobDriver_GettinRaped)
{
(Target.jobs.curDriver as JobDriver_GettinRaped).rapist_count -= 1;
}
});
rape.defaultCompleteMode = ToilCompleteMode.Delay;
rape.defaultDuration = duration;
yield return rape;
yield return new Toil
{
initAction = delegate
{
//Log.Message("[RJW] JobDriver_Rape::aftersex() called");
//// Trying to add some interactions and social logs
SexUtility.ProcessSex(pawn, Target, true);
},
defaultCompleteMode = ToilCompleteMode.Instant
};
}
}
}
|
Mewtopian/rjw
|
Source/JobDrivers/JobDriver_Rape.cs
|
C#
|
mit
| 5,832 |
using System;
using System.Collections.Generic;
using System.Linq;
using RimWorld;
using Verse;
using Verse.AI;
namespace rjw
{
internal class JobDef_RapeEnemy : JobDef
{
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 virtual bool CanUseThisJobForPawn(Pawn rapist)
{
if (rapist.CurJob != null && rapist.CurJob.def != JobDefOf.LayDown)
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
{
private static readonly HediffDef is_submitting = HediffDef.Named("Hediff_Submitting");//used in find_victim
//override can_rape mechanics
protected bool requierCanRape = 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;
public virtual Pawn FindVictim(Pawn rapist, Map m)
{
//Log.Message("[RJW]" + this.GetType().ToString() + "::TryGiveJob( " + xxx.get_pawnname(rapist) + " ) map " + m?.ToString());
if (rapist == null || m == null) return null;
//Log.Message("[RJW]" + this.GetType().ToString() + "::TryGiveJob( " + xxx.get_pawnname(rapist) + " ) can rape " + xxx.can_rape(rapist));
if (!xxx.can_rape(rapist) && requierCanRape) return null;
Pawn best_rapee = null;
List<Pawn> filteredtargets = new List<Pawn>();
float best_fuckability = 0.20f; // Don't rape pawns with <20% fuckability
IEnumerable<Pawn> targets =
m.mapPawns.AllPawnsSpawned.Where(x => !x.IsForbidden(rapist) && x != rapist && x.HostileTo(rapist));
//Log.Message("[RJW]" + this.GetType().ToString() + "::TryGiveJob( " + xxx.get_pawnname(rapist) + " ) found " + targets.Count() + "targets");
foreach (Pawn target in targets)
{
if (!xxx.can_path_to_target(rapist, target.Position))
continue;// too far
//Log.Message("[RJW]" + this.GetType().ToString() + "::TryGiveJob( " + xxx.get_pawnname(rapist) + " ) target: " + xxx.get_pawnname(target) );
if (considerStillAliveEnemies)
{
if (rapist.CanSee(target) && !target.Downed)
{
//Log.Message("[RJW]"+this.GetType().ToString()+"::TryGiveJob( " + xxx.get_pawnname(rapist) +" ) enemies: "+ xxx.get_pawnname(target)+ " still alive" );
return null; //Enemies still up. Kill them first.
}
}
if (!RJWSettings.bestiality_enabled && xxx.is_animal(target) && !(xxx.is_animal(rapist) && RJWSettings.animal_on_animal_enabled)) continue; //zoo disabled, skip.
if (target.CurJob.def == xxx.gettin_raped || target.CurJob.def == xxx.gettin_loved) continue; //already having sex with someone, skip, give chance to other victims.
//Log.Message("[RJW]"+this.GetType().ToString()+"::TryGiveJob( " + xxx.get_pawnname(rapist) + " -> " + xxx.get_pawnname(target) + " ) - checking\nCanReserve:"+ rapist.CanReserve(target, xxx.max_rapists_per_prisoner, 0) + "\nCanReach:" + rapist.CanReach(target, PathEndMode.OnCell, Danger.None)+ "\nCan_rape_Easily:" + Can_rape_Easily(target));
if (rapist.CanReserveAndReach(target, PathEndMode.OnCell, Danger.Some, xxx.max_rapists_per_prisoner, 0) && Can_rape_Easily(target) )
{
if (xxx.is_human(target) || xxx.is_animal(target))
{
float fuc = GetFuckability(rapist, target);
//Log.Message("[RJW]"+this.GetType().ToString()+ "::FindVictim( " + xxx.get_pawnname(rapist) + " -> " + xxx.get_pawnname(target) + " ) - fuckability:" + fuc + " ");
if (fuc > best_fuckability)
{
if (xxx.is_animal(rapist))
{
filteredtargets.Add(target);
continue;
}
best_rapee = target;
best_fuckability = fuc;
}
//else { Log.Message("[RJW]"+this.GetType().ToString()+"::TryGiveJob( " + xxx.get_pawnname(rapist) + " -> " + xxx.get_pawnname(target) + " ) - is not good for me "+ "( " + fuc + " )"); }
}
}
//else { Log.Message("[RJW]"+this.GetType().ToString()+"::TryGiveJob( " + xxx.get_pawnname(rapist) + " -> " + xxx.get_pawnname(target) + " ) - is not good"); }
}
//Log.Message("[RJW]"+this.GetType().ToString()+"::TryGiveJob( " + xxx.get_pawnname(rapist) + " -> " + xxx.get_pawnname(best_rapee) + " ) - fuckability:" + best_fuckability + " ");
return filteredtargets.Any() ? filteredtargets.RandomElement() : best_rapee;
}
public virtual float GetFuckability(Pawn rapist, Pawn target)
{
//Log.Message("[RJW]JobDriver_RapeEnemy::GetFuckability(" + rapist.ToString() + "," + target.ToString() + ")");
if (target.health.hediffSet.HasHediff(is_submitting))//it's not about attractiveness anymore, it's about showing who's whos bitch
{
return 2 * xxx.would_fuck(rapist, target, invert_opinion: true, ignore_bleeding: true, ignore_gender: true);
}
return !xxx.would_rape(rapist, target) ? 0f
: xxx.would_fuck(rapist, target, invert_opinion: true, ignore_bleeding: true, ignore_gender: true);
}
protected bool Can_rape_Easily(Pawn pawn)
{
return xxx.can_get_raped(pawn) && !pawn.IsBurning();
}
}
}
|
Mewtopian/rjw
|
Source/JobDrivers/JobDriver_RapeEnemy.cs
|
C#
|
mit
| 5,496 |
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) && (RJWSettings.bestiality_enabled || RJWSettings.animal_on_animal_enabled);
}
}
}
|
Mewtopian/rjw
|
Source/JobDrivers/JobDriver_RapeEnemyByAnimal.cs
|
C#
|
mit
| 500 |
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);
}
}
}
|
Mewtopian/rjw
|
Source/JobDrivers/JobDriver_RapeEnemyByHumanlike.cs
|
C#
|
mit
| 400 |
using System.Linq;
using RimWorld;
using Verse;
namespace rjw
{
internal class JobDriver_RapeEnemyByInsect : JobDriver_RapeEnemy
{
//override mechanics
//public JobDriver_RapeEnemyByInsect()
//{
// this.requierCanRape = 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;
//someday add check for insect-insect breeding
return xxx.is_insect(rapist) && RJWSettings.bestiality_enabled;
}
public override float GetFuckability(Pawn rapist, Pawn target)
{
//Plant Eggs to everyone.
if (rapist.gender == Gender.Female)
{
return 1f;
}
//Feritlize eggs to everyone with planted eggs.
else
{
//if ((from x in target.health.hediffSet.GetHediffs<Hediff_InsectEgg>() where (x.IsParent(rapist.def.defName) && !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 0f;
}
}
}
|
Mewtopian/rjw
|
Source/JobDrivers/JobDriver_RapeEnemyByInsect.cs
|
C#
|
mit
| 1,169 |
using RimWorld;
using Verse;
namespace rjw
{
internal class JobDriver_RapeEnemyByMech : JobDriver_RapeEnemy
{
//public JobDriver_RapeEnemyByMech()
//{
// this.requierCanRape = 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 xxx.is_mechanoid(rapist);
}
public override float GetFuckability(Pawn rapist, Pawn target)
{
//--Log.Message("[RJW]JobDriver_RapeEnemyByMech::GetFuckability("+ rapist.ToString()+","+ target.ToString() + ") - Force Rape");
//Plant chips to humanlikes.
if (xxx.is_human(target))
return 1f;
else
return 0f;
}
}
}
|
Mewtopian/rjw
|
Source/JobDrivers/JobDriver_RapeEnemyByMech.cs
|
C#
|
mit
| 794 |
using RimWorld;
using Verse;
namespace rjw
{
internal class JobDriver_RapeEnemyToParasite : JobDriver_RapeEnemy
{
public JobDriver_RapeEnemyToParasite()
{
this.requierCanRape = false;
}
//not implemented
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;
}
}
}
|
Mewtopian/rjw
|
Source/JobDrivers/JobDriver_RapeEnemyToParasite.cs
|
C#
|
mit
| 489 |
using System.Collections.Generic;
using RimWorld;
using Verse;
using Verse.AI;
namespace rjw
{
public abstract class JobDriver_Sex : JobDriver
{
protected float satisfaction = 1.0f;
public bool shouldreserve = true;
public int stackCount = 0;
public int ticks_between_hearts;
public int ticks_between_hits = 50;
public int ticks_between_thrusts;
public Thing Target = null;
//private Building_Bed Bed;
public override bool TryMakePreToilReservations(bool errorOnFailed)
{
Log.Message("shouldreserve " + shouldreserve);
if (shouldreserve)
return pawn.Reserve(Target, job, xxx.max_rapists_per_prisoner, stackCount, 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);
}
public void CalculateSatisfactionPerTick()
{
satisfaction = 1.0f;
}
protected override IEnumerable<Toil> MakeNewToils()
{
return null;
}
}
}
|
Mewtopian/rjw
|
Source/JobDrivers/JobDriver_Sex.cs
|
C#
|
mit
| 1,013 |
using System.Collections.Generic;
using RimWorld;
using Verse;
using Verse.AI;
using Verse.Sound;
using Multiplayer.API;
namespace rjw
{
public class JobDriver_ViolateCorpse : JobDriver
{
private int duration;
private int ticks_between_hearts;
private int ticks_between_hits = 50;
private int ticks_between_thrusts;
protected TargetIndex icorpse = TargetIndex.A;
protected Corpse Target => (Corpse)(job.GetTarget(icorpse));
public static void sexTick(Pawn pawn, Thing Target)
{
if (!xxx.has_quirk(pawn, "Endytophile"))
{
xxx.DrawNude(pawn, true);
}
if (RJWSettings.sounds_enabled)
SoundDef.Named("Sex").PlayOneShot(new TargetInfo(pawn.Position, pawn.Map));
pawn.Drawer.Notify_MeleeAttackOn(Target);
pawn.rotationTracker.FaceCell(Target.Position);
}
public override bool TryMakePreToilReservations(bool errorOnFailed)
{
return pawn.Reserve(Target, job, 1, -1, null, errorOnFailed);
}
[SyncMethod]
protected override IEnumerable<Toil> MakeNewToils()
{
//--Log.Message("[RJW] JobDriver_ViolateCorpse::MakeNewToils() called");
//Rand.PopState();
//Rand.PushState(RJW_Multiplayer.PredictableSeed());
duration = (int)(2000.0f * Rand.Range(0.50f, 0.90f));
ticks_between_hearts = Rand.RangeInclusive(70, 130);
ticks_between_hits = Rand.Range(xxx.config.min_ticks_between_hits, xxx.config.max_ticks_between_hits);
ticks_between_thrusts = 100;
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);
this.FailOnDespawnedNullOrForbidden(icorpse);
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);
//--Log.Message("[RJW] JobDriver_ViolateCorpse::MakeNewToils() - moving towards Target");
yield return Toils_Goto.GotoThing(icorpse, PathEndMode.OnCell);
var alert = RJWPreferenceSettings.rape_alert_sound == RJWPreferenceSettings.RapeAlert.Disabled ?
MessageTypeDefOf.SilentInput : MessageTypeDefOf.NeutralEvent;
Messages.Message(pawn.Name + " is trying to rape a Target.", pawn, alert);
var rape = new Toil();
rape.initAction = delegate
{
//--Log.Message("[RJW] JobDriver_ViolateCorpse::MakeNewToils() - reserving Target");
//pawn.Reserve(Target, 1, 0); // Target rapin seems like a solitary activity
//--Log.Message("[RJW] JobDriver_ViolateCorpse::MakeNewToils() - stripping Target");
Target.Strip();
};
rape.tickAction = delegate
{
if (pawn.IsHashIntervalTick(ticks_between_hearts))
MoteMaker.ThrowMetaIcon(pawn.Position, pawn.Map, ThingDefOf.Mote_Heart);
if (pawn.IsHashIntervalTick(ticks_between_thrusts))
sexTick(pawn, Target);
/*
if (pawn.IsHashIntervalTick (ticks_between_hits))
roll_to_hit (pawn, Corpse);
*/
xxx.reduce_rest(pawn, 2);
};
rape.AddFinishAction(delegate
{
if (xxx.is_human(pawn))
pawn.Drawer.renderer.graphics.ResolveApparelGraphics();
});
rape.defaultCompleteMode = ToilCompleteMode.Delay;
rape.defaultDuration = duration;
yield return rape;
yield return new Toil
{
initAction = delegate
{
//--Log.Message("[RJW] JobDriver_ViolateCorpse::MakeNewToils() - creating aftersex toil");
//Addded by nizhuan-jjr: Try to apply an aftersex process for the pawn and the Target
if (Target.InnerPawn != null)
{
SexUtility.ProcessSex(pawn, Target.InnerPawn, true);
}
},
defaultCompleteMode = ToilCompleteMode.Instant
};
}
}
}
|
Mewtopian/rjw
|
Source/JobDrivers/JobDriver_ViolateCorpse.cs
|
C#
|
mit
| 3,709 |
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
{
private const float min_fuckability = 0.10f; // Don't rape prisoners with <10% fuckability
[SyncMethod]
public static Pawn find_victim(Pawn pawn, Map m)
{
IEnumerable<Pawn> targets = m.mapPawns.AllPawns.Where(x
=> x != pawn
&& IsPrisonerOf(x, pawn.Faction)
&& xxx.can_get_raped(x)
&& !x.Position.IsForbidden(pawn)
);
List<Pawn> valid_targets = new List<Pawn>();
foreach (Pawn target in targets)
{
if (!pawn.CanReserve(target, xxx.max_rapists_per_prisoner, 0)) continue;
//--Log.Message(xxx.get_pawnname(pawn) + "->" + xxx.get_pawnname(target) + ":" + fuc);
if (xxx.would_fuck(pawn, target, true, true) > min_fuckability)
{
valid_targets.Add(target);
}
}
//Rand.PopState();
//Rand.PushState(RJW_Multiplayer.PredictableSeed());
return valid_targets.Any() ? valid_targets.RandomElement() : null;
}
protected override Job TryGiveJob(Pawn pawn)
{
//Log.Message("[RJW] JobGiver_AIRapePrisoner::TryGiveJob( " + xxx.get_pawnname(pawn) + " ) called ");
if (!xxx.can_rape(pawn)) return null;
if (SexUtility.ReadyForLovin(pawn) || xxx.need_some_sex(pawn) > 1f)
{
// 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)
{
//--Log.Message("[RJW] JobGiver_RandomRape::TryGiveJob( " + xxx.get_pawnname(p) + " ) - found victim " + xxx.get_pawnname(prisoner));
return new Job(xxx.random_rape, 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;
}
}
}
|
Mewtopian/rjw
|
Source/JobGivers/JobGiver_AIRapePrisoner.cs
|
C#
|
mit
| 2,005 |
// #define TESTMODE // Uncomment to enable logging.
using System.Diagnostics;
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
{
[Conditional("TESTMODE")]
private static void DebugText(string msg)
{
Log.Message(msg);
}
protected override Job TryGiveJob(Pawn pawn)
{
if (pawn.Drafted) return null;
// Most checks are now done in ThinkNode_ConditionalBestiality
DebugText("[RJW] JobGiver_Bestiality::TryGiveJob( " + xxx.get_pawnname(pawn) + " ) called");
if (!SexUtility.ReadyForLovin(pawn) && !xxx.is_frustrated(pawn))
return null;
Pawn target = BreederHelper.find_breeder_animal(pawn, pawn.Map);
DebugText("[RJW] JobGiver_Bestiality::TryGiveJob - target is " + (target == null ? "no target found" : xxx.get_pawnname(target)));
if (target == null) return null;
if (xxx.can_rape(pawn))
{
return new Job(xxx.bestiality, target);
}
Building_Bed bed = pawn.ownership.OwnedBed;
if (!xxx.can_be_fucked(pawn) || bed == null || !target.CanReach(bed, PathEndMode.OnCell, Danger.Some) || target.Downed) return null;
// TODO: Should rename this to BestialityInBed or somesuch, since it's not limited to females.
return new Job(xxx.bestialityForFemale, target, bed, bed.SleepPosOfAssignedPawn(pawn));
}
}
}
|
Mewtopian/rjw
|
Source/JobGivers/JobGiver_Bestiality.cs
|
C#
|
mit
| 1,427 |
using Verse;
using Verse.AI;
using System.Collections.Generic;
using Multiplayer.API;
namespace rjw
{
/// <summary>
/// Attempts to give a breeding job to an eligible animal.
/// </summary>
public class JobGiver_Breed : ThinkNode_JobGiver
{
[SyncMethod]
protected override Job TryGiveJob(Pawn animal)
{
//Log.Message("[RJW] JobGiver_Breed::TryGiveJob( " + xxx.get_pawnname(animal) + " ) called0" + (SexUtility.ReadyForLovin(animal)));
if (!SexUtility.ReadyForLovin(animal))
return null;
if(xxx.is_healthy(animal) && xxx.can_rape(animal))
{
//Log.Message("[RJW] JobGiver_Breed::TryGiveJob( " + xxx.get_pawnname(animal) + " ) called2");
List<Pawn> valid_targets = new List<Pawn>();
//search for desiganted target to sex
if (animal.IsDesignatedBreedingAnimal())
{
Pawn designated_target = BreederHelper.find_designated_breeder(animal, animal.Map);
if (designated_target != null)
{
valid_targets.Add(designated_target);
}
}
//some weird shit happens, animal tries to rape and fails, needs investigation someday
/*
//search for animal to sex
if (RJWSettings.animal_on_animal_enabled)
{
//Using bestiality target finder, since it works best for this.
//search for same race mate
if (!valid_targets.Any())
{
Pawn animal_target = BreederHelper.find_breeder_animal(animal, animal.Map);
if (animal_target != null)
{
valid_targets.Add(animal_target);
}
}
//search for any other animal/human to sex
if (!valid_targets.Any())
{
Pawn animal_target = BreederHelper.find_breeder_animal(animal, animal.Map, false);
if (animal_target != null)
{
valid_targets.Add(animal_target);
}
}
}
*/
//Log.Message("[RJW] JobGiver_Breed::TryGiveJob( " + xxx.get_pawnname(animal) + " ) called3 - (" + ((target == null) ? "no target found" : xxx.get_pawnname(target))+") is the prisoner");
if (valid_targets != null && valid_targets.Any())
{
//Rand.PopState();
//Rand.PushState(RJW_Multiplayer.PredictableSeed());
var target = valid_targets.RandomElement();
//Log.Message("Target: " + xxx.get_pawnname(target));
return new Job(DefDatabase<JobDef>.GetNamed("Breed"), target, animal);
}
}
return null;
}
}
}
|
Mewtopian/rjw
|
Source/JobGivers/JobGiver_Breed.cs
|
C#
|
mit
| 2,343 |
using Verse;
using Verse.AI;
using RimWorld;
using System.Collections.Generic;
using System.Linq;
namespace rjw
{
public class JobGiver_ComfortPrisonerRape : ThinkNode_JobGiver
{
public static Pawn find_prisoner_to_rape(Pawn pawn, Map m)
{
if (!DesignatorsData.rjwComfort.Any()) return null;
Pawn best_rapee = null;
float best_fuckability = 0.10f; // Don't rape prisoners with <10% fuckability
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)
&& xxx.would_rape(pawn, x)
);
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 (!xxx.can_path_to_target(pawn, target.Position))
continue;// too far
float fuc = 0.0f;
if (xxx.is_animal(target))
fuc = xxx.would_fuck_animal(pawn, target, true);
else if (xxx.is_human(target))
fuc = xxx.would_fuck(pawn, target, true);
//--Log.Message(pawn.Name + " -> " + candidate.Name + " (" + fuc.ToString() + " / " + best_fuckability.ToString() + ")");
if (fuc > best_fuckability)
{
best_rapee = target;
best_fuckability = fuc;
}
}
return best_rapee;
}
protected override Job TryGiveJob(Pawn pawn)
{
//Log.Message("[RJW] JobGiver_ComfortPrisonerRape::TryGiveJob( " + xxx.get_pawnname(pawn) + " ) called0");
if (!RJWSettings.WildMode)
{
// don't allow pawns marked as comfort prisoners to rape others
if (!xxx.is_healthy(pawn) || pawn.IsDesignatedComfort() || (!SexUtility.ReadyForLovin(pawn) && !xxx.is_frustrated(pawn))) return null;
}
if (pawn.Drafted) return null;
//Log.Message("[RJW] JobGiver_ComfortPrisonerRape::TryGiveJob( " + xxx.get_pawnname(pawn) + " ) called1");
if (!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 layind down idle.
if (!(pawn.jobs.curJob == null || pawn.jobs.curJob.def == JobDefOf.LayDown)) return null;
//--Log.Message("[RJW] JobGiver_ComfortPrisonerRape::TryGiveJob( " + xxx.get_pawnname(pawn) + " ) called2");
// Faction check.
if (!(pawn.Faction?.IsPlayer ?? false) && !pawn.IsPrisonerOfColony) return null;
Pawn target = find_prisoner_to_rape(pawn, pawn.Map);
//--Log.Message("[RJW] JobGiver_ComfortPrisonerRape::TryGiveJob( " + xxx.get_pawnname(pawn) + " ) called3 - (" + ((target == null) ? "no target found" : xxx.get_pawnname(target))+") is the prisoner");
if (target == null) return null;
//Log.Message("giving job to " + pawner + " with target " + target);
if (xxx.is_animal(target))
return new Job(xxx.bestiality, target);
else
return new Job(xxx.comfort_prisoner_rapin, target);
}
}
}
|
Mewtopian/rjw
|
Source/JobGivers/JobGiver_ComfortPrisonerRape.cs
|
C#
|
mit
| 2,989 |
using RimWorld;
using Verse;
using Verse.AI;
using System.Collections.Generic;
using System.Linq;
using Multiplayer.API;
namespace rjw
{
public class JobGiver_DoFappin : ThinkNode_JobGiver
{
[SyncMethod]
public virtual IntVec3 FindFapLocation(Pawn pawn)
{
IntVec3 position = pawn.Position;
int bestPosition = -100;
IntVec3 cell = pawn.Position;
int maxDistance = 40;
FloatRange temperature = pawn.ComfortableTemperatureRange();
bool is_somnophile = xxx.has_quirk(pawn, "Somnophile");
bool is_exhibitionist = xxx.has_quirk(pawn, "Exhibitionist");
List<Pawn> all_pawns = pawn.Map.mapPawns.AllPawnsSpawned.Where(x
=> x.Position.DistanceTo(pawn.Position) < 100
&& xxx.is_human(x)
&& x != pawn
).ToList();
//Log.Message("[RJW] Pawn is " + xxx.get_pawnname(pawn) + ", current cell is " + cell);
//Rand.PopState();
//Rand.PushState(RJW_Multiplayer.PredictableSeed());
List<IntVec3> random_cells = new List<IntVec3>();
for (int loop = 0; loop < 50; ++loop)
{
random_cells.Add(position + IntVec3.FromVector3(Vector3Utility.HorizontalVectorFromAngle(Rand.Range(0, 360)) * Rand.RangeInclusive(1, maxDistance)));
}
random_cells = random_cells.Where(x
=> x.Standable(pawn.Map)
&& x.InAllowedArea(pawn)
&& x.GetDangerFor(pawn, pawn.Map) != Danger.Deadly
&& !x.ContainsTrap(pawn.Map)
&& !x.ContainsStaticFire(pawn.Map)
).Distinct().ToList();
//Log.Message("[RJW] Found " + random_cells.Count + " valid cells.");
foreach (IntVec3 random_cell in random_cells)
{
if (!xxx.can_path_to_target(pawn, random_cell))
continue;// too far
int score = 0;
Room room = random_cell.GetRoom(pawn.Map);
bool might_be_seen = all_pawns.Any(x
=> GenSight.LineOfSight(x.Position, random_cell, pawn.Map)
&& x.Position.DistanceTo(random_cell) < 50
&& x.Awake()
);
if (is_exhibitionist)
{
if (might_be_seen)
score += 5;
else
score -= 10;
}
else
{
if (might_be_seen)
score -= 30;
}
if (is_somnophile) // Fap while Watching someone sleep. Not creepy at all!
{
if (all_pawns.Any(x
=> GenSight.LineOfSight(random_cell, x.Position, pawn.Map)
&& x.Position.DistanceTo(random_cell) < 6
&& !x.Awake()
))
score += 50;
}
if (random_cell.GetTemperature(pawn.Map) > temperature.min && random_cell.GetTemperature(pawn.Map) < temperature.max)
score += 20;
else
score -= 20;
if (random_cell.Roofed(pawn.Map))
score += 5;
if (random_cell.HasEatSurface(pawn.Map))
score += 5; // Hide in vegetation.
if (random_cell.GetDangerFor(pawn, pawn.Map) == Danger.Some)
score -= 25;
else if (random_cell.GetDangerFor(pawn, pawn.Map) == Danger.None)
score += 5;
if (random_cell.GetTerrain(pawn.Map) == TerrainDefOf.WaterShallow ||
random_cell.GetTerrain(pawn.Map) == TerrainDefOf.WaterMovingShallow ||
random_cell.GetTerrain(pawn.Map) == TerrainDefOf.WaterOceanShallow)
score -= 20;
if (random_cell.GetThingList(pawn.Map).Any(x => x.def.IsWithinCategory(ThingCategoryDefOf.Corpses)) && !xxx.is_necrophiliac(pawn))
score -= 20;
if (random_cell.GetThingList(pawn.Map).Any(x => x.def.IsWithinCategory(ThingCategoryDefOf.Foods)))
score -= 10;
if (room == pawn.Position.GetRoom(pawn.MapHeld))
score -= 10;
if (room.PsychologicallyOutdoors)
score += 5;
if (room.isPrisonCell)
score += 5;
if (room.IsHuge)
score -= 5;
if (room.ContainedBeds.Any())
score += 5;
if (room.IsDoorway)
score -= 10;
if (!room.Owners.Any())
score += 10;
else if (room.Owners.Contains(pawn))
score += 20;
if (room.Role == RoomRoleDefOf.Bedroom || room.Role == RoomRoleDefOf.PrisonCell)
score += 10;
else if (room.Role == RoomRoleDefOf.Barracks || room.Role == RoomRoleDefOf.Laboratory || room.Role == RoomRoleDefOf.RecRoom)
score += 2;
else if (room.Role == RoomRoleDefOf.DiningRoom || room.Role == RoomRoleDefOf.Hospital || room.Role == RoomRoleDefOf.PrisonBarracks)
score -= 5;
if (room.GetStat(RoomStatDefOf.Cleanliness) < 0.01f)
score -= 5;
if (room.GetStat(RoomStatDefOf.GraveVisitingJoyGainFactor) > 0.1f)
score -= 5;
if (score <= bestPosition) continue;
bestPosition = score;
cell = random_cell;
}
return cell;
//Log.Message("[RJW] Best cell is " + cell);
}
protected override Job TryGiveJob(Pawn pawn)
{
//--Log.Message("[RJW] JobGiver_DoFappin::TryGiveJob( " + xxx.get_pawnname(pawn) + " ) called");
if (pawn.Drafted) return null;
if (!xxx.can_be_fucked(pawn) && !xxx.can_fuck(pawn)) return null;
// Whores only fap if frustrated, unless imprisoned.
if ((SexUtility.ReadyForLovin(pawn) && (!xxx.is_whore(pawn) || pawn.IsPrisoner )) || xxx.is_frustrated(pawn))
{
if (pawn.jobs.curDriver is JobDriver_LayDown && RJWPreferenceSettings.FapInBed)
{
Building_Bed bed = ((JobDriver_LayDown)pawn.jobs.curDriver).Bed;
if (bed != null) return new Job(xxx.fappin, bed);
}
else if ((xxx.is_frustrated(pawn) || xxx.has_quirk(pawn, "Exhibitionist")) && RJWPreferenceSettings.FapEverywhere)
{
return new Job(xxx.quickfap, FindFapLocation(pawn));
}
}
return null;
}
}
}
|
Mewtopian/rjw
|
Source/JobGivers/JobGiver_DoFappin.cs
|
C#
|
mit
| 5,351 |
using System.Collections.Generic;
using System.Linq;
using RimWorld;
using Verse;
using Verse.AI;
using Multiplayer.API;
namespace rjw
{
public class JobGiver_JoinInBed : ThinkNode_JobGiver
{
private const int MaxDistanceSquaredToFuck = 10000;
private static bool CanFuck(Pawn target)
{
return xxx.can_fuck(target) || xxx.can_be_fucked(target);
}
[SyncMethod]
private static bool roll_to_skip(Pawn pawn, Pawn target, out float fuckability)
{
fuckability = xxx.would_fuck(pawn, target); // 0.0 to 1.0
if (fuckability < RJWHookupSettings.MinimumFuckabilityToHookup)
{
Log.Message($"[RJW] roll_to_skip({xxx.get_pawnname(pawn)},{xxx.get_pawnname(target)}) fuckability too low:({fuckability})");
return false;
}
float reciprocity = xxx.is_animal(target) ? 1.0f : xxx.would_fuck(target, pawn);
if (reciprocity < RJWHookupSettings.MinimumFuckabilityToHookup)
{
Log.Message($"[RJW] roll_to_skip({xxx.get_pawnname(pawn)},{xxx.get_pawnname(target)}) won't fuck me:({fuckability},{reciprocity})");
return false;
}
float chance_to_skip = 0.9f - 0.7f * fuckability;
//Rand.PopState();
//Rand.PushState(RJW_Multiplayer.PredictableSeed());
return Rand.Value < chance_to_skip;
}
[SyncMethod]
public static Pawn find_pawn_to_fuck(Pawn pawn, Map map)
{
string pawnName = xxx.get_pawnname(pawn);
if (RJWSettings.DebugLogJoinInBed) Log.Message($"[RJW] find_pawn_to_fuck({pawnName}): starting.");
bool pawnIsNympho = xxx.is_nympho(pawn);
bool pawnCanPickAnyone = RJWSettings.WildMode || (pawnIsNympho && RJWHookupSettings.NymphosCanPickAnyone);
bool pawnCanPickAnimals = (pawnCanPickAnyone || xxx.is_zoophile(pawn)) && RJWSettings.bestiality_enabled;
if (RJWSettings.DebugLogJoinInBed) Log.Message($"[RJW] find_pawn_to_fuck({pawnName}): nympho:{pawnIsNympho}, ignores rules:{pawnCanPickAnyone}, zoo:{pawnCanPickAnimals}");
if (!RJWHookupSettings.ColonistsCanHookup && pawn.IsFreeColonist && !pawnCanPickAnyone)
{
if (RJWSettings.DebugLogJoinInBed) Log.Message($"[RJW] find_pawn_to_fuck({pawnName}): is a colonist and colonist hookups are disabled in mod settings");
return null;
}
//Rand.PopState();
//Rand.PushState(RJW_Multiplayer.PredictableSeed());
// Check AllPawns, not just colonists, to include guests.
List<Pawn> targets = map.mapPawns.AllPawns.Where(x
=> x.InBed()
&& x != pawn
&& !x.Position.IsForbidden(pawn)
&& xxx.IsTargetPawnOkay(x)
&& CanFuck(x)
&& x.Map == pawn.Map
&& !x.HostileTo(pawn)
//&& (pawnCanPickAnimals || !xxx.is_animal(x))
&& !xxx.is_animal(x)
&& (xxx.is_laying_down_alone(x) || xxx.in_same_bed(x, pawn))
).ToList();
if (!targets.Any())
{
if (RJWSettings.DebugLogJoinInBed) Log.Message($"[RJW] find_pawn_to_fuck({pawnName}): no eligible targets");
return null;
}
if (RJWSettings.DebugLogJoinInBed) Log.Message($"[RJW] find_pawn_to_fuck({pawnName}): considering {targets.Count} targets");
// find lover/partner on same map
List<Pawn> partners = targets.Where(x
=> pawn.relations.DirectRelationExists(PawnRelationDefOf.Lover, x)
|| pawn.relations.DirectRelationExists(PawnRelationDefOf.Fiance, x)
|| pawn.relations.DirectRelationExists(PawnRelationDefOf.Spouse, x)
).ToList();
if (RJWSettings.DebugLogJoinInBed) Log.Message($"[RJW] find_pawn_to_fuck({pawnName}): considering {partners.Count} partners");
if (partners.Any())
{
partners.Shuffle(); //Randomize order.
foreach (Pawn target in partners)
{
if (RJWSettings.DebugLogJoinInBed) Log.Message($"[RJW] find_pawn_to_fuck({pawnName}): checking lover {xxx.get_pawnname(target)}");
if (pawn.Position.DistanceToSquared(target.Position) < MaxDistanceSquaredToFuck
&& pawn.CanReserveAndReach(target, PathEndMode.OnCell, Danger.Some, 1, 0)
&& target.CanReserve(pawn, 1, 0)
&& xxx.would_fuck(pawn, target) > 0.1f
&& xxx.would_fuck(target, pawn) > 0.1f)
{
if (RJWSettings.DebugLogJoinInBed) Log.Message($"[RJW] find_pawn_to_fuck({pawnName}): banging lover {xxx.get_pawnname(target)}");
return target;
}
}
}
// No lovers around... see if the pawn fancies a hookup. Nymphos and frustrated pawns always do!
if (RJWSettings.DebugLogJoinInBed) Log.Message($"[RJW] find_pawn_to_fuck({pawnName}): no partners available. checking canHookup");
bool canHookup = pawnIsNympho || pawnCanPickAnyone || xxx.is_frustrated(pawn) || (xxx.is_horny(pawn) && Rand.Value > RJWHookupSettings.HookupChanceForNonNymphos);
if (!canHookup)
{
if (RJWSettings.DebugLogJoinInBed) Log.Message($"[RJW] find_pawn_to_fuck({pawnName}): no hookup today");
return null;
}
// No cheating from casual hookups... would probably make colony relationship management too annoying
if (RJWSettings.DebugLogJoinInBed) Log.Message($"[RJW] find_pawn_to_fuck({pawnName}): checking canHookupWithoutCheating");
bool hookupWouldBeCheating = xxx.HasNonPolyPartnerOnCurrentMap(pawn);
if (hookupWouldBeCheating)
{
if (RJWHookupSettings.NymphosCanCheat && pawnIsNympho && xxx.is_frustrated(pawn))
{
if (RJWSettings.DebugLogJoinInBed) Log.Message($"[RJW] find_pawn_to_fuck({pawnName}): I'm a nympho and I'm so frustrated that I'm going to cheat");
// No return here so they continue searching for hookup
}
else
{
if (RJWSettings.DebugLogJoinInBed) Log.Message($"[RJW] find_pawn_to_fuck({pawnName}): I want to bang but that's cheating");
return null;
}
}
Pawn best_fuckee = FindBestPartner(pawn, targets, pawnCanPickAnyone, pawnIsNympho);
return best_fuckee;
}
/// <summary> Checks all of our potential partners to see if anyone's eligible, returning the most attractive and convenient one. </summary>
protected static Pawn FindBestPartner(Pawn pawn, List<Pawn> targets, bool pawnCanPickAnyone, bool pawnIsNympho)
{
string pawnName = xxx.get_pawnname(pawn);
Pawn best_fuckee = null;
float best_fuckability_score = 0;
foreach (Pawn targetPawn in targets)
{
if (RJWSettings.DebugLogJoinInBed) Log.Message($"[RJW] FindBestPartner({pawnName}): checking hookup {xxx.get_pawnname(targetPawn)}");
// Check to see if the mod settings for hookups allow this pairing
if (!pawnCanPickAnyone && !HookupAllowedViaSettings(pawn, targetPawn))
continue;
// Check for homewrecking (banging a pawn who's in a relationship)
if (!xxx.is_animal(targetPawn) &&
xxx.HasNonPolyPartnerOnCurrentMap(targetPawn))
{
if (RJWHookupSettings.NymphosCanHomewreck && pawnIsNympho && xxx.is_frustrated(pawn))
{
// Hookup allowed... rip colony mood
}
else if (RJWHookupSettings.NymphosCanHomewreckReverse && xxx.is_nympho(targetPawn) && xxx.is_frustrated(targetPawn))
{
// Hookup allowed... rip colony mood
}
else
{
if (RJWSettings.DebugLogJoinInBed) Log.Message($"[RJW] FindBestPartner({pawnName}): not hooking up with {xxx.get_pawnname(targetPawn)} to avoid homewrecking");
continue;
}
}
// If the pawn has had sex recently and isn't horny right now, skip them.
if (!SexUtility.ReadyForLovin(targetPawn) && !xxx.is_horny(targetPawn))
{
if (RJWSettings.DebugLogJoinInBed) Log.Message($"[RJW] FindBestPartner({pawnName}): hookup {xxx.get_pawnname(targetPawn)} isn't ready for lovin'");
continue;
}
if (RJWSettings.DebugLogJoinInBed) Log.Message($"[RJW] FindBestPartner({pawnName}): hookup {xxx.get_pawnname(targetPawn)} is sufficiently single");
if (!xxx.is_animal(targetPawn))
{
float relations = pawn.relations.OpinionOf(targetPawn);
if (relations < RJWHookupSettings.MinimumRelationshipToHookup)
{
if (!(relations > 0 && xxx.is_nympho(pawn)))
{
if (RJWSettings.DebugLogJoinInBed) Log.Message($"[RJW] FindBestPartner({pawnName}): hookup {xxx.get_pawnname(targetPawn)}, i dont like them:({relations})");
continue;
}
}
relations = targetPawn.relations.OpinionOf(pawn);
if (relations < RJWHookupSettings.MinimumRelationshipToHookup)
{
if (!(relations > 0 && xxx.is_nympho(targetPawn)))
{
if (RJWSettings.DebugLogJoinInBed) Log.Message($"[RJW] FindBestPartner({pawnName}): hookup {xxx.get_pawnname(targetPawn)}, dont like me:({relations})");
continue;
}
}
float attraction = pawn.relations.SecondaryRomanceChanceFactor(targetPawn);
if (attraction < RJWHookupSettings.MinimumAttractivenessToHookup)
{
if (!(attraction > 0 && xxx.is_nympho(pawn)))
{
if (RJWSettings.DebugLogJoinInBed) Log.Message($"[RJW] FindBestPartner({pawnName}): hookup {xxx.get_pawnname(targetPawn)}, i dont find them attractive:({attraction})");
continue;
}
}
attraction = targetPawn.relations.SecondaryRomanceChanceFactor(pawn);
if (attraction < RJWHookupSettings.MinimumAttractivenessToHookup)
{
if (!(attraction > 0 && xxx.is_nympho(targetPawn)))
{
if (RJWSettings.DebugLogJoinInBed) Log.Message($"[RJW] FindBestPartner({pawnName}): hookup {xxx.get_pawnname(targetPawn)}, doesnt find me attractive:({attraction})");
continue;
}
}
}
// Check to see if the two pawns are willing to bang, and if so remember how much attractive we find them
float fuckability = 0f;
if (pawn.CanReserveAndReach(targetPawn, PathEndMode.OnCell, Danger.Some, 1, 0) &&
targetPawn.CanReserve(pawn, 1, 0) &&
roll_to_skip(pawn, targetPawn, out fuckability)) // do NOT check pawnIgnoresRules here - these checks, particularly roll_to_skip, are critical
{
int dis = pawn.Position.DistanceToSquared(targetPawn.Position);
if (dis <= 4)
{
// Right next to me (in my bed)? You'll do.
if (RJWSettings.DebugLogJoinInBed) Log.Message($"[RJW] FindBestPartner({pawnName}): hookup {xxx.get_pawnname(targetPawn)} is right next to me. we'll bang, ok?");
best_fuckability_score = 1.0e6f;
best_fuckee = targetPawn;
}
else if (dis > MaxDistanceSquaredToFuck)
{
// too far
if (RJWSettings.DebugLogJoinInBed) Log.Message($"[RJW] FindBestPartner({pawnName}): hookup {xxx.get_pawnname(targetPawn)} is too far... distance:{dis} max:{MaxDistanceSquaredToFuck}");
continue;
}
else
{
// scaling fuckability by distance may give us more varied results and give the less attractive folks a chance
float fuckability_score = fuckability / GenMath.Sqrt(GenMath.Sqrt(dis));
if (RJWSettings.DebugLogJoinInBed) Log.Message($"[RJW] FindBestPartner({pawnName}): hookup {xxx.get_pawnname(targetPawn)} is totally bangable. attraction: {fuckability}, score:{fuckability_score}");
if (fuckability_score > best_fuckability_score)
{
best_fuckee = targetPawn;
best_fuckability_score = fuckability_score;
}
}
}
}
if (best_fuckee == null)
{
if (RJWSettings.DebugLogJoinInBed) Log.Message($"[RJW] FindBestPartner({pawnName}): couldn't find anyone to bang");
}
else
{
if (RJWSettings.DebugLogJoinInBed) Log.Message($"[RJW] FindBestPartner({pawnName}): found rando {xxx.get_pawnname(best_fuckee)} with score {best_fuckability_score}");
}
return best_fuckee;
}
/// <summary> Checks to see if the mod settings allow the two pawns to hookup. </summary>
protected static bool HookupAllowedViaSettings(Pawn pawn, Pawn targetPawn)
{
// Can prisoners hook up?
if (pawn.IsPrisonerOfColony || pawn.IsPrisoner)
{
if (!RJWHookupSettings.PrisonersCanHookupWithNonPrisoner && !(targetPawn.IsPrisonerOfColony || targetPawn.IsPrisoner))
{
if (RJWSettings.DebugLogJoinInBed) Log.Message($"[RJW] find_pawn_to_fuck({xxx.get_pawnname(pawn)}): not hooking up with {xxx.get_pawnname(targetPawn)} due to mod setting PrisonersCanHookupWithNonPrisoner");
return false;
}
if (!RJWHookupSettings.PrisonersCanHookupWithPrisoner && (targetPawn.IsPrisonerOfColony || targetPawn.IsPrisoner))
{
if (RJWSettings.DebugLogJoinInBed) Log.Message($"[RJW] find_pawn_to_fuck({xxx.get_pawnname(pawn)}): not hooking up with {xxx.get_pawnname(targetPawn)} due to mod setting PrisonersCanHookupWithPrisoner");
return false;
}
}
else
{
// Can non prisoners hook up with prisoners?
if (!RJWHookupSettings.CanHookupWithPrisoner && (targetPawn.IsPrisonerOfColony || targetPawn.IsPrisoner))
{
if (RJWSettings.DebugLogJoinInBed) Log.Message($"[RJW] find_pawn_to_fuck({xxx.get_pawnname(pawn)}): not hooking up with {xxx.get_pawnname(targetPawn)} due to mod setting CanHookupWithPrisoner");
return false;
}
}
// Can colonist hook up with visitors?
if (pawn.IsFreeColonist)
{
if (!RJWHookupSettings.ColonistsCanHookupWithVisitor && targetPawn.Faction != Faction.OfPlayer && !targetPawn.IsPrisonerOfColony)
{
if (RJWSettings.DebugLogJoinInBed) Log.Message($"[RJW] find_pawn_to_fuck({xxx.get_pawnname(pawn)}): not hooking up with {xxx.get_pawnname(targetPawn)} due to mod setting ColonistsCanHookupWithVisitor");
return false;
}
}
// Can visitors hook up?
if (pawn.Faction != Faction.OfPlayer && !pawn.IsPrisonerOfColony)
{
// visitors vs colonist
if (!RJWHookupSettings.VisitorsCanHookupWithColonists && targetPawn.IsColonist)
{
if (RJWSettings.DebugLogJoinInBed) Log.Message($"[RJW] find_pawn_to_fuck({xxx.get_pawnname(pawn)}): not hooking up with {xxx.get_pawnname(targetPawn)} due to mod setting VisitorsCanHookupWithColonists");
return false;
}
// visitors vs visitors
if (!RJWHookupSettings.VisitorsCanHookupWithVisitors && targetPawn.Faction != Faction.OfPlayer)
{
if (RJWSettings.DebugLogJoinInBed) Log.Message($"[RJW] find_pawn_to_fuck({xxx.get_pawnname(pawn)}): not hooking up with {xxx.get_pawnname(targetPawn)} due to mod setting VisitorsCanHookupWithVisitors");
return false;
}
}
// TODO: Not sure if this handles all the pawn-on-animal cases.
return true;
}
protected override Job TryGiveJob(Pawn pawn)
{
if (!RJWHookupSettings.HookupsEnabled)
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) Log.Message($"[RJW] 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 (xxx.can_fuck(pawn) || xxx.can_be_fucked(pawn))
{
//--Log.Message(" finding partner");
Pawn partner = find_pawn_to_fuck(pawn, pawn.Map);
//--Log.Message(" checking partner");
if (partner == null)
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 new Job(DefDatabase<JobDef>.GetNamed("JoinInBed"), pawn, partner, bed);
}
}
return null;
}
}
}
|
Mewtopian/rjw
|
Source/JobGivers/JobGiver_JoinInBed.cs
|
C#
|
mit
| 16,055 |
using System.Collections.Generic;
using System.Linq;
using RimWorld;
using Verse;
using Verse.AI;
namespace rjw
{
public class JobGiver_NymphJoinInBed : ThinkNode_JobGiver
{
private static bool roll_to_skip(Pawn nymph, Pawn target)
{
float fuckability = xxx.would_fuck(nymph, target); // 0.0 to 1.0
if (fuckability < 0.1f)
return false;
float chance_to_skip = 0.9f - 0.7f * fuckability;
return Rand.Value < chance_to_skip;
}
private static bool is_healthy(Pawn target)
{
return xxx.is_healthy(target) &&
(xxx.can_fuck(target) || xxx.can_be_fucked(target));
}
public static Pawn find_pawn_to_fuck(Pawn nymph, Map map)
{
Pawn best_fuckee = null;
float best_distance = 1.0e6f;
List<Pawn> valid_targets = new List<Pawn>();
// find lover/partner on same map
IEnumerable<Pawn> targets = map.mapPawns.AllPawnsSpawned.Where(x => x != nymph && x.InBed() && !x.Position.IsForbidden(nymph) && !x.Suspended && !x.Downed && is_healthy(x));
foreach (DirectPawnRelation relation in nymph.relations.DirectRelations)
{
if (relation.def != PawnRelationDefOf.Lover
&& relation.def != PawnRelationDefOf.Spouse
&& relation.def != PawnRelationDefOf.Fiance)
//|| (relation.def != PawnRelationDefOf.Bond && (!xxx.is_animal(relation.otherPawn) || (xxx.is_zoophile(nymph) && RJWSettings.bestiality_enabled))))
continue;
{
//Log.Message("[RJW] find_pawn_to_fuck( " + xxx.get_pawnname(best_fuckee) + " ) Lover/Spouse/Fiance found");
if (nymph.Position.DistanceToSquared(relation.otherPawn.Position) < 60 &&
nymph.CanReserveAndReach(relation.otherPawn, PathEndMode.OnCell, Danger.Some, 1, 0) &&
relation.otherPawn.CanReserve(nymph, 1, 0))
if (targets.Contains(relation.otherPawn))
valid_targets.Add(relation.otherPawn);
//Log.Message("[RJW] find_pawn_to_fuck( " + xxx.get_pawnname(best_fuckee) + " ) Lover/Spouse/Fiance cant be fucked right now");
}
}
if (valid_targets != null && valid_targets.Any())
{
foreach (Pawn q in valid_targets)
{
if (xxx.is_laying_down_alone(q) &&
nymph.CanReserveAndReach(q, PathEndMode.OnCell, Danger.Some, 1, 0) &&
q.CanReserve(nymph, 1, 0) &&
roll_to_skip(nymph, q))
{
int dis = nymph.Position.DistanceToSquared(q.Position);
if (dis < best_distance)
{
best_fuckee = q;
best_distance = dis;
}
}
}
if (best_fuckee != null)
return best_fuckee;
}
targets = targets.Where(x => xxx.is_human(x));
foreach (Pawn q in targets)
{
if (xxx.is_laying_down_alone(q) &&
nymph.CanReserveAndReach(q, PathEndMode.OnCell, Danger.Some, 1, 0) &&
q.CanReserve(nymph, 1, 0) &&
roll_to_skip(nymph, q))
{
int dis = nymph.Position.DistanceToSquared(q.Position);
if (dis < best_distance)
{
best_fuckee = q;
best_distance = dis;
}
}
}
return best_fuckee;
}
protected override Job TryGiveJob(Pawn nymph)
{
//--Log.Message("[RJW] JobGiver_NymphJoinInBed( " + xxx.get_pawnname(nymph) + " ) called");
if ((nymph.CurJob == null || nymph.CurJob.def == JobDefOf.LayDown))
{
//--Log.Message(" checking nympho and abilities");
if ((xxx.can_fuck(nymph) || xxx.can_be_fucked(nymph)))
{
//--Log.Message(" finding partner");
Pawn partner = find_pawn_to_fuck(nymph, nymph.Map);
//--Log.Message(" checking partner");
if (partner == null) return null;
Building_Bed bed;
if (xxx.is_human(partner))
{
// Can never be null, since find checks for bed.
bed = partner.CurrentBed();
// Interrupt current job.
if (nymph.CurJob != null)
nymph.jobs.curDriver.EndJobWith(JobCondition.InterruptForced);
//--Log.Message(" returning job");
return new Job(DefDatabase<JobDef>.GetNamed("NymphJoinInBed"), partner, bed);
}
/*
else if (xxx.is_animal(partner) && xxx.is_zoophile(nymph) && RJWSettings.bestiality_enabled)
{
if (xxx.can_rape(nymph) && Rand.Value < 0.5f)
{
if (nymph.CurJob != null)
nymph.jobs.curDriver.EndJobWith(JobCondition.InterruptForced);
return new Job(xxx.bestiality, partner);
}
//not sure if animal can "wakeup" and go to nymph
bed = nymph.ownership.OwnedBed;
if (!xxx.can_be_fucked(nymph) || bed == null || !partner.CanReach(bed, PathEndMode.OnCell, Danger.Some)) return null;
if (nymph.CurJob != null)
nymph.jobs.curDriver.EndJobWith(JobCondition.InterruptForced);
return new Job(xxx.bestialityForFemale, partner, bed, bed.SleepPosOfAssignedPawn(nymph));
}
*/
}
}
return null;
}
}
}
|
Mewtopian/rjw
|
Source/JobGivers/JobGiver_NymphJoinInBed.cs.bak
|
bak
|
mit
| 4,734 |
using System.Linq;
using RimWorld;
using Verse;
using Verse.AI;
using System.Collections.Generic;
namespace rjw
{
public class JobGiver_RandomRape : ThinkNode_JobGiver
{
public Pawn find_victim(Pawn pawn, Map m)
{
Pawn victim = null;
IEnumerable<Pawn> targets = m.mapPawns.AllPawnsSpawned.Where(x
=> x != pawn
&& xxx.is_not_dying(x)
&& xxx.can_get_raped(x)
&& !x.Suspended
&& !x.IsForbidden(pawn)
&& pawn.CanReserveAndReach(x, PathEndMode.Touch, Danger.Some, xxx.max_rapists_per_prisoner, 0)
&& !x.HostileTo(pawn)
);
float best_fuckability = 0.10f; // Don't rape pawns with <10% fuckability
//Animal rape
if (xxx.is_zoophile(pawn) && RJWSettings.bestiality_enabled)
{
foreach (Pawn target in targets.Where(x => xxx.is_animal(x)))
{
if (!xxx.can_path_to_target(pawn, target.Position))
continue;// too far
float fuc = xxx.would_fuck(pawn, target, true, true);
if (fuc > best_fuckability)
{
best_fuckability = fuc;
victim = target;
}
}
if (victim != null)
return victim;
}
// Humanlike rape - could be prisoner, colonist, or non-hostile outsider
foreach (Pawn target in targets.Where(x => !xxx.is_animal(x)))
{
if (!xxx.can_path_to_target(pawn, target.Position))
continue;// too far
float fuc = xxx.would_fuck(pawn, target, true, true);
if (fuc > best_fuckability)
{
best_fuckability = fuc;
victim = target;
}
}
return victim;
}
protected override Job TryGiveJob(Pawn pawn)
{
//Log.Message("[RJW] JobGiver_RandomRape::TryGiveJob( " + xxx.get_pawnname(pawn) + " ) called");
if (xxx.can_rape(pawn))
{
Pawn victim = find_victim(pawn, pawn.Map);
if (victim != null)
{
//Log.Message("[RJW] JobGiver_RandomRape::TryGiveJob( " + xxx.get_pawnname(pawn) + " ) - found victim " + xxx.get_pawnname(victim));
return new Job(xxx.random_rape, victim);
}
}
return null;
}
}
}
|
Mewtopian/rjw
|
Source/JobGivers/JobGiver_RandomRape.cs
|
C#
|
mit
| 1,993 |
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)
{
//Log.Message("[RJW] JobGiver_RapeEnemy::TryGiveJob( " + xxx.get_pawnname(pawn) + " ) called0");
//Log.Message("[RJW] JobGiver_RapeEnemy::TryGiveJob( " + xxx.get_pawnname(pawn) + " ) 0 " + SexUtility.ReadyForLovin(pawn));
//Log.Message("[RJW] JobGiver_RapeEnemy::TryGiveJob( " + xxx.get_pawnname(pawn) + " ) 1 " + (xxx.need_some_sex(pawn) <= 1f));
//Log.Message("[RJW] JobGiver_RapeEnemy::TryGiveJob( " + xxx.get_pawnname(pawn) + " ) 2 " + !(SexUtility.ReadyForLovin(pawn) || xxx.need_some_sex(pawn) <= 1f));
//Log.Message("[RJW] JobGiver_RapeEnemy::TryGiveJob( " + xxx.get_pawnname(pawn) + " ) 1 " + Find.TickManager.TicksGame);
//Log.Message("[RJW] 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;
//Log.Message("[RJW] 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;
}
}
}
//Log.Message("[RJW] JobGiver_RapeEnemy::ChoosedJobDef( " + xxx.get_pawnname(pawn) + " ) - " + rapeEnemyJobDef.ToString() + " choosed");
Pawn victim = rapeEnemyJobDef?.FindVictim(pawn, pawn.Map);
//Log.Message("[RJW] 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 ? new Job(rapeEnemyJobDef, victim) : null;
/*
else
{
//--Log.Message("[RJW]" + this.GetType().ToString() + "::TryGiveJob( " + xxx.get_pawnname(pawn) + " ) - unable to find victim");
pawn.mindState.canLovinTick = Find.TickManager.TicksGame + Rand.Range(75, 150);
}
*/
//else { //--Log.Message("[RJW] JobGiver_RapeEnemy::TryGiveJob( " + xxx.get_pawnname(pawn) + " ) - too fast to play next"); }
}
}
}
|
Mewtopian/rjw
|
Source/JobGivers/JobGiver_RapeEnemy.cs
|
C#
|
mit
| 3,004 |
using RimWorld;
using Verse;
using Verse.AI;
using System.Collections.Generic;
using System.Linq;
namespace rjw
{
public class JobGiver_ViolateCorpse : ThinkNode_JobGiver
{
public static Corpse find_corpse(Pawn pawn, Map m)
{
//Log.Message("JobGiver_ViolateCorpse::find_corpse( " + xxx.get_pawnname(pawn) + " ) called");
Corpse found = null;
float best_fuckability = 0.1f;
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 (!xxx.can_path_to_target(pawn, target.Position))
continue;// too far
// Filter out rotters if not necrophile.
if (!xxx.is_necrophiliac(pawn) && target.CurRotDrawMode != RotDrawMode.Fresh)
continue;
float fuc = xxx.would_fuck(pawn, target, false, false);
//--Log.Message(" " + xxx.get_pawnname(corpse.Inner) + " = " + fuc + ", best = " + best_fuckability);
if (!(fuc > best_fuckability)) continue;
found = target;
best_fuckability = fuc;
}
return found;
}
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;
//--Log.Message("[RJW] JobGiver_ViolateCorpse::TryGiveJob for ( " + xxx.get_pawnname(pawn) + " )");
if (SexUtility.ReadyForLovin(pawn) || xxx.need_some_sex(pawn) > 1f)
{
//--Log.Message("[RJW] JobGiver_ViolateCorpse::TryGiveJob, can love ");
if (!xxx.can_rape(pawn)) return null;
var target = find_corpse(pawn, pawn.Map);
//--Log.Message("[RJW] JobGiver_ViolateCorpse::TryGiveJob - target is " + (target == null ? "NULL" : "Found"));
if (target != null)
{
return new Job(xxx.violate_corpse, target);
}
// Ticks should only be increased after successful sex.
}
return null;
}
}
}
|
Mewtopian/rjw
|
Source/JobGivers/JobGiver_ViolateCorpse.cs
|
C#
|
mit
| 1,999 |
using System.Collections.Generic;
using System.Linq;
using System;
using Verse;
using RimWorld;
using RimWorld.Planet;
namespace rjw.MainTab
{
public class MainTabWindow_Brothel : MainTabWindow_PawnTable
{
private static PawnTableDef pawnTableDef;
protected override PawnTableDef PawnTableDef => pawnTableDef ?? (pawnTableDef = DefDatabase<PawnTableDef>.GetNamed("Brothel"));
protected override IEnumerable<Pawn> Pawns => Find.CurrentMap.mapPawns.AllPawns.Where(p => p.IsDesignatedService() || p.IsDesignatedComfort());
public override void PostOpen()
{
base.PostOpen();
Find.World.renderer.wantedMode = WorldRenderMode.None;
}
}
}
|
Mewtopian/rjw
|
Source/MainTab/MainTabWindow_Brothel.cs
|
C#
|
mit
| 661 |
using System.Collections.Generic;
using System.Linq;
using System.Text;
using RimWorld;
using RimWorld.Planet;
using UnityEngine;
using Verse;
namespace rjw.MainTab
{
[StaticConstructorOnStartup]
public class PawnColumnWorker_AverageMoneyByWhore : PawnColumnWorker_TextCenter
{
public static readonly RecordDef EarnedMoneyByWhore = DefDatabase<RecordDef>.GetNamed("EarnedMoneyByWhore");
public static readonly RecordDef CountOfWhore = DefDatabase<RecordDef>.GetNamed("CountOfWhore");
protected internal float score;
protected override string GetTextFor(Pawn pawn)
{
float total = pawn.records.GetValue(EarnedMoneyByWhore);
float count = pawn.records.GetValue(CountOfWhore);
if ((int)count == 0)
{
return "-";
}
score = (total / count);
return ((int)score).ToString();
}
public override int Compare(Pawn a, Pawn b)
{
return GetValueToCompare(a).CompareTo(GetValueToCompare(b));
}
private float GetValueToCompare(Pawn pawn)
{
return score;
}
}
}
|
Mewtopian/rjw
|
Source/MainTab/PawnColumnWorker_AverageMoneyByWhore.cs
|
C#
|
mit
| 1,011 |
using System.Collections.Generic;
using System.Linq;
using System.Text;
using RimWorld;
using RimWorld.Planet;
using UnityEngine;
using Verse;
namespace rjw.MainTab
{
[StaticConstructorOnStartup]
public class PawnColumnWorker_CountOfWhore : PawnColumnWorker_TextCenter
{
public static readonly RecordDef CountOfWhore = DefDatabase<RecordDef>.GetNamed("CountOfWhore");
protected internal int score;
protected override string GetTextFor(Pawn pawn)
{
score = pawn.records.GetAsInt(CountOfWhore);
return pawn.records.GetValue(CountOfWhore).ToString();
}
public override int Compare(Pawn a, Pawn b)
{
return GetValueToCompare(a).CompareTo(GetValueToCompare(b));
}
private int GetValueToCompare(Pawn pawn)
{
return score;
}
}
}
|
Mewtopian/rjw
|
Source/MainTab/PawnColumnWorker_CountOfWhore.cs
|
C#
|
mit
| 768 |
using System.Collections.Generic;
using System.Linq;
using System.Text;
using RimWorld;
using RimWorld.Planet;
using UnityEngine;
using Verse;
namespace rjw.MainTab
{
[StaticConstructorOnStartup]
public class PawnColumnWorker_EarnedMoneyByWhore : PawnColumnWorker_TextCenter
{
public static readonly RecordDef EarnedMoneyByWhore = DefDatabase<RecordDef>.GetNamed("EarnedMoneyByWhore");
protected internal int score;
protected override string GetTextFor(Pawn pawn)
{
score = pawn.records.GetAsInt(EarnedMoneyByWhore);
return pawn.records.GetValue(EarnedMoneyByWhore).ToString();
}
public override int Compare(Pawn a, Pawn b)
{
return GetValueToCompare(a).CompareTo(GetValueToCompare(b));
}
private int GetValueToCompare(Pawn pawn)
{
return score;
}
}
}
|
Mewtopian/rjw
|
Source/MainTab/PawnColumnWorker_EarnedMoneyByWhore.cs
|
C#
|
mit
| 798 |
using System.Collections.Generic;
using System.Linq;
using System.Text;
using RimWorld;
using RimWorld.Planet;
using UnityEngine;
using Verse;
namespace rjw.MainTab
{
[StaticConstructorOnStartup]
public class PawnColumnWorker_IsComfortPrisoner : PawnColumnWorker_Icon
{
private static readonly Texture2D comfortOn = ContentFinder<Texture2D>.Get("UI/Tab/ComfortPrisoner_on");
private readonly Texture2D comfortOff = ContentFinder<Texture2D>.Get("UI/Tab/ComfortPrisoner_off");
protected override Texture2D GetIconFor(Pawn pawn)
{
return pawn.IsDesignatedComfort() ? comfortOn : null;
}
}
}
|
Mewtopian/rjw
|
Source/MainTab/PawnColumnWorker_IsComfortPrisoner.cs
|
C#
|
mit
| 609 |
using System.Collections.Generic;
using System.Linq;
using System.Text;
using RimWorld;
using RimWorld.Planet;
using UnityEngine;
using Verse;
namespace rjw.MainTab
{
[StaticConstructorOnStartup]
public class PawnColumnWorker_IsWhore : PawnColumnWorker_Icon
{
private static readonly Texture2D serviceOn = ContentFinder<Texture2D>.Get("UI/Tab/Service_on");
private static readonly Texture2D serviceOff = ContentFinder<Texture2D>.Get("UI/Tab/Service_off");
protected override Texture2D GetIconFor(Pawn pawn)
{
return pawn.IsDesignatedService() ? serviceOn : null;
}
}
}
|
Mewtopian/rjw
|
Source/MainTab/PawnColumnWorker_IsWhore.cs
|
C#
|
mit
| 591 |
using System.Collections.Generic;
using System.Linq;
using System.Text;
using RimWorld;
using RimWorld.Planet;
using UnityEngine;
using Verse;
namespace rjw.MainTab
{
[StaticConstructorOnStartup]
public class PawnColumnWorker_Mood : PawnColumnWorker_TextCenter
{
protected internal float score;
protected override string GetTextFor(Pawn pawn)
{
score = pawn.needs.mood.CurLevelPercentage;
return score.ToStringPercent();
}
public override int Compare(Pawn a, Pawn b)
{
return GetValueToCompare(a).CompareTo(GetValueToCompare(b));
}
private float GetValueToCompare(Pawn pawn)
{
return score;
}
}
}
|
Mewtopian/rjw
|
Source/MainTab/PawnColumnWorker_Mood.cs
|
C#
|
mit
| 640 |
using System.Collections.Generic;
using System.Linq;
using System.Text;
using RimWorld;
using RimWorld.Planet;
using UnityEngine;
using Verse;
namespace rjw.MainTab
{
[StaticConstructorOnStartup]
public class PawnColumnWorker_PriceRangeOfWhore : PawnColumnWorker_TextCenter
{
protected internal int min;
protected internal int max;
protected override string GetTextFor(Pawn pawn)
{
min = WhoringHelper.WhoreMinPrice(pawn);
max = WhoringHelper.WhoreMaxPrice(pawn);
return string.Format("{0} - {1}", min, max);
}
public override int Compare(Pawn a, Pawn b)
{
return GetValueToCompare(a).CompareTo(GetValueToCompare(b));
}
private int GetValueToCompare(Pawn pawn)
{
return min;
}
}
}
|
Mewtopian/rjw
|
Source/MainTab/PawnColumnWorker_PriceRangeOfWhore.cs
|
C#
|
mit
| 729 |
using System.Collections.Generic;
using System.Linq;
using System.Text;
using RimWorld;
using RimWorld.Planet;
using UnityEngine;
using Verse;
namespace rjw.MainTab
{
[StaticConstructorOnStartup]
public class PawnColumnWorker_RoomAdjustmentOfWhore : PawnColumnWorker_TextCenter
{
protected internal float score;
protected override string GetTextFor(Pawn pawn)
{
score = WhoringHelper.WhoreRoomAdjustment(pawn);
Room ownedRoom = pawn.ownership.OwnedRoom;
int scoreStageIndex;
if (ownedRoom == null)
{
scoreStageIndex = 0;
}
else
{
scoreStageIndex = RoomStatDefOf.Impressiveness.GetScoreStageIndex(ownedRoom.GetStat(RoomStatDefOf.Impressiveness));
}
return string.Format("{0} -> {1}", scoreStageIndex, score.ToStringPercent());
}
public override int Compare(Pawn a, Pawn b)
{
return GetValueToCompare(a).CompareTo(GetValueToCompare(b));
}
private float GetValueToCompare(Pawn pawn)
{
return score;
}
}
}
|
Mewtopian/rjw
|
Source/MainTab/PawnColumnWorker_RoomAdjustmentOfWhore.cs
|
C#
|
mit
| 978 |
using System.Collections.Generic;
using System.Linq;
using System.Text;
using RimWorld;
using RimWorld.Planet;
using UnityEngine;
using Verse;
namespace rjw.MainTab
{
public abstract class PawnColumnWorker_TextCenter : PawnColumnWorker_Text
{
public override void DoCell(Rect rect, Pawn pawn, PawnTable table)
{
Rect rect2 = new Rect(rect.x, rect.y, rect.width, Mathf.Min(rect.height, 30f));
string textFor = GetTextFor(pawn);
if (textFor != null)
{
Text.Font = GameFont.Small;
Text.Anchor = TextAnchor.MiddleCenter;
Text.WordWrap = false;
Widgets.Label(rect2, textFor);
Text.WordWrap = true;
Text.Anchor = TextAnchor.UpperLeft;
string tip = GetTip(pawn);
if (!tip.NullOrEmpty())
{
TooltipHandler.TipRegion(rect2, tip);
}
}
}
}
}
|
Mewtopian/rjw
|
Source/MainTab/PawnColumnWorker_TextCenter.cs
|
C#
|
mit
| 803 |
using System;
using System.Collections.Generic;
using System.Linq;
using RimWorld;
using Verse;
namespace rjw.MainTab
{
public class PawnTable_Whores : PawnTable
{
public PawnTable_Whores(PawnTableDef def, Func<IEnumerable<Pawn>> pawnsGetter, int uiWidth, int uiHeight) : base(def, pawnsGetter, uiWidth, uiHeight) { }
protected override IEnumerable<Pawn> LabelSortFunction(IEnumerable<Pawn> input)
{
return input.OrderBy(p => p.Name?.Numerical != false).ThenBy(p => (p.Name as NameSingle)?.Number ?? 0).ThenBy(p => p.def.label);
}
protected override IEnumerable<Pawn> PrimarySortFunction(IEnumerable<Pawn> input)
{
return input.OrderByDescending(p => p.Faction.Name);
}
}
}
|
Mewtopian/rjw
|
Source/MainTab/PawnTable_Whores.cs
|
C#
|
mit
| 702 |
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;
}
}
}
|
Mewtopian/rjw
|
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.need_some_sex(pawn) < 2f)
{
this.RecoverFromState();
return;
}
}
base.MentalStateTick();
}
}
public class SexualMentalStateWorker : MentalStateWorker
{
public override bool StateCanOccur(Pawn pawn)
{
SexualMentalStateDef d = this.def as SexualMentalStateDef;
if (d == null)
{
return base.StateCanOccur(pawn);
}
else
{
return base.StateCanOccur(pawn) &&
(!d.requireCanFuck || xxx.can_fuck(pawn)) &&
(!d.requireCanBeFuck || xxx.can_be_fucked(pawn)) &&
(!d.requireCanRape || xxx.can_rape(pawn)) &&
(!d.requireCanGetRaped || xxx.can_get_raped(pawn) );
}
}
}
public class SexualMentalBreakWorker : MentalBreakWorker
{
public override float CommonalityFor(Pawn pawn)
{
SexualMentalBreakDef d = this.def as SexualMentalBreakDef;
if (d == null)
{
return base.CommonalityFor(pawn);
}
else
{
var need_sex = pawn.needs.TryGetNeed<Need_Sex>();
return base.CommonalityFor(pawn) * d.commonalityMultiplierBySexNeed.Evaluate(need_sex.CurLevelPercentage*100f);
}
}
}
public class SexualMentalStateDef : MentalStateDef
{
public bool requireCanFuck = false;
public bool requireCanBeFuck = false;
public bool requireCanRape = false;
public bool requireCanGetRaped = false;
}
public class SexualMentalBreakDef : MentalBreakDef
{
public SimpleCurve commonalityMultiplierBySexNeed;
}
}
|
Mewtopian/rjw
|
Source/MentalStates/SexualMentalState.cs
|
C#
|
mit
| 1,712 |
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
return pawn.health.hediffSet.hediffs.Any(hed =>
hed.def == Genital_Helper.archotech_penis
);
}
public static bool AndroidVaginaFertility(Pawn pawn)
{
//androids only fertile with archotech parts
return pawn.health.hediffSet.hediffs.Any(hed =>
hed.def == Genital_Helper.archotech_vagina
);
}
}
}
|
Mewtopian/rjw
|
Source/Modules/Androids/AndroidsCompatibility.cs
|
C#
|
mit
| 2,048 |
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 + " 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))
yield return this.make_option(FloatMenuOptionLabel + " on " + xxx.get_pawnname(other), pawn, other, other.IsPrisonerOfColony ? WorkTypeDefOf.Warden : null);
}
}
}
}
|
Mewtopian/rjw
|
Source/Modules/Bondage/Comps/CompBondageGear.cs
|
C#
|
mit
| 1,014 |
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);
}
}
}
|
Mewtopian/rjw
|
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);
}
}
}
|
Mewtopian/rjw
|
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);
}
}
}
|
Mewtopian/rjw
|
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 + " on " + ((other == null) ? "self" : xxx.get_pawnname(other));
}
public override IEnumerable<FloatMenuOption> CompFloatMenuOptions(Pawn pawn)
{
if (!pawn.CanReserve(parent))
yield return new FloatMenuOption(FloatMenuOptionLabel + " (" + "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);
}
}
}
}
}
}
|
Mewtopian/rjw
|
Source/Modules/Bondage/Comps/CompStampedApparelKey.cs
|
C#
|
mit
| 1,892 |
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);
}
}
}
|
Mewtopian/rjw
|
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
};
}
}
}
|
Mewtopian/rjw
|
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
{
Log.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
Log.Error("Unable to get CompUseEffect for use of " + effective_item.Label + " on " + xxx.get_pawnname(other) + " by " + xxx.get_pawnname(pawn));
}
},
defaultCompleteMode = ToilCompleteMode.Instant
};
}
}
}
}
|
Mewtopian/rjw
|
Source/Modules/Bondage/JobDrivers/JobDriver_UseItemOn.cs
|
C#
|
mit
| 3,165 |
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);
}
}
}
|
Mewtopian/rjw
|
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);
}
}
}
}
|
Mewtopian/rjw
|
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;
}
}
}
|
Mewtopian/rjw
|
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 = new Job(((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.story.WorkTypeIsDisabled(required_work))
{
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_genitals = 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
{
public override float GetSpecialApparelScoreOffset()
{
return (Wearer == null) ? -1e5f : 1e5f;
}
// made this method universal for any bondage_gear, won't affect anything if gear's BoundBodyPartGroupDefs is empty or null
public override bool AllowVerbCast(IntVec3 root, Map map, LocalTargetInfo targ, 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)
{
Log.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
{
Log.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
{
Log.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;
}
}
|
Mewtopian/rjw
|
Source/Modules/Bondage/bondage_gear.cs
|
C#
|
mit
| 13,121 |
using RimWorld;
using Verse;
namespace rjw
{
public class CompMilkableHuman : CompHasGatherableBodyResource
{
protected override int GatherResourcesIntervalDays => Props.milkIntervalDays;
protected override int ResourceAmount => Props.milkAmount;
protected override ThingDef ResourceDef => Props.milkDef;
protected override string SaveKey => "milkFullness";
public CompProperties_MilkableHuman Props => (CompProperties_MilkableHuman)props;
protected override bool Active
{
get
{
if (!Active)
{
return false;
}
Pawn pawn = parent as Pawn;
if (pawn != null)
{
//idk should probably remove non rjw stuff
//should merge Lactating into .cs hediff?
//vanilla
//C&P?
//rjw human
//rjw animal
if ((!pawn.health.hediffSet.HasHediff(HediffDef.Named("RJW_lactating"), false))
&& ((pawn.health.hediffSet.HasHediff(HediffDef.Named("Pregnant"), false) && pawn.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("Pregnant"), false).Visible)
//|| (pawn.health.hediffSet.HasHediff(HediffDef.Named("HumanPregnancy"), false) && pawn.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("HumanPregnancy"), false).Visible)
|| (pawn.health.hediffSet.HasHediff(HediffDef.Named("RJW_pregnancy"), false) && pawn.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("RJW_pregnancy"), false).Visible)
|| (pawn.health.hediffSet.HasHediff(HediffDef.Named("RJW_pregnancy_beast"), false) && pawn.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("RJW_pregnancy_beast"), false).Visible)))
{
pawn.health.AddHediff(HediffDef.Named("RJW_lactating"), null, null, null);
}
if ((!Props.milkFemaleOnly || pawn.gender == Gender.Female)
&& (pawn.ageTracker.CurLifeStage.reproductive)
&& (pawn.RaceProps.Humanlike)
&& (pawn.health.hediffSet.HasHediff(HediffDef.Named("RJW_lactating"), false)
//|| pawn.health.hediffSet.HasHediff(HediffDef.Named("Lactating_Permanent"), false)
//|| pawn.health.hediffSet.HasHediff(HediffDef.Named("Lactating_Natural"), false)
//|| pawn.health.hediffSet.HasHediff(HediffDef.Named("Lactating_Drug"), false)
))
{
return true;
}
}
return false;
}
}
public override string CompInspectStringExtra()
{
if (!Active)
{
return null;
}
return Translator.Translate("MilkFullness") + ": " + GenText.ToStringPercent(this.Fullness);
}
}
}
|
Mewtopian/rjw
|
Source/Modules/Milking/Comps/CompMilkableHuman.cs
|
C#
|
mit
| 2,444 |
using Verse;
namespace rjw
{
public class CompProperties_MilkableHuman : CompProperties
{
public int milkIntervalDays;
public int milkAmount = 8;
public ThingDef milkDef;
public bool milkFemaleOnly = true;
public CompProperties_MilkableHuman()
{
compClass = typeof(CompMilkableHuman);
}
}
}
|
Mewtopian/rjw
|
Source/Modules/Milking/Comps/CompProperties_MilkableHuman.cs
|
C#
|
mit
| 316 |
using RimWorld;
using Verse;
namespace rjw
{
[DefOf]
public static class JobDefOfZ
{
public static JobDef MilkHuman;
static JobDefOfZ()
{
DefOfHelper.EnsureInitializedInCtor(typeof(JobDefOf));
}
}
}
|
Mewtopian/rjw
|
Source/Modules/Milking/JobDrivers/JobDefOfZ.cs
|
C#
|
mit
| 216 |
using RimWorld;
using System;
using System.Collections.Generic;
using Verse;
using Verse.AI;
namespace rjw
{
public abstract class JobDriver_GatherHumanBodyResources : JobDriver_GatherAnimalBodyResources
{
private float gatherProgress;
/*
//maybe change?
protected abstract int GatherResourcesIntervalDays
{
get;
}
//add breastsize modifier?
protected abstract int ResourceAmount
{
get;
}
//add more milks?
protected abstract ThingDef ResourceDef
{
get;
}
*/
protected override IEnumerable<Toil> MakeNewToils()
{
ToilFailConditions.FailOnDespawnedNullOrForbidden<JobDriver_GatherHumanBodyResources>(this, TargetIndex.A);
ToilFailConditions.FailOnNotCasualInterruptible<JobDriver_GatherHumanBodyResources>(this, TargetIndex.A);
yield return Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.Touch);
Toil wait = new Toil();
wait.initAction = delegate
{
Pawn milker = base.pawn;
LocalTargetInfo target = base.job.GetTarget(TargetIndex.A);
Pawn target2 = (Pawn)target.Thing;
milker.pather.StopDead();
PawnUtility.ForceWait(target2, 15000, null, true);
};
wait.tickAction = delegate
{
Pawn milker = base.pawn;
milker.skills.Learn(SkillDefOf.Animals, 0.13f, false);
gatherProgress += StatExtension.GetStatValue(milker, StatDefOf.AnimalGatherSpeed, true);
if (gatherProgress >= WorkTotal)
{
GetComp((Pawn)base.job.GetTarget(TargetIndex.A)).Gathered(base.pawn);
milker.jobs.EndCurrentJob(JobCondition.Succeeded, true);
}
};
wait.AddFinishAction((Action)delegate
{
Pawn milker = base.pawn;
LocalTargetInfo target = base.job.GetTarget(TargetIndex.A);
Pawn target2 = (Pawn)target.Thing;
if (target2 != null && target2.CurJobDef == JobDefOf.Wait_MaintainPosture)
{
milker.jobs.EndCurrentJob(JobCondition.InterruptForced, true);
}
});
ToilFailConditions.FailOnDespawnedOrNull<Toil>(wait, TargetIndex.A);
ToilFailConditions.FailOnCannotTouch<Toil>(wait, TargetIndex.A, PathEndMode.Touch);
wait.AddEndCondition((Func<JobCondition>)delegate
{
if (GetComp((Pawn)base.job.GetTarget(TargetIndex.A)).ActiveAndFull)
{
return JobCondition.Ongoing;
}
return JobCondition.Incompletable;
});
wait.defaultCompleteMode = ToilCompleteMode.Never;
ToilEffects.WithProgressBar(wait, TargetIndex.A, (Func<float>)(() => gatherProgress / WorkTotal), false, -0.5f);
wait.activeSkill = (() => SkillDefOf.Animals);
yield return wait;
}
}
}
|
Mewtopian/rjw
|
Source/Modules/Milking/JobDrivers/JobDriver_GatherHumanBodyResources.cs
|
C#
|
mit
| 2,524 |
using RimWorld;
using Verse;
namespace rjw
{
public class JobDriver_MilkHuman : JobDriver_GatherHumanBodyResources
{
protected override float WorkTotal => 400f;
protected override CompHasGatherableBodyResource GetComp(Pawn animal)
{
return ThingCompUtility.TryGetComp<CompMilkableHuman>(animal);
}
}
}
|
Mewtopian/rjw
|
Source/Modules/Milking/JobDrivers/JobDriver_MilkHuman.cs
|
C#
|
mit
| 318 |
using RimWorld;
using System.Collections.Generic;
using Verse;
using Verse.AI;
namespace rjw
{
public abstract class WorkGiver_GatherHumanBodyResources : WorkGiver_GatherAnimalBodyResources
{
public override IEnumerable<Thing> PotentialWorkThingsGlobal(Pawn pawn)
{
//List<Pawn> pawns = pawn.Map.mapPawns.SpawnedPawnsInFaction(pawn.Faction);
//int i = 0;
//if (i < pawns.Count)
//{
// yield return (Thing)pawns[i];
/*Error: Unable to find new state assignment for yield return*/
// ;
//}
foreach (Pawn targetpawn in pawn.Map.mapPawns.FreeColonistsAndPrisonersSpawned)
{
yield return targetpawn;
}
}
public override bool HasJobOnThing(Pawn pawn, Thing t, bool forced = false)
{
Pawn pawn2 = t as Pawn;
if (pawn2 == null || !pawn2.RaceProps.Humanlike)
{
return false;
}
CompHasGatherableBodyResource comp = GetComp(pawn2);
if (comp != null && comp.ActiveAndFull && PawnUtility.CanCasuallyInteractNow(pawn2, false) && pawn2 != pawn)
{
LocalTargetInfo target = pawn2;
bool ignoreOtherReservations = forced;
if (ReservationUtility.CanReserve(pawn, target, 1, -1, null, ignoreOtherReservations))
{
return true;
}
}
return false;
}
}
}
|
Mewtopian/rjw
|
Source/Modules/Milking/WorkGivers/WorkGiver_GatherHumanBodyResources.cs
|
C#
|
mit
| 1,240 |
using RimWorld;
using Verse;
namespace rjw
{
public class WorkGiver_MilkHuman : WorkGiver_GatherHumanBodyResources
{
protected override JobDef JobDef => JobDefOfZ.MilkHuman;
protected override CompHasGatherableBodyResource GetComp(Pawn animal)
{
return ThingCompUtility.TryGetComp<CompMilkableHuman>(animal);
}
}
}
|
Mewtopian/rjw
|
Source/Modules/Milking/WorkGivers/WorkGiver_MilkHuman.cs
|
C#
|
mit
| 331 |
using Verse;
using RimWorld;
using Multiplayer.API;
namespace rjw
{
[StaticConstructorOnStartup]
public static class RJW_Multiplayer
{
static RJW_Multiplayer()
{
if (!MP.enabled) return;
// This is where the magic happens and your attributes
// auto register, similar to Harmony's PatchAll.
MP.RegisterAll();
/*
Log.Message("RJW MP compat testing");
var type = AccessTools.TypeByName("rjw.RJWdesignations");
//Log.Message("rjw MP compat " + type.Name);
Log.Message("is host " + MP.IsHosting);
Log.Message("PlayerName " + MP.PlayerName);
Log.Message("IsInMultiplayer " + MP.IsInMultiplayer);
//MP.RegisterSyncMethod(type, "Comfort");
/*
MP.RegisterSyncMethod(type, "<GetGizmos>Service");
MP.RegisterSyncMethod(type, "<GetGizmos>BreedingHuman");
MP.RegisterSyncMethod(type, "<GetGizmos>BreedingAnimal");
MP.RegisterSyncMethod(type, "<GetGizmos>Breeder");
MP.RegisterSyncMethod(type, "<GetGizmos>Milking");
MP.RegisterSyncMethod(type, "<GetGizmos>Hero");
*/
// You can choose to not auto register and do it manually
// with the MP.Register* methods.
// Use MP.IsInMultiplayer to act upon it in other places
// user can have it enabled and not be in session
}
//generate PredictableSeed for Verse.Rand
public static int PredictableSeed()
{
int seed = 0;
try
{
Map map = Find.CurrentMap;
//int seedHourOfDay = GenLocalDate.HourOfDay(map);
//int seedDayOfYear = GenLocalDate.DayOfYear(map);
//int seedYear = GenLocalDate.Year(map);
seed = (GenLocalDate.HourOfDay(map) + GenLocalDate.DayOfYear(map)) * GenLocalDate.Year(map);
//int seed = (seedHourOfDay + seedDayOfYear) * seedYear;
//Log.Warning("seedHourOfDay: " + seedHourOfDay + "\nseedDayOfYear: " + seedDayOfYear + "\nseedYear: " + seedYear + "\n" + seed);
}
catch
{
seed = Rand.Int;
}
return seed;
}
}
}
|
Mewtopian/rjw
|
Source/Modules/Multiplayer/Multiplayer.cs
|
C#
|
mit
| 1,923 |
using System.Linq;
using RimWorld;
using Verse;
using Multiplayer.API;
namespace rjw
{
public class IncidentWorker_NymphJoins : IncidentWorker
{
protected override bool CanFireNowSub(IncidentParms parms)
{
if (!RJWSettings.nymphos) return false;
Map map = (Map)parms.target;
float colonist_count = map.mapPawns.FreeColonistsCount;
float nymph_count = map.mapPawns.FreeColonists.Count(xxx.is_nympho);
float nymph_fraction = nymph_count / colonist_count;
return colonist_count >= 1 && (nymph_fraction < xxx.config.max_nymph_fraction);
}
[SyncMethod]
protected override bool TryExecuteWorker(IncidentParms parms)
{
//--Log.Message("IncidentWorker_NymphJoins::TryExecute() called");
if (!RJWSettings.nymphos) return false;
Map map = (Map) parms.target;
if (map == null)
{
//--Log.Message("IncidentWorker_NymphJoins::TryExecute() - map is null, abort!");
return false;
}
else
{
//--Log.Message("IncidentWorker_NymphJoins::TryExecute() - map is ok");
}
//Rand.PopState();
//Rand.PushState(RJW_Multiplayer.PredictableSeed());
if (!RCellFinder.TryFindRandomPawnEntryCell(out IntVec3 loc, map, CellFinder.EdgeRoadChance_Friendly + 0.2f))
{
//--Log.Message("IncidentWorker_NymphJoins::TryExecute() - no entry, abort!");
return false;
}
Pawn pawn = nymph_generator.spawn_nymph(loc, ref map, Faction.OfPlayer);
Find.LetterStack.ReceiveLetter("Nymph Joins", "A wandering nymph has decided to join your colony.",
LetterDefOf.PositiveEvent, pawn);
return true;
}
}
}
|
Mewtopian/rjw
|
Source/Modules/Nymphs/Incidents/IncidentWorker_NymphJoins.cs
|
C#
|
mit
| 1,569 |
using RimWorld;
using Verse;
using Multiplayer.API;
namespace rjw
{
public class IncidentWorker_NymphVisitorGroup : IncidentWorker_NeutralGroup
{
private static readonly SimpleCurve PointsCurve = new SimpleCurve
{
new CurvePoint(45f, 0f),
new CurvePoint(50f, 1f),
new CurvePoint(100f, 1f),
new CurvePoint(200f, 0.25f),
new CurvePoint(300f, 0.1f),
new CurvePoint(500f, 0f)
};
protected override void ResolveParmsPoints(IncidentParms parms)
{
if (!(parms.points >= 0f))
{
parms.points = Rand.ByCurve(PointsCurve);
}
}
[SyncMethod]
protected override bool TryExecuteWorker(IncidentParms parms)
{
//--Log.Message("IncidentWorker_NymphVisitorGroup::TryExecute() called");
if (!RJWSettings.nymphos)
{
return false;
}
Map map = (Map)parms.target;
if (map == null)
{
//--Log.Message("IncidentWorker_NymphJoins::TryExecute() - map is null, abort!");
return false;
}
else
{
//--Log.Message("IncidentWorker_NymphJoins::TryExecute() - map is ok");
}
//Rand.PopState();
//Rand.PushState(RJW_Multiplayer.PredictableSeed());
if (!RCellFinder.TryFindRandomPawnEntryCell(out IntVec3 loc, map, CellFinder.EdgeRoadChance_Friendly + 0.2f))
{
//--Log.Message("IncidentWorker_NymphJoins::TryExecute() - no entry, abort!");
return false;
}
Pawn pawn = nymph_generator.spawn_nymph(loc, ref map);
Find.LetterStack.ReceiveLetter("Nymph wanders in", "A wandering nymph has decided to visit your colony.", LetterDefOf.NeutralEvent, pawn);
return true;
}
}
}
|
Mewtopian/rjw
|
Source/Modules/Nymphs/Incidents/IncidentWorker_NymphVisitorGroup.cs
|
C#
|
mit
| 1,574 |
using System;
using RimWorld;
using Verse;
namespace rjw
{
public class IncidentWorker_TestInc : IncidentWorker
{
public static void list_backstories()
{
foreach (var bs in BackstoryDatabase.allBackstories.Values)
Log.Message("Backstory \"" + bs.title + "\" has identifier \"" + bs.identifier + "\"");
}
public static void inject_designator()
{
//var des = new Designator_ComfortPrisoner();
//Find.ReverseDesignatorDatabase.AllDesignators.Add(des);
//Find.ReverseDesignatorDatabase.AllDesignators.Add(new Designator_Breed());
}
public static void spawn_nymphs(Map m)
{
IntVec3 loc;
if (!CellFinder.TryFindRandomEdgeCellWith(m.reachability.CanReachColony, m, 1.0f, out loc)) // TODO fix ROADCHANCE
return;
for (int i = 1; i <= 10; ++i)
nymph_generator.spawn_nymph(loc, ref m);
//Find.LetterStack.ReceiveLetter("Nymphs!", "A whole group of nymphs has wandered into your colony.", LetterDefOf.BadNonUrgent, null);
Find.LetterStack.ReceiveLetter("Nymphs!", "A whole group of nymphs has wandered into your colony.", LetterDefOf.NegativeEvent, null);
}
// Applies permanent damage to a randomly chosen colonist, to test that this works
public static void damage_virally(Map m)
{
var vir_dam = DefDatabase<DamageDef>.GetNamed("ViralDamage");
var p = m.mapPawns.FreeColonists.RandomElement();
var lun = p.RaceProps.body.AllParts.Find((BodyPartRecord bpr) => String.Equals(bpr.def.defName, "LeftLung"));
var dam_def = HealthUtility.GetHediffDefFromDamage(vir_dam, p, lun);
var inj = (Hediff_Injury)HediffMaker.MakeHediff(dam_def, p, null);
inj.Severity = 2.0f;
inj.TryGetComp<HediffComp_GetsPermanent>().IsPermanent = true;
p.health.AddHediff(inj, lun, null);
}
// Gives all colonists on the map a severe syphilis or HIV infection
public static void infect_the_colonists(Map m)
{
foreach (var p in m.mapPawns.FreeColonists)
{
if (Rand.Value < 0.50f)
std_spreader.infect(p, std.syphilis);
// var std_hed_def = (Rand.Value < 0.50f) ? std.syphilis.hediff_def : std.hiv.hediff_def;
// p.health.AddHediff (std_hed_def);
// p.health.hediffSet.GetFirstHediffOfDef (std_hed_def).Severity = Rand.Range (0.50f, 0.90f);
}
}
// Reduces the sex need of the selected pawn
public static void reduce_sex_need_on_select(Map m)
{
Pawn pawn = Find.Selector.SingleSelectedThing as Pawn;
if (pawn != null)
{
if (pawn.needs.TryGetNeed<Need_Sex>() != null)
{
//--Log.Message("[RJW]TestInc::reduce_sex_need_on_select is called");
pawn.needs.TryGetNeed<Need_Sex>().CurLevel -= 0.5f;
}
}
}
protected override bool TryExecuteWorker(IncidentParms parms)
{
var m = (Map)parms.target;
// list_backstories ();
// inject_designator ();
// spawn_nymphs (m);
// damage_virally (m);
//infect_the_colonists(m);
reduce_sex_need_on_select(m);
return true;
}
}
}
|
Mewtopian/rjw
|
Source/Modules/Nymphs/Incidents/IncidentWorker_TestInc.cs
|
C#
|
mit
| 2,929 |
using RimWorld;
using UnityEngine;
using Verse;
namespace rjw
{
public class IncidentWorker_TestInc2 : IncidentWorker
{
// Testing the mechanism of some build-in functions
public static void test_funcion()
{
float a = Mathf.InverseLerp(0, 2, 3); //gives 1
float b = Mathf.InverseLerp(0.2f, 2, 0.1f); //gives 0
float c = Mathf.InverseLerp(2f, 1, 2.5f); //gives 0
//--Log.Message("[RJW]TestInc2::test_function is called - value a is " + a);
//--Log.Message("[RJW]TestInc2::test_function is called - value b is " + b);
//--Log.Message("[RJW]TestInc2::test_function is called - value c is " + c);
}
// Gives the wanted information of the selected thing
public static void info_on_select(Map m)
{
Pawn p = Find.Selector.SingleSelectedThing as Pawn;
if (p != null)
{
//--Log.Message("[RJW]TestInc2::info_on_select is called");
foreach (var q in m.mapPawns.AllPawns)
{
xxx.would_fuck(p, q, true);
}
}
}
protected override bool TryExecuteWorker(IncidentParms parms)
{
var m = (Map)parms.target;
info_on_select(m);
return true;
}
}
}
|
Mewtopian/rjw
|
Source/Modules/Nymphs/Incidents/IncidentWorker_TestInc2.cs
|
C#
|
mit
| 1,153 |
using System.Collections.Generic;
using RimWorld;
using Verse;
using Multiplayer.API;
namespace rjw
{
public struct nymph_story
{
public Backstory child;
public Backstory adult;
public List<Trait> traits;
}
public struct nymph_passion_chances
{
public float major;
public float minor;
public nymph_passion_chances(float maj, float min)
{
major = maj;
minor = min;
}
}
public static class nymph_backstories
{
public struct child
{
public static Backstory vatgrown_sex_slave;
};
public struct adult
{
public static Backstory feisty;
public static Backstory curious;
public static Backstory tender;
public static Backstory chatty;
public static Backstory broken;
};
public static void init()
{
{
Backstory bs = new Backstory();
bs.identifier = ""; // identifier will be set by ResolveReferences
MiscTranslationDef MTdef = DefDatabase<MiscTranslationDef>.GetNamedSilentFail("rjw_vatgrown_sex_slave");
if (MTdef != null)
{
bs.SetTitle(MTdef.label, MTdef.label);
bs.SetTitleShort(MTdef.stringA, MTdef.stringA);
bs.baseDesc = MTdef.description;
}
else
{
bs.SetTitle("Vat-Grown Sex Slave", "Vat-Grown Sex Slave");
bs.SetTitleShort("SexSlave", "SexSlave");
bs.baseDesc = "NAME is made as a sex machine, rather than a human.During HIS growing period in the factory, HE was taught plenty of social skills and sex skills, just to satisfy various sex demands.";
}
// bs.skillGains = new Dictionary<string, int> ();
bs.skillGainsResolved.Add(DefDatabase<SkillDef>.GetNamed("Social"), 8);
// bs.skillGainsResolved = new Dictionary<SkillDef, int> (); // populated by ResolveReferences
bs.workDisables = WorkTags.Intellectual;
bs.requiredWorkTags = WorkTags.None;
bs.slot = BackstorySlot.Childhood;
bs.spawnCategories = new List<string>() { "rjw_nymphsCategory", "Slave" }; // Not necessary (I Think)
Unprivater.SetProtectedValue("bodyTypeGlobal", bs, "Thin");
Unprivater.SetProtectedValue("bodyTypeFemale", bs, "Thin");
Unprivater.SetProtectedValue("bodyTypeMale", bs, "Thin");
Unprivater.SetProtectedValue("bodyTypeGlobalResolved", bs, BodyTypeDefOf.Thin);
Unprivater.SetProtectedValue("bodyTypeFemaleResolved", bs, BodyTypeDefOf.Thin);
Unprivater.SetProtectedValue("bodyTypeMaleResolved", bs, BodyTypeDefOf.Thin);
//bs.bodyTypeFemale = BodyType.Female;
//bs.bodyTypeMale = BodyType.Thin;
bs.forcedTraits = new List<TraitEntry>();
bs.forcedTraits.Add(new TraitEntry(xxx.nymphomaniac, 0));
bs.disallowedTraits = new List<TraitEntry>();
bs.disallowedTraits.Add(new TraitEntry(TraitDefOf.DislikesMen, 0));
bs.disallowedTraits.Add(new TraitEntry(TraitDefOf.DislikesWomen, 0));
bs.disallowedTraits.Add(new TraitEntry(TraitDefOf.TooSmart, 0));
bs.shuffleable = true;
bs.ResolveReferences();
BackstoryDatabase.AddBackstory(bs);
child.vatgrown_sex_slave = bs;
//--Log.Message("[RJW]nymph_backstories::init() succeed0");
}
{
Backstory bs = new Backstory();
bs.identifier = "";
MiscTranslationDef MTdef = DefDatabase<MiscTranslationDef>.GetNamedSilentFail("rjw_feisty");
if (MTdef != null)
{
bs.SetTitle(MTdef.label, MTdef.label);
bs.SetTitleShort(MTdef.stringA, MTdef.stringA);
bs.baseDesc = MTdef.description;
}
else
{
bs.SetTitle("Feisty Nymph", "Feisty Nymph");
bs.SetTitleShort("Nymph", "Nymph");
bs.baseDesc = "NAME struts around the colony like a conqueror examining a newly annexed territory. You try to focus on your work but HE won't let you.";
}
bs.skillGainsResolved.Add(DefDatabase<SkillDef>.GetNamed("Social"), -3);
bs.skillGainsResolved.Add(DefDatabase<SkillDef>.GetNamed("Shooting"), 2);
bs.skillGainsResolved.Add(DefDatabase<SkillDef>.GetNamed("Melee"), 9);
bs.workDisables = (WorkTags.Cleaning | WorkTags.Animals | WorkTags.Caring | WorkTags.Artistic | WorkTags.ManualSkilled);
bs.requiredWorkTags = WorkTags.None;
bs.slot = BackstorySlot.Adulthood;
bs.spawnCategories = new List<string>() { "rjw_nymphsCategory", "Slave" }; // Not necessary (I Think)
Unprivater.SetProtectedValue("bodyTypeGlobal", bs, "Thin");
Unprivater.SetProtectedValue("bodyTypeFemale", bs, "Thin");
Unprivater.SetProtectedValue("bodyTypeMale", bs, "Thin");
Unprivater.SetProtectedValue("bodyTypeGlobalResolved", bs, BodyTypeDefOf.Thin);
Unprivater.SetProtectedValue("bodyTypeFemaleResolved", bs, BodyTypeDefOf.Thin);
Unprivater.SetProtectedValue("bodyTypeMaleResolved", bs, BodyTypeDefOf.Thin);
bs.forcedTraits = new List<TraitEntry>();
bs.forcedTraits.Add(new TraitEntry(xxx.nymphomaniac, 0));
bs.disallowedTraits = new List<TraitEntry>();
bs.disallowedTraits.Add(new TraitEntry(TraitDefOf.DislikesMen, 0));
bs.disallowedTraits.Add(new TraitEntry(TraitDefOf.DislikesWomen, 0));
bs.disallowedTraits.Add(new TraitEntry(TraitDefOf.TooSmart, 0));
bs.shuffleable = true;
bs.ResolveReferences();
BackstoryDatabase.AddBackstory(bs);
adult.feisty = bs;
//--Log.Message("[RJW]nymph_backstories::init() succeed1");
}
{
Backstory bs = new Backstory();
bs.identifier = "";
MiscTranslationDef MTdef = DefDatabase<MiscTranslationDef>.GetNamedSilentFail("rjw_curious");
if (MTdef != null)
{
bs.SetTitle(MTdef.label, MTdef.label);
bs.SetTitleShort(MTdef.stringA, MTdef.stringA);
bs.baseDesc = MTdef.description;
}
else
{
bs.SetTitle("Curious Nymph", "Curious Nymph");
bs.SetTitleShort("Nymph", "Nymph");
bs.baseDesc = "Hold the covering plate back and place the actuator in slot C. Line the rod up. No, that won't do, it needs to be perfect. Now pop the JC-444 chip in place.";
}
bs.skillGainsResolved.Add(DefDatabase<SkillDef>.GetNamed("Construction"), 2);
bs.skillGainsResolved.Add(DefDatabase<SkillDef>.GetNamed("Crafting"), 6);
bs.workDisables = (WorkTags.Animals | WorkTags.Artistic | WorkTags.Caring | WorkTags.Cooking | WorkTags.Mining | WorkTags.PlantWork | WorkTags.Violent | WorkTags.ManualDumb);
bs.requiredWorkTags = WorkTags.None;
bs.slot = BackstorySlot.Adulthood;
bs.spawnCategories = new List<string>() { "rjw_nymphsCategory", "Slave" }; // Not necessary (I Think)
Unprivater.SetProtectedValue("bodyTypeGlobal", bs, "Thin");
Unprivater.SetProtectedValue("bodyTypeFemale", bs, "Thin");
Unprivater.SetProtectedValue("bodyTypeMale", bs, "Thin");
Unprivater.SetProtectedValue("bodyTypeGlobalResolved", bs, BodyTypeDefOf.Thin);
Unprivater.SetProtectedValue("bodyTypeFemaleResolved", bs, BodyTypeDefOf.Thin);
Unprivater.SetProtectedValue("bodyTypeMaleResolved", bs, BodyTypeDefOf.Thin);
bs.forcedTraits = new List<TraitEntry>();
bs.forcedTraits.Add(new TraitEntry(xxx.nymphomaniac, 0));
bs.disallowedTraits = new List<TraitEntry>();
bs.disallowedTraits.Add(new TraitEntry(TraitDefOf.DislikesMen, 0));
bs.disallowedTraits.Add(new TraitEntry(TraitDefOf.DislikesWomen, 0));
bs.disallowedTraits.Add(new TraitEntry(TraitDefOf.TooSmart, 0));
bs.shuffleable = true;
bs.ResolveReferences();
BackstoryDatabase.AddBackstory(bs);
adult.curious = bs;
//--Log.Message("[RJW]nymph_backstories::init() succeed2");
}
{
Backstory bs = new Backstory();
bs.identifier = "";
MiscTranslationDef MTdef = DefDatabase<MiscTranslationDef>.GetNamedSilentFail("rjw_tender");
if (MTdef != null)
{
bs.SetTitle(MTdef.label, MTdef.label);
bs.SetTitleShort(MTdef.stringA, MTdef.stringA);
bs.baseDesc = MTdef.description;
}
else
{
bs.SetTitle("Tender Nymph", "Tender Nymph");
bs.SetTitleShort("Nymph", "Nymph");
bs.baseDesc = "NAME has a pair of charming eyes, and HIS voice is soft and sweet. Due to HIS previous nurse job, HE tends people quite well.";
}
bs.skillGainsResolved.Add(DefDatabase<SkillDef>.GetNamed("Medicine"), 4);
bs.workDisables = (WorkTags.Animals | WorkTags.Artistic | WorkTags.Hauling | WorkTags.Violent | WorkTags.ManualSkilled);
bs.requiredWorkTags = WorkTags.None;
bs.slot = BackstorySlot.Adulthood;
bs.spawnCategories = new List<string>() { "rjw_nymphsCategory", "Slave" }; // Not necessary (I Think)
Unprivater.SetProtectedValue("bodyTypeGlobal", bs, "Thin");
Unprivater.SetProtectedValue("bodyTypeFemale", bs, "Thin");
Unprivater.SetProtectedValue("bodyTypeMale", bs, "Thin");
Unprivater.SetProtectedValue("bodyTypeGlobalResolved", bs, BodyTypeDefOf.Thin);
Unprivater.SetProtectedValue("bodyTypeFemaleResolved", bs, BodyTypeDefOf.Thin);
Unprivater.SetProtectedValue("bodyTypeMaleResolved", bs, BodyTypeDefOf.Thin);
bs.forcedTraits = new List<TraitEntry>();
bs.forcedTraits.Add(new TraitEntry(xxx.nymphomaniac, 0));
bs.disallowedTraits = new List<TraitEntry>();
bs.disallowedTraits.Add(new TraitEntry(TraitDefOf.DislikesMen, 0));
bs.disallowedTraits.Add(new TraitEntry(TraitDefOf.DislikesWomen, 0));
bs.disallowedTraits.Add(new TraitEntry(TraitDefOf.TooSmart, 0));
bs.shuffleable = true;
bs.ResolveReferences();
BackstoryDatabase.AddBackstory(bs);
adult.tender = bs;
//--Log.Message("[RJW]nymph_backstories::init() succeed3");
}
{
Backstory bs = new Backstory();
bs.identifier = "";
MiscTranslationDef MTdef = DefDatabase<MiscTranslationDef>.GetNamedSilentFail("rjw_chatty");
if (MTdef != null)
{
bs.SetTitle(MTdef.label, MTdef.label);
bs.SetTitleShort(MTdef.stringA, MTdef.stringA);
bs.baseDesc = MTdef.description;
}
else
{
bs.SetTitle("Chatty Nymph", "Chatty Nymph");
bs.SetTitleShort("Nymph", "Nymph");
bs.baseDesc = "No one can be more loquacious than NAME. HECAP has a flexible tongue, a sharp mind, and hot lips.";
}
bs.skillGainsResolved.Add(DefDatabase<SkillDef>.GetNamed("Social"), 6);
bs.workDisables = (WorkTags.Animals | WorkTags.Caring | WorkTags.Artistic | WorkTags.Violent | WorkTags.ManualDumb | WorkTags.ManualSkilled);
bs.requiredWorkTags = WorkTags.None;
bs.slot = BackstorySlot.Adulthood;
bs.spawnCategories = new List<string>() { "rjw_nymphsCategory", "Slave" }; // Not necessary (I Think)
Unprivater.SetProtectedValue("bodyTypeGlobal", bs, "Thin");
Unprivater.SetProtectedValue("bodyTypeFemale", bs, "Thin");
Unprivater.SetProtectedValue("bodyTypeMale", bs, "Thin");
Unprivater.SetProtectedValue("bodyTypeGlobalResolved", bs, BodyTypeDefOf.Thin);
Unprivater.SetProtectedValue("bodyTypeFemaleResolved", bs, BodyTypeDefOf.Thin);
Unprivater.SetProtectedValue("bodyTypeMaleResolved", bs, BodyTypeDefOf.Thin);
bs.forcedTraits = new List<TraitEntry>();
bs.forcedTraits.Add(new TraitEntry(xxx.nymphomaniac, 0));
bs.disallowedTraits = new List<TraitEntry>();
bs.disallowedTraits.Add(new TraitEntry(TraitDefOf.DislikesMen, 0));
bs.disallowedTraits.Add(new TraitEntry(TraitDefOf.DislikesWomen, 0));
bs.disallowedTraits.Add(new TraitEntry(TraitDefOf.TooSmart, 0));
bs.shuffleable = true;
bs.ResolveReferences();
BackstoryDatabase.AddBackstory(bs);
adult.chatty = bs;
//--Log.Message("[RJW]nymph_backstories::init() succeed4");
}
{
Backstory bs = new Backstory();
bs.identifier = "";
MiscTranslationDef MTdef = DefDatabase<MiscTranslationDef>.GetNamedSilentFail("rjw_broken");
if (MTdef != null)
{
bs.SetTitle(MTdef.label, MTdef.label);
bs.SetTitleShort(MTdef.stringA, MTdef.stringA);
bs.baseDesc = MTdef.description;
}
else
{
bs.SetTitle("Broken Nymph", "Broken Nymph");
bs.SetTitleShort("Nymph", "Nymph");
bs.baseDesc = "Maybe NAME suffered some terrible Things, HE looks rather emaciated, and no one wants to speak with HIM.\nHECAP only behaves a bit vivaciously while staring at some rod-like stuffs.";
}
bs.skillGainsResolved.Add(DefDatabase<SkillDef>.GetNamed("Social"), -5);
bs.skillGainsResolved.Add(DefDatabase<SkillDef>.GetNamed("Artistic"), 8);
bs.workDisables = (WorkTags.Cleaning | WorkTags.Animals | WorkTags.Caring | WorkTags.Violent | WorkTags.ManualSkilled);
bs.requiredWorkTags = WorkTags.None;
bs.slot = BackstorySlot.Adulthood;
bs.spawnCategories = new List<string>() { "rjw_nymphsCategory", "Slave" }; // Not necessary (I Think)
Unprivater.SetProtectedValue("bodyTypeGlobal", bs, "Thin");
Unprivater.SetProtectedValue("bodyTypeFemale", bs, "Thin");
Unprivater.SetProtectedValue("bodyTypeMale", bs, "Thin");
Unprivater.SetProtectedValue("bodyTypeGlobalResolved", bs, BodyTypeDefOf.Thin);
Unprivater.SetProtectedValue("bodyTypeFemaleResolved", bs, BodyTypeDefOf.Thin);
Unprivater.SetProtectedValue("bodyTypeMaleResolved", bs, BodyTypeDefOf.Thin);
bs.forcedTraits = new List<TraitEntry>();
bs.forcedTraits.Add(new TraitEntry(xxx.nymphomaniac, 0));
bs.disallowedTraits = new List<TraitEntry>();
bs.disallowedTraits.Add(new TraitEntry(TraitDefOf.DislikesMen, 0));
bs.disallowedTraits.Add(new TraitEntry(TraitDefOf.DislikesWomen, 0));
bs.disallowedTraits.Add(new TraitEntry(TraitDefOf.TooSmart, 0));
bs.shuffleable = true;
bs.ResolveReferences();
BackstoryDatabase.AddBackstory(bs);
adult.broken = bs;
//--Log.Message("[RJW]nymph_backstories::init() succeed5");
}
}
public static nymph_passion_chances get_passion_chances(Backstory child_bs, Backstory adult_bs, SkillDef skill_def)
{
var maj = 0.0f;
var min = 0.0f;
if (adult_bs == adult.feisty)
{
if (skill_def == SkillDefOf.Melee) { maj = 0.50f; min = 1.00f; }
else if (skill_def == SkillDefOf.Shooting) { maj = 0.25f; min = 0.75f; }
else if (skill_def == SkillDefOf.Social) { maj = 0.10f; min = 0.67f; }
}
else if (adult_bs == adult.curious)
{
if (skill_def == SkillDefOf.Construction) { maj = 0.15f; min = 0.40f; }
else if (skill_def == SkillDefOf.Crafting) { maj = 0.50f; min = 1.00f; }
else if (skill_def == SkillDefOf.Social) { maj = 0.20f; min = 1.00f; }
}
else if (adult_bs == adult.tender)
{
if (skill_def == SkillDefOf.Medicine) { maj = 0.20f; min = 0.60f; }
else if (skill_def == SkillDefOf.Social) { maj = 0.50f; min = 1.00f; }
}
else if (adult_bs == adult.chatty)
{
if (skill_def == SkillDefOf.Social) { maj = 1.00f; min = 1.00f; }
}
else if (adult_bs == adult.broken)
{
if (skill_def == SkillDefOf.Artistic) { maj = 0.50f; min = 1.00f; }
else if (skill_def == SkillDefOf.Social) { maj = 0.00f; min = 0.33f; }
}
return new nymph_passion_chances(maj, min);
}
// Randomly chooses backstories and traits for a nymph
[SyncMethod]
public static nymph_story generate()
{
var tr = new nymph_story();
tr.child = child.vatgrown_sex_slave;
tr.traits = new List<Trait>();
tr.traits.Add(new Trait(xxx.nymphomaniac, 0, true));
//Rand.PopState();
//Rand.PushState(RJW_Multiplayer.PredictableSeed());
var beauty = 0;
var rv = Rand.Value;
var rv2 = Rand.Value;
if (rv < 0.300)
{
tr.adult = adult.feisty;
beauty = Rand.RangeInclusive(0, 2);
if (rv2 < 0.33)
tr.traits.Add(new Trait(TraitDefOf.Brawler));
else if (rv2 < 0.67)
tr.traits.Add(new Trait(TraitDefOf.Bloodlust));
else
tr.traits.Add(new Trait(xxx.rapist));
}
/* removed in B19?
to remove later from cs
else if (rv < 0.475)
{
tr.adult = adult.curious;
beauty = Rand.RangeInclusive(0, 2);
if (rv2 < 0.33)
tr.traits.Add(new Trait(TraitDef.Named("Prosthophile")));
}
*/
else if (rv < 0.650)
{
tr.adult = adult.tender;
beauty = Rand.RangeInclusive(1, 2);
if (rv2 < 0.50)
tr.traits.Add(new Trait(TraitDefOf.Kind));
}
else if (rv < 0.825)
{
tr.adult = adult.chatty;
beauty = 2;
if (rv2 < 0.33)
tr.traits.Add(new Trait(TraitDefOf.Greedy));
}
else
{
tr.adult = adult.broken;
beauty = Rand.RangeInclusive(0, 2);
if (rv2 < 0.33)
tr.traits.Add(new Trait(TraitDefOf.DrugDesire, 1));
else if (rv2 < 0.67)
tr.traits.Add(new Trait(TraitDefOf.DrugDesire, 2));
}
if (beauty > 0)
tr.traits.Add(new Trait(TraitDefOf.Beauty, beauty, false));
return tr;
}
}
}
|
Mewtopian/rjw
|
Source/Modules/Nymphs/Pawns/Nymph_Backstories.cs
|
C#
|
mit
| 16,314 |
using System.Collections.Generic;
using RimWorld;
using UnityEngine;
using Verse;
using System;
using Multiplayer.API;
namespace rjw
{
public static class nymph_generator
{
private static bool is_trait_conflicting_or_duplicate(Pawn pawn, Trait t)
{
foreach (var existing in pawn.story.traits.allTraits)
if ((existing.def == t.def) || (t.def.ConflictsWith(existing)))
return true;
return false;
}
[SyncMethod]
public static Gender setnymphgender()
{
//with males 100% its still 99%, coz im to lazy to fix it
//float rnd = Rand.Value;
//Rand.PopState();
//Rand.PushState(RJW_Multiplayer.PredictableSeed());
float chance = RJWSettings.male_nymph_chance;
Gender Pawngender = Rand.Chance(chance) ? Gender.Male: Gender.Female;
//Log.Message("[RJW] setnymphsex: " + (rnd < chance) + " rnd:" + rnd + " chance:" + chance);
//Log.Message("[RJW] setnymphsex: " + Pawngender);
return Pawngender;
}
// Replaces a pawn's backstory and traits to turn it into a nymph
[SyncMethod]
public static void set_story(Pawn pawn)
{
var gen_sto = nymph_backstories.generate();
pawn.story.childhood = gen_sto.child;
pawn.story.adulthood = gen_sto.adult;
// add broken body to broken nymph
if (pawn.story.adulthood == nymph_backstories.adult.broken)
{
BodyPartRecord torso = pawn.RaceProps.body.AllParts.Find((bpr) => String.Equals(bpr.def.defName, "Torso"));
pawn.health.AddHediff(xxx.feelingBroken, torso);
//Rand.PopState();
//Rand.PushState(RJW_Multiplayer.PredictableSeed());
(pawn.health.hediffSet.GetFirstHediffOfDef(xxx.feelingBroken)).Severity = Rand.Range(0.4f, 1.0f);
}
//The mod More Trait Slots will adjust the max number of traits pawn can get, and therefore,
//I need to collect pawns' traits and assign other_traits back to the pawn after adding the nymph_story traits.
Stack<Trait> other_traits = new Stack<Trait>();
int numberOfTotalTraits = 0;
if (!pawn.story.traits.allTraits.NullOrEmpty())
{
foreach (Trait t in pawn.story.traits.allTraits)
{
other_traits.Push(t);
++numberOfTotalTraits;
}
}
pawn.story.traits.allTraits.Clear();
var trait_count = 0;
foreach (var t in gen_sto.traits)
{
pawn.story.traits.GainTrait(t);
++trait_count;
}
while (trait_count < numberOfTotalTraits)
{
Trait t = other_traits.Pop();
if (!is_trait_conflicting_or_duplicate(pawn, t))
pawn.story.traits.GainTrait(t);
++trait_count;
}
}
[SyncMethod]
private static int sum_previous_gains(SkillDef def, Pawn_StoryTracker sto, Pawn_AgeTracker age)
{
int total_gain = 0;
int gain;
// Gains from backstories
if (sto.childhood.skillGainsResolved.TryGetValue(def, out gain))
total_gain += gain;
if (sto.adulthood.skillGainsResolved.TryGetValue(def, out gain))
total_gain += gain;
// Gains from traits
foreach (var trait in sto.traits.allTraits)
if (trait.CurrentData.skillGains.TryGetValue(def, out gain))
total_gain += gain;
// Gains from age
//Rand.PopState();
//Rand.PushState(RJW_Multiplayer.PredictableSeed());
var rgain = Rand.Value * (float)total_gain * 0.35f;
var age_factor = Mathf.Clamp01((age.AgeBiologicalYearsFloat - 17.0f) / 10.0f); // Assume nymphs are 17~27
total_gain += (int)(age_factor * rgain);
return Mathf.Clamp(total_gain, 0, 20);
}
// Set a nymph's initial skills & passions from backstory, traits, and age
[SyncMethod]
public static void set_skills(Pawn pawn)
{
foreach (var skill_def in DefDatabase<SkillDef>.AllDefsListForReading)
{
var rec = pawn.skills.GetSkill(skill_def);
if (!rec.TotallyDisabled)
{
//Rand.PopState();
//Rand.PushState(RJW_Multiplayer.PredictableSeed());
rec.Level = sum_previous_gains(skill_def, pawn.story, pawn.ageTracker);
rec.xpSinceLastLevel = rec.XpRequiredForLevelUp * Rand.Range(0.10f, 0.90f);
var pas_cha = nymph_backstories.get_passion_chances(pawn.story.childhood, pawn.story.adulthood, skill_def);
var rv = Rand.Value;
if (rv < pas_cha.major) rec.passion = Passion.Major;
else if (rv < pas_cha.minor) rec.passion = Passion.Minor;
else rec.passion = Passion.None;
}
else
rec.passion = Passion.None;
}
}
// Apply nymphoverrides for generated pawn
public static void nymph_override(Pawn pawn)
{
set_story(pawn);
set_skills(pawn);
}
[SyncMethod]
public static Pawn spawn_nymph(IntVec3 around_loc, ref Map map, Faction faction = null)
{
PawnKindDef pkd;
{
pkd = PawnKindDef.Named("Nymph");
pkd.minGenerationAge = 18;
pkd.maxGenerationAge = 27;
}
PawnGenerationRequest request = new PawnGenerationRequest(pkd,
faction,
PawnGenerationContext.NonPlayer,
map.Tile, // tile(default is -1), since Inhabitant is true, then tile should have a value here; otherwise an error will pop
false, // Force generate new pawn
false, // Newborn
false, // Allow dead
false, // Allow downed
false, // Can generate pawn relations
false, // Must be capable of violence
0.0f, // Colonist relation chance factor
false, // Force add free warm layer if needed
true, // Allow gay
true, // Allow food
true, // Inhabitant
false, // Been in Cryosleep
false, // ForceRedressWorldPawnIfFormerColonist
false, // WorldPawnFactionDoesntMatter
c => (c.story.bodyType == BodyTypeDefOf.Female) || (c.story.bodyType == BodyTypeDefOf.Thin), // ValidatorPreGear
c => (c.story.bodyType == BodyTypeDefOf.Female) || (c.story.bodyType == BodyTypeDefOf.Thin), // ValidatorPostGear
null, // MinChanceToRedressWorldPawn
null, // Fixed biological age
null, // Fixed chronological age
setnymphgender(), // Fixed gender
null, // Fixed melanin
null); // Fixed last name
//Rand.PopState();
//Rand.PushState(RJW_Multiplayer.PredictableSeed());
IntVec3 spawn_loc = CellFinder.RandomClosewalkCellNear(around_loc, map, 6);//RandomSpawnCellForPawnNear could be an alternative
//Log.Message("[RJW] spawn_nymph1: " + request.FixedGender);
//generate random pawn
Pawn pawn = rjw_PawnGenerator.GeneratePawn(request);
//i have no fucking idea why, but core PawnGenerator always generate females ignoring request settings
//Pawn pawn = PawnGenerator.GeneratePawn(request);
//Log.Message("[RJW] spawn_nymph3: " + pawn.gender);
//override random generated pawn stuff with nymph stuff
nymph_override(pawn);
GenSpawn.Spawn(pawn, spawn_loc, map);
return pawn;
}
}
}
|
Mewtopian/rjw
|
Source/Modules/Nymphs/Pawns/Nymph_Generator.cs
|
C#
|
mit
| 6,810 |
using System.Collections.Generic;
using Verse;
using Multiplayer.API;
namespace rjw
{
//MicroComputer
internal class Hediff_MicroComputer : Hediff_MechImplants
{
protected int nextEventTick = 60000;
public override void ExposeData()
{
base.ExposeData();
Scribe_Values.Look<int>(ref this.nextEventTick, "nextEventTick", 60000, false);
}
[SyncMethod]
public override void PostMake()
{
base.PostMake();
//Rand.PopState();
//Rand.PushState(RJW_Multiplayer.PredictableSeed());
nextEventTick = Rand.Range(mcDef.minEventInterval, mcDef.maxEventInterval);
}
public override void Tick()
{
base.Tick();
if (this.pawn.IsHashIntervalTick(1000))
{
if (this.ageTicks >= nextEventTick)
{
HediffDef randomEffectDef = DefDatabase<HediffDef>.GetNamed(randomEffect);
if (randomEffectDef != null)
{
pawn.health.AddHediff(randomEffectDef);
}
else
{
//--Log.Message("[RJW]" + this.GetType().ToString() + "::Tick() - There is no Random Effect");
}
this.ageTicks = 0;
}
}
}
protected HediffDef_MechImplants mcDef
{
get
{
return ((HediffDef_MechImplants)def);
}
}
protected List<string> randomEffects
{
get
{
return mcDef.randomHediffDefs;
}
}
protected string randomEffect
{
get
{
//Rand.PopState();
//Rand.PushState(RJW_Multiplayer.PredictableSeed());
return randomEffects.RandomElement<string>();
}
}
}
}
|
Mewtopian/rjw
|
Source/Modules/Pregnancy/Hediffs/HeDiff_MicroComputer.cs
|
C#
|
mit
| 1,477 |
using System.Collections.Generic;
using Verse;
using System.Linq;
namespace rjw
{
[StaticConstructorOnStartup]
internal class HediffDef_EnemyImplants : HediffDef
{
//single parent eggs
public string parentDef = "";
//multiparent eggs
public List<string> parentDefs = new List<string>();
//for implanting eggs
public bool IsParent(string defnam)
{
return
//predefined parent eggs
parentDef == defnam ||
parentDefs.Contains(defnam) ||
//dynamic egg
(parentDef == "Unknown" && defnam == "Unknown" && RJWPregnancySettings.egg_pregnancy_implant_anyone);
}
}
[StaticConstructorOnStartup]
internal class HediffDef_InsectEgg : HediffDef_EnemyImplants
{
//this is filled from xml
//1 day = 60000 ticks
public float eggsize = 1;
public bool selffertilized = false;
}
[StaticConstructorOnStartup]
internal class HediffDef_MechImplants : HediffDef_EnemyImplants
{
public List<string> randomHediffDefs = new List<string>();
public int minEventInterval = 30000;
public int maxEventInterval = 90000;
}
}
|
Mewtopian/rjw
|
Source/Modules/Pregnancy/Hediffs/HediffDef_EnemyImplants.cs
|
C#
|
mit
| 1,065 |
using System;
using System.Collections.Generic;
using RimWorld;
using Verse;
using UnityEngine;
using System.Text;
using Multiplayer.API;
using System.Linq;
namespace rjw
{
class Hediff_BasePregnancy : HediffWithComps
{
///<summary>
///This hediff class simulates pregnancy.
///</summary>
/*It is different from vanilla in that if father disappears, this one still remembers him.
Other weird variants can be derived
As usuall, significant parts of this are completely stolen from Children and Pregnancy*/
//Static fields
private const int MiscarryCheckInterval = 1000;
private const float MTBMiscarryStarvingDays = 0.5f;
private const float MTBMiscarryWoundedDays = 0.5f;
protected const int TicksPerDay = 60000;
protected const int TicksPerHour = 2500;
protected const string starvationMessage = "MessageMiscarriedStarvation";
protected const string poorHealthMessage = "MessageMiscarriedPoorHealth";
protected static readonly HashSet<String> non_genetic_traits = new HashSet<string>(DefDatabase<StringListDef>.GetNamed("NonInheritedTraits").strings);
//Fields
///All babies should be premade and stored here
protected List<Pawn> babies;
///Reference to daddy, goes null sometimes
protected Pawn father;
///Is pregnancy visible?
protected bool is_discovered;
///Is pregnancy type checked?
public bool is_checked = false;
///Mechanoid pregnancy, false - spawn agressive mech
public bool is_hacked = false;
///Contractions duration, effectively additional hediff stage, a dirty hack to make birthing process notable
protected int contractions;
///Gestation progress per tick
protected float progress_per_tick;
//
// Properties
//
public float GestationProgress
{
get => Severity;
private set => Severity = value;
}
private bool IsSeverelyWounded
{
get
{
float num = 0;
List<Hediff> hediffs = pawn.health.hediffSet.hediffs;
foreach (Hediff h in hediffs)
{
if (h is Hediff_Injury && (!h.IsPermanent() || !h.IsTended()))
{
num += h.Severity;
}
}
List<Hediff_MissingPart> missingPartsCommonAncestors = pawn.health.hediffSet.GetMissingPartsCommonAncestors();
foreach (Hediff_MissingPart mp in missingPartsCommonAncestors)
{
if (mp.IsFresh)
{
num += mp.Part.def.GetMaxHealth(pawn);
}
}
return num > 38 * pawn.RaceProps.baseHealthScale;
}
}
public override void PostMake()
{
// Ensure the hediff always applies to the torso, regardless of incorrect directive
base.PostMake();
BodyPartRecord torso = pawn.RaceProps.body.AllParts.Find(x => x.def.defName == "Torso");
if (Part != torso)
Part = torso;
//(debug->add heddif)
//init empty preg, instabirth, cause error during birthing
//Initialize(pawn, father);
}
public override bool Visible => is_discovered;
public void DiscoverPregnancy()
{
is_discovered = true;
if (PawnUtility.ShouldSendNotificationAbout(this.pawn))
{
if (!is_checked)
{
string key1 = "RJW_PregnantTitle";
string message_title = TranslatorFormattedStringExtensions.Translate(key1, pawn.LabelIndefinite());
string key2 = "RJW_PregnantText";
string message_text = TranslatorFormattedStringExtensions.Translate(key2, pawn.LabelIndefinite());
Find.LetterStack.ReceiveLetter(message_title, message_text, LetterDefOf.NeutralEvent, pawn, null);
}
else
{
PregnancyMessage();
}
}
}
public void CheckPregnancy()
{
is_checked = true;
if (!is_discovered)
DiscoverPregnancy();
else
PregnancyMessage();
}
public virtual void PregnancyMessage()
{
string key1 = "RJW_PregnantTitle";
string message_title = TranslatorFormattedStringExtensions.Translate(key1, pawn.LabelIndefinite());
string key2 = "RJW_PregnantNormal";
string message_text = TranslatorFormattedStringExtensions.Translate(key2, pawn.LabelIndefinite());
Find.LetterStack.ReceiveLetter(message_title, message_text, LetterDefOf.NeutralEvent, pawn, null);
}
// Quick method to simply return a body part instance by a given part name
internal static BodyPartRecord GetPawnBodyPart(Pawn pawn, String bodyPart)
{
return pawn.RaceProps.body.AllParts.Find(x => x.def == DefDatabase<BodyPartDef>.GetNamed(bodyPart));
}
public void Miscarry()
{
pawn.health?.RemoveHediff(this);
}
[SyncMethod]
public Pawn partstospawn(Pawn baby, Pawn mother, Pawn dad)
{
//decide what parts to inherit
//default use own parts
Pawn partstospawn = baby;
//Rand.PopState();
//Rand.PushState(RJW_Multiplayer.PredictableSeed());
//spawn with mother parts
if (mother != null && Rand.Range(0, 100) <= 10)
partstospawn = mother;
//spawn with father parts
if (dad != null && Rand.Range(0, 100) <= 10)
partstospawn = dad;
//Log.Message("[RJW] Pregnancy partstospawn " + partstospawn);
return partstospawn;
}
[SyncMethod]
public bool spawnfutachild(Pawn baby, Pawn mother, Pawn dad)
{
int futachance = 0;
if (mother != null && Genital_Helper.is_futa(mother))
futachance = futachance + 25;
if (dad != null && Genital_Helper.is_futa(dad))
futachance = futachance + 25;
//Log.Message("[RJW] Pregnancy spawnfutachild " + futachance);
//Rand.PopState();
//Rand.PushState(RJW_Multiplayer.PredictableSeed());
return (Rand.Range(0, 100) <= futachance);
}
[SyncMethod]
public static Pawn Trytogetfather(ref Pawn mother)
{
//birthing with debug has no father
//Postmake.initialize() has no father
Log.Warning("Hediff_BasePregnancy::Trytogetfather() - debug? no father defined, trying to add one");
Pawn pawn = mother;
Pawn father = null;
//possible fathers
List<Pawn> partners = pawn.relations.RelatedPawns.Where(x =>
Genital_Helper.has_penis(x) && !x.Dead &&
(pawn.relations.DirectRelationExists(PawnRelationDefOf.Lover, x) ||
pawn.relations.DirectRelationExists(PawnRelationDefOf.Fiance, x) ||
pawn.relations.DirectRelationExists(PawnRelationDefOf.Spouse, x))
).ToList();
//add bonded animal
if (xxx.is_zoophile(mother) && RJWSettings.bestiality_enabled)
partners.AddRange(pawn.relations.RelatedPawns.Where(x =>
Genital_Helper.has_penis(x) &&
pawn.relations.DirectRelationExists(PawnRelationDefOf.Bond, x)).ToList());
if (partners.Any())
{
father = partners.RandomElement();
Log.Warning("Hediff_BasePregnancy::Trytogetfather() - father set to: " + xxx.get_pawnname(father));
}
return father;
}
[SyncMethod]
public override void Tick()
{
ageTicks++;
if (pawn.IsHashIntervalTick(1000))
if (!pawn.health.hediffSet.HasHediff(HediffDef.Named("RJW_pregnancy_mech")))
{
//Log.Message("[RJW] Pregnancy is ticking for " + pawn + " this is " + this.def.defName + " will end in " + 1/progress_per_tick/TicksPerDay + " days resulting in "+ babies[0].def.defName);
//Rand.PopState();
//Rand.PushState(RJW_Multiplayer.PredictableSeed());
//miscarry after starving 0.5 day
if (pawn.needs.food != null && pawn.needs.food.CurCategory == HungerCategory.Starving && Rand.MTBEventOccurs(0.5f, TicksPerDay, MiscarryCheckInterval))
{
if (Visible && PawnUtility.ShouldSendNotificationAbout(pawn))
{
string text = "MessageMiscarriedStarvation".Translate(pawn.LabelIndefinite()).CapitalizeFirst();
Messages.Message(text, pawn, MessageTypeDefOf.NegativeHealthEvent);
}
Miscarry();
return;
}
//let beatings only be important when pregnancy is developed somewhat
//miscarry after SeverelyWounded 0.5 day
if (Visible && IsSeverelyWounded && Rand.MTBEventOccurs(0.5f, TicksPerDay, MiscarryCheckInterval))
{
if (Visible && PawnUtility.ShouldSendNotificationAbout(pawn))
{
string text = "MessageMiscarriedPoorHealth".Translate(pawn.LabelIndefinite()).CapitalizeFirst();
Messages.Message(text, pawn, MessageTypeDefOf.NegativeHealthEvent);
}
Miscarry();
return;
}
}
if (xxx.has_quirk(pawn, "Breeder") || pawn.health.hediffSet.HasHediff(HediffDef.Named("FertilityEnhancer")))
GestationProgress += progress_per_tick * 1.25f;
else
GestationProgress += progress_per_tick;
// Check if pregnancy is far enough along to "show" for the body type
if (!is_discovered)
{
BodyTypeDef bodyT = pawn?.story?.bodyType;
//float threshold = 0f;
if ((bodyT == BodyTypeDefOf.Thin && GestationProgress > 0.25f) ||
(bodyT == BodyTypeDefOf.Female && GestationProgress > 0.35f) ||
(GestationProgress > 0.50f))
DiscoverPregnancy();
//switch (bodyT)
//{
//case BodyType.Thin: threshold = 0.3f; break;
//case BodyType.Female: threshold = 0.389f; break;
//case BodyType.Male: threshold = 0.41f; break;
//default: threshold = 0.5f; break;
//}
//if (GestationProgress > threshold){ DiscoverPregnancy(); }
}
// no birthings in caravan?
// no idea if it has any effect on guests that left player map
if (CurStageIndex == 3 && pawn.Map != null)
{
if (contractions == 0)
{
if (PawnUtility.ShouldSendNotificationAbout(this.pawn))
{
string text = "RJW_Contractions".Translate(pawn.LabelIndefinite());
Messages.Message(text, pawn, MessageTypeDefOf.NeutralEvent);
}
}
contractions++;
if (contractions >= TicksPerHour)//birthing takes an hour
{
if (PawnUtility.ShouldSendNotificationAbout(this.pawn))
{
string message_title = "RJW_GaveBirthTitle".Translate(pawn.LabelIndefinite());
string message_text = "RJW_GaveBirthText".Translate(pawn.LabelIndefinite());
string baby_text = ((babies.Count == 1) ? "RJW_ABaby".Translate() : "RJW_NBabies".Translate(babies.Count));
message_text = message_text + baby_text;
Find.LetterStack.ReceiveLetter(message_title, message_text, LetterDefOf.PositiveEvent, pawn);
}
GiveBirth();
}
}
}
//
//These functions are different from CnP
//
public override void ExposeData()//If you didn't know, this one is used to save the object for later loading of the game... and to load the data into the object, <sigh>
{
base.ExposeData();
Scribe_References.Look(ref father, "father");
Scribe_Values.Look(ref is_checked, "is_checked");
Scribe_Values.Look(ref is_hacked, "is_hacked");
Scribe_Values.Look(ref is_discovered, "is_discovered");
Scribe_Values.Look(ref contractions, "contractions");
Scribe_Collections.Look(ref babies, saveDestroyedThings: true, label: "babies", lookMode: LookMode.Deep, ctorArgs: new object[0]);
Scribe_Values.Look(ref progress_per_tick, "progress_per_tick", 1);
}
//This should generate pawns to be born in due time. Should take into account all settings and parent races
[SyncMethod]
protected virtual void GenerateBabies()
{
Pawn mother = pawn;
//Log.Message("Generating babies for " + this.def.defName);
if (mother == null)
{
Log.Error("Hediff_BasePregnancy::GenerateBabies() - no mother defined");
return;
}
if (father == null)
{
father = Trytogetfather(ref mother);
}
//Babies will have average number of traits of their parents, this way it will hopefully be compatible with various mods that change number of allowed traits
int trait_count = 0;
//Rand.PopState();
//Rand.PushState(RJW_Multiplayer.PredictableSeed());
List<Trait> traitpool = new List<Trait>();
float skin_whiteness = Rand.Range(0, 1);
//Log.Message("[RJW]Generating babies " + traitpool.Count + " traits at first");
if (xxx.has_traits(mother) && mother.RaceProps.Humanlike)
{
foreach (Trait momtrait in mother.story.traits.allTraits)
{
if (!RJWPregnancySettings.trait_filtering_enabled || !non_genetic_traits.Contains(momtrait.def.defName))
traitpool.Add(momtrait);
}
skin_whiteness = mother.story.melanin;
trait_count = mother.story.traits.allTraits.Count;
}
if (father != null && xxx.has_traits(father) && father.RaceProps.Humanlike)
{
foreach (Trait poptrait in father.story.traits.allTraits)
{
if (!RJWPregnancySettings.trait_filtering_enabled || !non_genetic_traits.Contains(poptrait.def.defName))
traitpool.Add(poptrait);
}
skin_whiteness = Rand.Range(skin_whiteness, father.story.melanin);
trait_count = Mathf.RoundToInt((trait_count + father.story.traits.allTraits.Count) / 2f);
}
//this probably doesnt matter in 1.0 remove it and wait for bug reports =)
//trait_count = trait_count > 2 ? trait_count : 2;//Tynan has hardcoded 2-3 traits per pawn. In the above, result may be less than that. Let us not have disfunctional babies.
//Log.Message("[RJW]Generating babies " + traitpool.Count + " traits aFter parents");
Pawn parent = mother; //race of child
Pawn parent2= father; //name for child
//Decide on which parent is first to be inherited
if (father != null && RJWPregnancySettings.use_parent_method)
{
//Log.Message("The baby race needs definition");
//humanality
if (xxx.is_human(mother) && xxx.is_human(father))
{
//Log.Message("It's of two humanlikes");
if (!Rand.Chance(RJWPregnancySettings.humanlike_DNA_from_mother))
{
//Log.Message("Mother will birth father race");
parent = father;
}
else
{
//Log.Message("Mother will birth own race");
}
}
else
{
//bestiality
if ((!xxx.is_human(mother) && xxx.is_human(father)) ||
(xxx.is_human(mother) && !xxx.is_human(father)))
{
if (RJWPregnancySettings.bestiality_DNA_inheritance == 0.0f)
{
//Log.Message("mother will birth beast");
if (xxx.is_human(mother))
parent = father;
else
parent = mother;
}
else if (RJWPregnancySettings.bestiality_DNA_inheritance == 1.0f)
{
//Log.Message("mother will birth humanlike");
if (xxx.is_human(mother))
parent = mother;
else
parent = father;
}
else
{
if (!Rand.Chance(RJWPregnancySettings.bestial_DNA_from_mother))
{
//Log.Message("Mother will birth father race");
parent = father;
}
else
{
//Log.Message("Mother will birth own race");
}
}
}
//animality
else if (!Rand.Chance(RJWPregnancySettings.bestial_DNA_from_mother))
{
//Log.Message("Mother will birth father race");
parent = father;
}
else
{
//Log.Message("Mother will birth own race");
}
}
}
//androids can only birth non androids
if (AndroidsCompatibility.IsAndroid(mother) && !AndroidsCompatibility.IsAndroid(father))
{
parent = father;
}
else if (!AndroidsCompatibility.IsAndroid(mother) && AndroidsCompatibility.IsAndroid(father))
{
parent = mother;
}
else if (AndroidsCompatibility.IsAndroid(mother) && AndroidsCompatibility.IsAndroid(father))
{
Log.Warning("Both parents are andoids, what have you done monster!");
//this should never happen but w/e
}
//slimes birth only other slimes
if (mother.kindDef.race.defName.ToLower().Contains("slime"))
{
parent = mother;
}
if (father != null)
if (father.kindDef.race.defName.ToLower().Contains("slime"))
{
parent = father;
}
//Log.Message("[RJW] The main parent is " + parent);
//Log.Message("Mother: " + xxx.get_pawnname(mother) + " kind: " + mother.kindDef);
//Log.Message("Father: " + xxx.get_pawnname(father) + " kind: " + father.kindDef);
//Log.Message("Baby base: " + xxx.get_pawnname(parent) + " kind: " + parent.kindDef);
// Surname passing
string last_name = "";
if (xxx.is_human(father))
last_name = NameTriple.FromString(father.Name.ToStringFull).Last;
if (xxx.is_human(mother) && last_name == "")
last_name = NameTriple.FromString(mother.Name.ToStringFull).Last;
//Log.Message("[RJW] Bady surname will be " + last_name);
//Pawn generation request
int MapTile = -1;
PawnKindDef spawn_kind_def = parent.kindDef;
Faction spawn_faction = mother.IsPrisoner ? null : mother.Faction;
PawnGenerationRequest request = new PawnGenerationRequest(spawn_kind_def, spawn_faction, PawnGenerationContext.NonPlayer, MapTile, false, true, false, false, false, false, 1, false, true, false, false, false, false, false, null, null, null, 0, 0, null, skin_whiteness, last_name);
//Log.Message("[RJW] Generated request, making babies");
//Litter size. Let's use the main parent litter size, increased by fertility.
float litter_size = (parent.RaceProps.litterSizeCurve == null) ? 1 : Rand.ByCurve(parent.RaceProps.litterSizeCurve);
//Log.Message("[RJW] base Litter size " + litter_size);
litter_size *= mother.health.capacities.GetLevel(xxx.reproduction);
litter_size *= father == null ? 1 : father.health.capacities.GetLevel(xxx.reproduction);
litter_size = Math.Max(1, litter_size);
//Log.Message("[RJW] Litter size (w fertility) " + litter_size);
//Babies size vs mother body size
//assuming mother belly is 1/3 of mother body size
float baby_size = spawn_kind_def.RaceProps.lifeStageAges[0].def.bodySizeFactor * spawn_kind_def.RaceProps.baseBodySize; // adult size/5
//Log.Message("[RJW] Baby size " + baby_size);
float max_litter = 1f / 3f / baby_size;
//Log.Message("[RJW] Max size " + max_litter);
max_litter *= ((xxx.has_quirk(mother, "Breeder") || xxx.has_quirk(mother, "Incubator")) ? 2 : 1);
//Log.Message("[RJW] Max size (w quirks) " + max_litter);
//Generate random amount of babies within litter/max size
litter_size = (Rand.Range(litter_size, max_litter));
//Log.Message("[RJW] Litter size roll 1:" + litter_size);
litter_size = Mathf.RoundToInt(litter_size);
//Log.Message("[RJW] Litter size roll 2:" + litter_size);
litter_size = Math.Max(1, litter_size);
//Log.Message("[RJW] final Litter size " + litter_size);
for (int i = 0; i < litter_size; i++)
{
Pawn baby = PawnGenerator.GeneratePawn(request);
//Choose traits to add to the child. Unlike CnP this will allow for some random traits
if (xxx.is_human(baby) && traitpool.Count > 0)
{
int baby_trait_count = baby.story.traits.allTraits.Count;
if (baby_trait_count > trait_count / 2)
{
baby.story.traits.allTraits.RemoveRange(0, Math.Max(trait_count / 2, 1) - 1);
}
List<Trait> to_add = new List<Trait>();
while (to_add.Count < Math.Min(trait_count, traitpool.Count))
{
Trait gentrait = traitpool.RandomElement();
if (!to_add.Contains(gentrait))
{
to_add.Add(gentrait);
}
}
foreach (Trait trait in to_add)
{
// Skip to next check if baby already has the trait, or it conflicts with existing one.
if (baby.story.traits.HasTrait(trait.def) || baby.story.traits.allTraits.Any(x => x.def.ConflictsWith(trait))) continue;
baby.story.traits.GainTrait(trait);
if (baby.story.traits.allTraits.Count >= trait_count)
{
break;
}
}
}
babies.Add(baby);
}
}
//Handles the spawning of pawns and adding relations
//this is extended by other scripts
public virtual void GiveBirth()
{
}
public virtual void PostBirth(Pawn mother, Pawn father, Pawn baby)
{
if (xxx.is_human(baby))
{
baby.story.childhood = null;
baby.story.adulthood = null;
}
//inject RJW_BabyState to the newborn if RimWorldChildren is not active
//cnp patches its hediff right into pawn generator, so its already in if it can
if (!xxx.RimWorldChildrenIsActive)
{
if (xxx.is_human(baby) && baby.ageTracker.CurLifeStageIndex <= 1 && baby.ageTracker.AgeBiologicalYears < 1 && !baby.Dead)
{
// Clean out drugs, implants, and stuff randomly generated
//no support for custom race stuff, if there is any
baby.health.hediffSet.Clear();
baby.health.AddHediff(HediffDef.Named("RJW_BabyState"), null, null);//RJW_Babystate.tick_rare actually forces CnP switch to CnP one if it can, don't know wat do
Hediff_SimpleBaby babystate = (Hediff_SimpleBaby)baby.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("RJW_BabyState"));
if (babystate != null)
{
babystate.GrowUpTo(0, true);
}
}
}
else
{
if (xxx.is_human(mother))
{
//BnC compatibility
if (DefDatabase<HediffDef>.GetNamedSilentFail("BnC_RJW_PostPregnancy") == null)
{
mother.health.AddHediff(HediffDef.Named("PostPregnancy"), null, null);
mother.health.AddHediff(HediffDef.Named("Lactating"), mother.RaceProps.body.AllParts.Find(x => x.def.defName == "Chest"), null);
}
if (xxx.is_human(baby))
if (mother.records.GetAsInt(xxx.CountOfBirthHuman) == 0 &&
mother.records.GetAsInt(xxx.CountOfBirthAnimal) == 0 &&
mother.records.GetAsInt(xxx.CountOfBirthEgg) == 0 )
{
mother.needs.mood.thoughts.memories.TryGainMemory(ThoughtDef.Named("IGaveBirthFirstTime"));
}
else
{
mother.needs.mood.thoughts.memories.TryGainMemory(ThoughtDef.Named("IGaveBirth"));
}
}
if (xxx.is_human(baby))
if (xxx.is_human(father))
{
father.needs.mood.thoughts.memories.TryGainMemory(ThoughtDef.Named("PartnerGaveBirth"));
}
if (xxx.is_human(baby))
{
Log.Message("[RJW]PostBirth:: Rewriting story of " + baby);
var disabledBaby = BackstoryDatabase.allBackstories["CustomBackstory_NA_Childhood_Disabled"];
if (disabledBaby != null)
{
baby.story.childhood = disabledBaby;
}
else
{
Log.Error("Couldn't find the required Backstory: CustomBackstory_NA_Childhood_Disabled!");
baby.story.childhood = null;
}
}
}
if (baby.playerSettings != null && mother.playerSettings != null)
{
baby.playerSettings.AreaRestriction = mother.playerSettings.AreaRestriction;
}
//spawn futa
bool isfuta = spawnfutachild(baby, mother, father);
Genital_Helper.add_anus(baby, partstospawn(baby, mother, father));
if (baby.gender == Gender.Female || isfuta)
Genital_Helper.add_breasts(baby, partstospawn(baby, mother, father), Gender.Female);
if (isfuta)
{
Genital_Helper.add_genitals(baby, partstospawn(baby, mother, father), Gender.Male);
Genital_Helper.add_genitals(baby, partstospawn(baby, mother, father), Gender.Female);
baby.gender = Gender.Female; //set gender to female for futas, should cause no errors since babies already generated with relations n stuff
}
else
Genital_Helper.add_genitals(baby, partstospawn(baby, mother, father));
if (mother.Spawned)
{
// Move the baby in front of the mother, rather than on top
if (mother.CurrentBed() != null)
{
baby.Position = baby.Position + new IntVec3(0, 0, 1).RotatedBy(mother.CurrentBed().Rotation);
}
// Spawn guck
FilthMaker.MakeFilth(mother.Position, mother.Map, ThingDefOf.Filth_AmnioticFluid, mother.LabelIndefinite(), 5);
mother.caller?.DoCall();
baby.caller?.DoCall();
}
if (xxx.is_human(baby))
mother.records.AddTo(xxx.CountOfBirthHuman, 1);
if (xxx.is_animal(baby))
mother.records.AddTo(xxx.CountOfBirthAnimal, 1);
if ((mother.records.GetAsInt(xxx.CountOfBirthHuman) > 10 || mother.records.GetAsInt(xxx.CountOfBirthAnimal) > 20))
{
if (!xxx.has_quirk(mother, "Breeder"))
{
CompRJW.Comp(mother).quirks.AppendWithComma("Breeder");
}
if (!xxx.has_quirk(mother, "Impregnation fetish"))
{
CompRJW.Comp(mother).quirks.AppendWithComma("Impregnation fetish");
}
}
}
//This method is doing the work of the constructor since hediffs are created through HediffMaker instead of normal oop way
//This can't be in PostMake() because there wouldn't be father.
public void Initialize(Pawn mother, Pawn dad)
{
BodyPartRecord torso = mother.RaceProps.body.AllParts.Find(x => x.def.defName == "Torso");
mother.health.AddHediff(this, torso);
//Log.Message("[RJW]" + this.GetType().ToString() + " pregnancy hediff generated: " + this.Label);
//Log.Message("[RJW]" + this.GetType().ToString() + " mother: " + mother + " father: " + dad);
father = dad;
if (father != null)
{
babies = new List<Pawn>();
contractions = 0;
//Log.Message("[RJW]" + this.GetType().ToString() + " generating babies before: " + this.babies.Count);
GenerateBabies();
}
//progress_per_tick = babies.NullOrEmpty() ? 1f : (1.0f) / (babies[0].RaceProps.gestationPeriodDays * TicksPerDay/50);
progress_per_tick = babies.NullOrEmpty() ? 1f : (1.0f) / (babies[0].RaceProps.gestationPeriodDays * TicksPerDay);
//Log.Message("[RJW]" + this.GetType().ToString() + " generating babies after: " + this.babies.Count);
}
public override string DebugString()
{
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.Append(base.DebugString());
stringBuilder.AppendLine("Gestation progress: " + GestationProgress.ToStringPercent());
//stringBuilder.AppendLine("Time left: " + ((int)((1f - GestationProgress) * babies[0].RaceProps.gestationPeriodDays * TicksPerDay/50)).ToStringTicksToPeriod());
stringBuilder.AppendLine("Time left: " + ((int)((1f - GestationProgress) * babies[0].RaceProps.gestationPeriodDays * TicksPerDay)).ToStringTicksToPeriod());
stringBuilder.AppendLine(" Father: " + xxx.get_pawnname(father));
return stringBuilder.ToString();
}
}
}
|
Mewtopian/rjw
|
Source/Modules/Pregnancy/Hediffs/Hediff_BasePregnancy.cs
|
C#
|
mit
| 25,532 |
using System.Collections.Generic;
using System.Linq;
using RimWorld;
using Verse;
namespace rjw
{
///<summary>
///This hediff class simulates pregnancy with animal children, mother may be human. It is not intended to be reasonable.
///Differences from humanlike pregnancy are that animals are given some training and that less punishing relations are used for parent-child.
///</summary>
class Hediff_BestialPregnancy : Hediff_BasePregnancy
{
private static readonly PawnRelationDef relation_birthgiver = DefDatabase<PawnRelationDef>.AllDefs.FirstOrDefault(d => d.defName == "RJW_Sire");
private static readonly PawnRelationDef relation_spawn = DefDatabase<PawnRelationDef>.AllDefs.FirstOrDefault(d => d.defName == "RJW_Pup");
//static int max_train_level = TrainableUtility.TrainableDefsInListOrder.Sum(tr => tr.steps);
public override void PregnancyMessage()
{
string message_title = "RJW_PregnantTitle".Translate(pawn.LabelIndefinite());
string message_text1 = "RJW_PregnantText".Translate(pawn.LabelIndefinite());
string message_text2 = "RJW_PregnantStrange".Translate();
Find.LetterStack.ReceiveLetter(message_title, message_text1 + "\n" + message_text2, LetterDefOf.NeutralEvent, pawn);
}
//Makes half-human babies start off better. They start obedient, and if mother is a human, they get hediff to boost their training
protected void train(Pawn baby, Pawn mother, Pawn father)
{
bool _;
if (!xxx.is_human(baby) && baby.Faction == Faction.OfPlayer)
{
if (xxx.is_human(mother) && baby.Faction == Faction.OfPlayer && baby.training.CanAssignToTrain(TrainableDefOf.Obedience, out _).Accepted)
{
baby.training.Train(TrainableDefOf.Obedience, mother);
}
if (xxx.is_human(mother) && baby.Faction == Faction.OfPlayer && baby.training.CanAssignToTrain(TrainableDefOf.Tameness, out _).Accepted)
{
baby.training.Train(TrainableDefOf.Tameness, mother);
}
}
//baby.RaceProps.TrainableIntelligence.LabelCap.
//if (xxx.is_human(mother))
//{
// Let the animals be born as colony property
// if (mother.IsPrisonerOfColony || mother.IsColonist)
// {
// baby.SetFaction(Faction.OfPlayer);
// }
// let it be trained half to the max
// var baby_int = baby.RaceProps.TrainableIntelligence;
// int max_int = TrainableUtility.TrainableDefsInListOrder.FindLastIndex(tr => (tr.requiredTrainableIntelligence == baby_int));
// if (max_int == -1)
// return;
// Log.Message("RJW training " + baby + " max_int is " + max_int);
// var available_tricks = TrainableUtility.TrainableDefsInListOrder.GetRange(0, max_int + 1);
// int max_steps = available_tricks.Sum(tr => tr.steps);
// Log.Message("RJW training " + baby + " vill do " + max_steps/2 + " steps");
// int t_score = Rand.Range(Mathf.RoundToInt(max_steps / 4), Mathf.RoundToInt(max_steps / 2));
// for (int i = 1; i <= t_score; i++)
// {
// var tr = available_tricks.Where(t => !baby.training.IsCompleted(t)). RandomElement();
// Log.Message("RJW training " + baby + " for " + tr);
// baby.training.Train(tr, mother);
// }
// baby.health.AddHediff(HediffDef.Named("RJW_smartPup"));
//}
}
//Handles the spawning of pawns and adding relations
public override void GiveBirth()
{
Pawn mother = pawn;
if (mother == null)
return;
try
{
//fail if hediff added through debug, since babies not initialized
if (babies.Count > 9999)
Log.Message("RJW beastiality/animal pregnancy birthing pawn count: " + babies.Count);
}
catch
{
if (father == null)
{
Log.Message("RJW beastiality/animal pregnancy father is null(debug?), setting father to mother");
father = mother;
}
Initialize(mother, father);
}
List<Pawn> siblings = new List<Pawn>();
foreach (Pawn baby in babies)
{
PawnUtility.TrySpawnHatchedOrBornPawn(baby, mother);
Need_Sex sex_need = mother.needs.TryGetNeed<Need_Sex>();
if (mother.Faction != null && !(mother.Faction?.IsPlayer ?? false) && sex_need != null)
{
sex_need.CurLevel = 1.0f;
}
baby.relations.AddDirectRelation(relation_birthgiver, mother);
mother.relations.AddDirectRelation(relation_spawn, baby);
if (father != null && mother != father)
{
baby.relations.AddDirectRelation(relation_birthgiver, father);
father.relations.AddDirectRelation(relation_spawn, baby);
}
foreach (Pawn sibling in siblings)
{
baby.relations.AddDirectRelation(PawnRelationDefOf.Sibling, sibling);
}
siblings.Add(baby);
train(baby, mother, father);
PostBirth(mother, father, baby);
mother.health.RemoveHediff(this);
}
}
///This method should be the only one to create the hediff
//Hediffs are made HediffMaker.MakeHediff which returns hediff of class different than the one needed, so we do the cast and then do all the same operations as in parent class
//I don't know whether it'd be possible to use standard constructor instead of this retardation
public static void Create(Pawn mother, Pawn father)
{
if (mother == null)
return;
BodyPartRecord torso = mother.RaceProps.body.AllParts.Find(x => x.def.defName == "Torso");
//Log.Message("RJW beastial "+ mother + " " + father);
Hediff_BestialPregnancy hediff = (Hediff_BestialPregnancy)HediffMaker.MakeHediff(HediffDef.Named("RJW_pregnancy_beast"), mother, torso);
hediff.Initialize(mother, father);
}
}
}
|
Mewtopian/rjw
|
Source/Modules/Pregnancy/Hediffs/Hediff_BestialPregnancy.cs
|
C#
|
mit
| 5,464 |
using System;
using System.Collections.Generic;
using System.Text;
using RimWorld;
using Verse;
using UnityEngine;
namespace rjw
{
class Hediff_HumanlikePregnancy : Hediff_BasePregnancy
///<summary>
///This hediff class simulates pregnancy resulting in humanlike childs.
///</summary>
{
//Handles the spawning of pawns and adding relations
public override void GiveBirth()
{
Pawn mother = pawn;
if (mother == null)
return;
try
{
//fail if hediff added through debug, since babies not initialized
if (babies.Count > 9999)
Log.Message("RJW humanlike pregnancy birthing pawn count: " + babies.Count);
}
catch
{
Initialize(mother, father);
}
List<Pawn> siblings = new List<Pawn>();
foreach (Pawn baby in babies)
{
PawnUtility.TrySpawnHatchedOrBornPawn(baby, mother);
var sex_need = mother.needs.TryGetNeed<Need_Sex>();
if (mother.Faction != null && !(mother.Faction?.IsPlayer ?? false) && sex_need != null)
{
sex_need.CurLevel = 1.0f;
}
if (mother.Faction != null)
{
baby.SetFaction(mother.Faction);
}
if (mother.IsPrisonerOfColony)
{
baby.guest.CapturedBy(Faction.OfPlayer);
}
baby.relations.AddDirectRelation(PawnRelationDefOf.Parent, mother);
if (father != null)
{
baby.relations.AddDirectRelation(PawnRelationDefOf.Parent, father);
}
foreach (Pawn sibling in siblings)
{
baby.relations.AddDirectRelation(PawnRelationDefOf.Sibling, sibling);
}
siblings.Add(baby);
PostBirth(mother, father, baby);
mother.health.RemoveHediff(this);
}
}
///This method should be the only one to create the hediff
public static void Create(Pawn mother, Pawn father)
{
if (mother == null)
return;
var torso = mother.RaceProps.body.AllParts.Find(x => x.def.defName == "Torso");
//Log.Message("[RJW]Humanlike pregnancy " + mother + " is bred by " + father);
var hediff = (Hediff_HumanlikePregnancy)HediffMaker.MakeHediff(HediffDef.Named("RJW_pregnancy"), mother, torso);
hediff.Initialize(mother, father);
}
}
}
|
Mewtopian/rjw
|
Source/Modules/Pregnancy/Hediffs/Hediff_HumanlikePregnancy.cs
|
C#
|
mit
| 2,110 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.