mirror of
				https://gitgud.io/leboeuf/lewd-biotech.git
				synced 2024-08-14 23:57:27 +00:00 
			
		
		
		
	1.0 initial commit
This commit is contained in:
		
						commit
						1761f03048
					
				
					 34 changed files with 1448 additions and 0 deletions
				
			
		
							
								
								
									
										11
									
								
								Source/DefOf/GeneDefOf.cs
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								Source/DefOf/GeneDefOf.cs
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,11 @@
 | 
			
		|||
using RimWorld;
 | 
			
		||||
using Verse;
 | 
			
		||||
 | 
			
		||||
namespace LewdBiotech
 | 
			
		||||
{
 | 
			
		||||
    [RimWorld.DefOf]
 | 
			
		||||
    public static class GeneDefOf
 | 
			
		||||
    {
 | 
			
		||||
        public static GeneDef LitteredBirths;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										14
									
								
								Source/DefOf/HediffDefOf.cs
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								Source/DefOf/HediffDefOf.cs
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,14 @@
 | 
			
		|||
using RimWorld;
 | 
			
		||||
using Verse;
 | 
			
		||||
 | 
			
		||||
namespace LewdBiotech
 | 
			
		||||
{
 | 
			
		||||
    [RimWorld.DefOf]
 | 
			
		||||
    public static class HediffDefOf
 | 
			
		||||
    {
 | 
			
		||||
        // public static HediffDef Infatuo;
 | 
			
		||||
        // public static HediffDef InfatuoCalibrating;
 | 
			
		||||
        public static HediffDef OvaryAgitator;
 | 
			
		||||
        public static HediffDef Bioscaffold;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										11
									
								
								Source/DefOf/LetterDefOf.cs
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								Source/DefOf/LetterDefOf.cs
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,11 @@
 | 
			
		|||
using RimWorld;
 | 
			
		||||
using Verse;
 | 
			
		||||
 | 
			
		||||
namespace LewdBiotech
 | 
			
		||||
{
 | 
			
		||||
    [RimWorld.DefOf]
 | 
			
		||||
    public static class LetterDefOf
 | 
			
		||||
    {
 | 
			
		||||
        public static LetterDef AnotherBaby;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										57
									
								
								Source/Hediffs/Infatuo.cs
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										57
									
								
								Source/Hediffs/Infatuo.cs
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,57 @@
 | 
			
		|||
// FOR ANYONE (THAT ISN"T ME (BOEUF)) THAT CARES
 | 
			
		||||
// =====================
 | 
			
		||||
// This is an idea for an implant that I had that basically forces a pawn to romantically obsess about another pawn, but I'm taking a break from working on it
 | 
			
		||||
// because I'm too smoothbrain to work out relation defs and making custom relations, and the multibirth stuff was taking up my time as is
 | 
			
		||||
// If you want to mess with it, this code is here for shits and gigs - modify it, throw it out, make something new, idgaf
 | 
			
		||||
 | 
			
		||||
/*using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Text;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
 | 
			
		||||
namespace LewdBiotech.Hediffs
 | 
			
		||||
{
 | 
			
		||||
    class Infatuo
 | 
			
		||||
    {
 | 
			
		||||
		public class PawnRelationWorker_InfatuoInfatuated : PawnRelationWorker
 | 
			
		||||
		{
 | 
			
		||||
			// BaseGenerationChanceFactor - should NEVER autogenerate on pawns (for now, anyway)
 | 
			
		||||
			new public float BaseGenerationChanceFactor(Pawn generated, Pawn other, PawnGenerationRequest request)
 | 
			
		||||
			{
 | 
			
		||||
				return 0.0f;
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			// CreateRelation - shouldn't be needed for now since we're not autogenerating infatuo relations, but may be used in future
 | 
			
		||||
			public override void CreateRelation(Pawn generated, Pawn other, ref PawnGenerationRequest request)
 | 
			
		||||
			{
 | 
			
		||||
				return;
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			// GenerationChance - should NEVER autogenerate on pawns (for now, anyway)
 | 
			
		||||
			public override float GenerationChance(Pawn generated, Pawn other, PawnGenerationRequest request)
 | 
			
		||||
			{
 | 
			
		||||
				return 0.0f;
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			public override bool InRelation(Pawn me, Pawn other)
 | 
			
		||||
			{
 | 
			
		||||
				return (me.health.hediffSet.GetFirstHediff<Hediff_Infatuo>().target == other);
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		public class Hediff_Infatuo : Hediff
 | 
			
		||||
		{
 | 
			
		||||
			public Hediff_Infatuo(Pawn intTarget)
 | 
			
		||||
			{
 | 
			
		||||
				target = intTarget;
 | 
			
		||||
			}
 | 
			
		||||
			public Pawn target;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		public class Hediff_InfatuoCalibrating : Hediff
 | 
			
		||||
		{
 | 
			
		||||
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}*/
 | 
			
		||||
							
								
								
									
										35
									
								
								Source/Helpers/LBTLogger.cs
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										35
									
								
								Source/Helpers/LBTLogger.cs
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,35 @@
 | 
			
		|||
using Verse;
 | 
			
		||||
 | 
			
		||||
namespace LewdBiotech.Helpers
 | 
			
		||||
{
 | 
			
		||||
    public static class LBTLogger
 | 
			
		||||
    {
 | 
			
		||||
        public static void Message(string message)
 | 
			
		||||
        {
 | 
			
		||||
            Log.Message("[INFO][LewdBT] - " + message);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public static void Warning(string message)
 | 
			
		||||
        {
 | 
			
		||||
            Log.Message("[WARN][LewdBT] - " + message);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public static void Error(string message)
 | 
			
		||||
        {
 | 
			
		||||
            Log.Message("[ ERR][LewdBT] - " + message);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public static void MessageGroupHead(string message)
 | 
			
		||||
        {
 | 
			
		||||
            Log.Message("[INFO][LewdBT]╦═ " + message);
 | 
			
		||||
        }
 | 
			
		||||
        public static void MessageGroupBody(string message)
 | 
			
		||||
        {
 | 
			
		||||
            Log.Message("[INFO][LewdBT]╠═══ " + message);
 | 
			
		||||
        }
 | 
			
		||||
        public static void MessageGroupFoot(string message)
 | 
			
		||||
        {
 | 
			
		||||
            Log.Message("[INFO][LewdBT]╚═══ " + message);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										28
									
								
								Source/Helpers/LaborState.cs
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								Source/Helpers/LaborState.cs
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,28 @@
 | 
			
		|||
using System;
 | 
			
		||||
using RimWorld;
 | 
			
		||||
using Verse;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Text;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
 | 
			
		||||
namespace LewdBiotech
 | 
			
		||||
{
 | 
			
		||||
    class LaborState
 | 
			
		||||
    {
 | 
			
		||||
        public Pawn pawn;
 | 
			
		||||
        public int birthTotal = 0;
 | 
			
		||||
        public int birthCount = 1;
 | 
			
		||||
        public bool hasOvaryAgitator = false;
 | 
			
		||||
        public bool hasBioscaffold = false;
 | 
			
		||||
 | 
			
		||||
        public LaborState(Pawn pawn, int birthTotal)
 | 
			
		||||
        {
 | 
			
		||||
            this.pawn = pawn;
 | 
			
		||||
            this.birthTotal = birthTotal;
 | 
			
		||||
            this.birthCount = 0;
 | 
			
		||||
            this.hasOvaryAgitator = pawn.health.hediffSet.HasHediff(HediffDef.Named("OvaryAgitator"));
 | 
			
		||||
            this.hasBioscaffold = pawn.health.hediffSet.HasHediff(HediffDef.Named("OvaryAgitator"));
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										255
									
								
								Source/LewdBiotech.cs
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										255
									
								
								Source/LewdBiotech.cs
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,255 @@
 | 
			
		|||
using HarmonyLib;
 | 
			
		||||
using RimWorld;
 | 
			
		||||
using rjw;
 | 
			
		||||
using LewdBiotech.Helpers;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using Verse;
 | 
			
		||||
 | 
			
		||||
namespace LewdBiotech
 | 
			
		||||
{
 | 
			
		||||
    [StaticConstructorOnStartup]
 | 
			
		||||
    public class LewdBiotechMod
 | 
			
		||||
    {
 | 
			
		||||
		public static readonly ThoughtDef regretsStealingLovin = DefDatabase<ThoughtDef>.GetNamed("RegretsStealingLovin");
 | 
			
		||||
		public static readonly ThoughtDef stoleSomeLovin = DefDatabase<ThoughtDef>.GetNamed("StoleSomeLovin");
 | 
			
		||||
		public static readonly ThoughtDef bloodlustStoleSomeLovin = DefDatabase<ThoughtDef>.GetNamed("BloodlustStoleSomeLovin");
 | 
			
		||||
		public static readonly TraitDef rapist = DefDatabase<TraitDef>.GetNamed("Rapist");
 | 
			
		||||
		static Dictionary<string, LaborState> laborStateMap = new Dictionary<string, LaborState>();
 | 
			
		||||
 | 
			
		||||
		static LewdBiotechMod()
 | 
			
		||||
        {
 | 
			
		||||
            Harmony harmony = new Harmony(id: "rimworld.leboeuf.lewdbiotech");
 | 
			
		||||
 | 
			
		||||
			// Non-rapist would_rape bypass for limbic stimulator - may be unused
 | 
			
		||||
			harmony.Patch(AccessTools.Method(typeof(SexAppraiser), nameof(SexAppraiser.would_rape)), 
 | 
			
		||||
				postfix: new HarmonyMethod(typeof(LewdBiotechMod), nameof(would_rape_PostFix)));
 | 
			
		||||
 | 
			
		||||
			// Non-rapist is_rapist bypass for limbic stimulator
 | 
			
		||||
			harmony.Patch(AccessTools.Method(typeof(xxx), nameof(xxx.is_rapist)),
 | 
			
		||||
				postfix: new HarmonyMethod(typeof(LewdBiotechMod), nameof(is_rapist_PostFix)));
 | 
			
		||||
 | 
			
		||||
			// Non-Rapist trait rape thoughts
 | 
			
		||||
			harmony.Patch(AccessTools.Method(typeof(AfterSexUtility), nameof(AfterSexUtility.think_about_sex_Rapist)),
 | 
			
		||||
				postfix: new HarmonyMethod(typeof(LewdBiotechMod), nameof(think_about_sex_Rapist_PostFix)));
 | 
			
		||||
 | 
			
		||||
			// Bioscaffold double gestation speed tick
 | 
			
		||||
			harmony.Patch(AccessTools.Method(typeof(Hediff_Pregnant), nameof(Hediff_Pregnant.Tick)),
 | 
			
		||||
				postfix: new HarmonyMethod(typeof(LewdBiotechMod), nameof(Hediff_Pregnant_TickPostFix)));
 | 
			
		||||
 | 
			
		||||
			// Hediff_Labor state capture
 | 
			
		||||
			harmony.Patch(AccessTools.Method(typeof(Hediff_Labor), nameof(Hediff_Labor.PostRemoved)),
 | 
			
		||||
				postfix: new HarmonyMethod(typeof(LewdBiotechMod), nameof(Hediff_Labor_PostRemovedPostFix)));
 | 
			
		||||
 | 
			
		||||
			// OvaryAgitator/Gene_LitteredBirths multibirth logic
 | 
			
		||||
			harmony.Patch(AccessTools.Method(typeof(Hediff_LaborPushing), nameof(Hediff_LaborPushing.PostRemoved)),
 | 
			
		||||
				postfix: new HarmonyMethod(typeof(LewdBiotechMod), nameof(Hediff_LaborPushing_PostRemovedPostFix)));
 | 
			
		||||
 | 
			
		||||
			// =================================================================================================
 | 
			
		||||
			// Future content - Infatuo implant (possibly - don't know if I'm going to finish it; mixed feelings
 | 
			
		||||
			/*			harmony.Patch(AccessTools.Method(typeof(InteractionUtility), nameof(InteractionWorker.Interacted)),
 | 
			
		||||
							postfix: new HarmonyMethod(typeof(LewdBiotech), nameof(InteractionWorker_InteractedPostfix)));*/
 | 
			
		||||
			// =================================================================================================
 | 
			
		||||
 | 
			
		||||
			LBTLogger.Message("Lewd Biotech started successfully.");
 | 
			
		||||
			
 | 
			
		||||
			if (LBTSettings.devMode)
 | 
			
		||||
            {
 | 
			
		||||
				LBTLogger.Message("Notice: Developer logging for Lewd Biotech is currently active - it can be disabled in the mod settings.");
 | 
			
		||||
            }
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// Is this even used??? I haven't seen it be hit in debug logs yet ...
 | 
			
		||||
		// Keeping it here for now, I suppose.
 | 
			
		||||
		static void would_rape_PostFix(ref bool __result, Pawn rapist)
 | 
			
		||||
		{
 | 
			
		||||
			if (rapist.health.hediffSet.HasHediff(HediffDef.Named("LimbicStimulator")))
 | 
			
		||||
			{
 | 
			
		||||
				if (LBTSettings.devMode)
 | 
			
		||||
                {
 | 
			
		||||
					LBTLogger.MessageGroupHead("Found LimbicStimulator hediff during xxx.would_rape check");
 | 
			
		||||
					LBTLogger.MessageGroupBody("Pawn: " + rapist.NameShortColored + " (" + rapist.ThingID + ")");
 | 
			
		||||
					LBTLogger.MessageGroupBody("__result (Before roll): " + __result);
 | 
			
		||||
                }
 | 
			
		||||
				__result = Rand.Chance(0.95f);
 | 
			
		||||
				if (LBTSettings.devMode)
 | 
			
		||||
                {
 | 
			
		||||
					LBTLogger.MessageGroupFoot("__result (After roll): " + __result);
 | 
			
		||||
                }
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		static void is_rapist_PostFix(ref bool __result, Pawn pawn)
 | 
			
		||||
        {
 | 
			
		||||
			if (pawn.health.hediffSet.HasHediff(HediffDef.Named("LimbicStimulator")))
 | 
			
		||||
			{
 | 
			
		||||
				if (LBTSettings.devMode)
 | 
			
		||||
				{
 | 
			
		||||
					LBTLogger.Message("Found LimbicStimulator hediff during xxx.is_rapist check for " + pawn.NameShortColored + " (" + pawn.ThingID + ")" + " with __result = " + __result + " - forcing to true");
 | 
			
		||||
					__result = true;
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		static void think_about_sex_Rapist_PostFix(ref ThoughtDef __result, Pawn pawn)
 | 
			
		||||
        {
 | 
			
		||||
			if (LBTSettings.regretStealingLovinThoughtDisabled) return;
 | 
			
		||||
 | 
			
		||||
			if (pawn.health.hediffSet.HasHediff(HediffDef.Named("LimbicStimulator")) && (__result == stoleSomeLovin || __result == bloodlustStoleSomeLovin) && !pawn.story.traits.HasTrait(rapist))
 | 
			
		||||
			{
 | 
			
		||||
				__result = regretsStealingLovin;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		static void Hediff_Pregnant_TickPostFix(ref Hediff_Pregnant __instance)
 | 
			
		||||
        {
 | 
			
		||||
			// 60000 = 1 day ticks
 | 
			
		||||
			// 0.055 = severity/gestation per day
 | 
			
		||||
			// 0.000000916 (repeating) = target for "2x pregnancy speed"-ish
 | 
			
		||||
			// Note for posterity: my original calucation ousted me as COMICALLY bad at math
 | 
			
		||||
			// I also need to do a performance analysis on this - having this run every pregnant tick with multiple pawns on a map may be super expensive
 | 
			
		||||
			if (__instance.pawn.health.hediffSet.HasHediff(HediffDef.Named("Bioscaffold")) && __instance.pawn.health.hediffSet.HasHediff(HediffDef.Named("PregnantHuman")))
 | 
			
		||||
			{
 | 
			
		||||
				__instance.Severity = __instance.Severity + 0.000000916f;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// Notes about Hediff_Labor_PostRemovedPostFix
 | 
			
		||||
		// ===========================================
 | 
			
		||||
		// Alright, didn't really want to make a patch for Labor as well as LaborPushing, but I have to because otherwise there's
 | 
			
		||||
		// no way to assign a doctor on second/third/etc births if I only use LaborPushing, which can disproportionately cause
 | 
			
		||||
		// more stillbirths than you might normally have
 | 
			
		||||
		//
 | 
			
		||||
		// I TRIED to modify the ChildBirth lord job and ritual code to allow the first doctor that was assigned and any childbirth
 | 
			
		||||
		// attendees to just autoreassign themselves to the next births, but it wasn't working - for now, I'm not happy with how I'm
 | 
			
		||||
		// doing this because multiple births now require:
 | 
			
		||||
		// 1. (potentially several) forced pauses with letters telling the player to reassign a doctor to the mother who's giving birth to another child
 | 
			
		||||
		// 2. A LOT of state carrying (that I likely overengineered :v) ) between hediff removes and adds
 | 
			
		||||
		//
 | 
			
		||||
		// I've got a dictionary now for storing state across hediffs and on multiple pawns, instead of what I was originally doing, which was using
 | 
			
		||||
		// severity as a way of tracking state. LaborState class should help keep things a little more organized.
 | 
			
		||||
		//
 | 
			
		||||
		// I'll revisit this in the future (probably). Thanks for coming to my TED talk
 | 
			
		||||
		static void Hediff_Labor_PostRemovedPostFix(ref Hediff_Labor __instance)
 | 
			
		||||
        {
 | 
			
		||||
			bool randomTwinsRoll;
 | 
			
		||||
			int totalBirths;
 | 
			
		||||
			bool laborStateIsNull = !laborStateMap.ContainsKey(__instance.pawn.ThingID);
 | 
			
		||||
			bool hasLitteredBirthsGene = __instance.pawn.genes.HasGene(LewdBiotech.GeneDefOf.LitteredBirths);
 | 
			
		||||
 | 
			
		||||
			// we'll never do additional processing if this is the guaranteed last birth (eg birth #4)
 | 
			
		||||
			if (!laborStateIsNull && laborStateMap.TryGetValue(__instance.pawn.ThingID).birthCount == 4) 
 | 
			
		||||
			{
 | 
			
		||||
				return;
 | 
			
		||||
            }
 | 
			
		||||
			
 | 
			
		||||
			// For now, littered birth overrides ovary agitator and twin calculations, so if a LaborState already exists
 | 
			
		||||
			// with littered births gene, move on
 | 
			
		||||
			if (!laborStateIsNull && hasLitteredBirthsGene)
 | 
			
		||||
            {
 | 
			
		||||
				if (LBTSettings.devMode)
 | 
			
		||||
				{
 | 
			
		||||
					LBTLogger.MessageGroupHead("Found active LaborState and LitteredBirths gene - skipping additional Hediff_Labor_PostRemovedPostFix work");
 | 
			
		||||
					LBTLogger.MessageGroupBody("Pawn: " + __instance.pawn.NameShortColored + " (" + __instance.pawn.ThingID + ")");
 | 
			
		||||
					LBTLogger.MessageGroupFoot("birthCount: " + laborStateMap.TryGetValue(__instance.pawn.ThingID).birthCount);
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
				return;
 | 
			
		||||
            }
 | 
			
		||||
			
 | 
			
		||||
			// Make a new LaborState for the null case with littered births
 | 
			
		||||
			if (laborStateIsNull && hasLitteredBirthsGene)
 | 
			
		||||
            {
 | 
			
		||||
				LBTLogger.Message("Found littered births gene");
 | 
			
		||||
				int litteredBirthsTotalRoll = Rand.RangeInclusive(2, 4);
 | 
			
		||||
				laborStateMap.SetOrAdd(__instance.pawn.ThingID, new LaborState(__instance.pawn, litteredBirthsTotalRoll));
 | 
			
		||||
				return;
 | 
			
		||||
            }
 | 
			
		||||
			
 | 
			
		||||
			// Finally, regardless of littered births gene, we only want new state creation on
 | 
			
		||||
			// pawns that don't already have state, so return if state is !null (STATE SHOULD ALWAYS BE CLEANED IN LABORPUSHING POSTFIX)
 | 
			
		||||
			if (!laborStateIsNull)
 | 
			
		||||
            {
 | 
			
		||||
				if (LBTSettings.devMode)
 | 
			
		||||
                {
 | 
			
		||||
					LBTLogger.Warning("Labor state for pawn " + __instance.pawn.NameShortColored + " (" + __instance.pawn.ThingID + ") is not null despite all checks passing for determining first instance of Hediff_Labor - this warning should never occur, and may indicate a bug in Hediff_LaborPushing of lingering labor state from a previous pregnancy");
 | 
			
		||||
                }
 | 
			
		||||
				return;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
			// For everything else, we do random twin and OvaryAgitator handling
 | 
			
		||||
			// -------
 | 
			
		||||
			// If we fail a base chance twins roll, return without any additional processing and proceed with vanilla childbirth
 | 
			
		||||
			// Notes on rolls:
 | 
			
		||||
			// -> Chance without OvaryAgitator to have twins: 1%
 | 
			
		||||
			// -> Chance with OvaryAgitator to have twins: Guaranteed
 | 
			
		||||
			// ---> Chance with OvaryAgitator to have triplets (MUST HAVE SUCCEEDED TWINS ROLL): 50%
 | 
			
		||||
			// ---> Chance with OvaryAgitator to have quadruplets (MUST HAVE SUCCEEDED TRIPLETS ROLL): 10%
 | 
			
		||||
			// -> Chance with Littered Births gene: random between 2 and 4 (inclusive)
 | 
			
		||||
			randomTwinsRoll = Rand.Chance(0.01f);
 | 
			
		||||
			bool hasAgitator = __instance.pawn.health.hediffSet.HasHediff(HediffDef.Named("OvaryAgitator"));
 | 
			
		||||
			if (!randomTwinsRoll && !hasAgitator)
 | 
			
		||||
			{
 | 
			
		||||
				// We failed rolls, and we don't have an agitator - no additional processing, do vanilla single baby birth
 | 
			
		||||
				if (LBTSettings.devMode)
 | 
			
		||||
				{
 | 
			
		||||
					LBTLogger.MessageGroupHead("Inside Hediff_Labor_PostRemovedPostFix random twins check fail");
 | 
			
		||||
					LBTLogger.MessageGroupBody("Pawn: " + __instance.pawn.NameShortColored);
 | 
			
		||||
					LBTLogger.MessageGroupBody("Random twins roll outcome: " + randomTwinsRoll);
 | 
			
		||||
					LBTLogger.MessageGroupFoot("Has OvaryAgitator: " + hasAgitator);
 | 
			
		||||
				}
 | 
			
		||||
				return;
 | 
			
		||||
			}
 | 
			
		||||
			
 | 
			
		||||
			// Beyond this point, we can assume the pawn has an agitator
 | 
			
		||||
			totalBirths = 2;
 | 
			
		||||
			bool agitatorTriplets = Rand.Chance(0.5f);
 | 
			
		||||
			bool agitatorQuadruplets = Rand.Chance(0.1f);
 | 
			
		||||
			if (hasAgitator)
 | 
			
		||||
            {
 | 
			
		||||
				if (agitatorTriplets) totalBirths = 3;
 | 
			
		||||
				if (agitatorTriplets && agitatorQuadruplets) totalBirths = 4;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
			// Set new LaborState
 | 
			
		||||
			laborStateMap.Add(__instance.pawn.ThingID, new LaborState(__instance.pawn, totalBirths));
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		static void Hediff_LaborPushing_PostRemovedPostFix(ref Hediff_LaborPushing __instance)
 | 
			
		||||
        {
 | 
			
		||||
			bool hasAgitator = __instance.pawn.health.hediffSet.HasHediff(HediffDef.Named("OvaryAgitator"));
 | 
			
		||||
			bool hasLitteredBirthsGene = __instance.pawn.genes.HasGene(LewdBiotech.GeneDefOf.LitteredBirths);
 | 
			
		||||
			bool laborStateIsNull = !laborStateMap.ContainsKey(__instance.pawn.ThingID);
 | 
			
		||||
			LaborState currentLaborState;
 | 
			
		||||
			laborStateMap.TryGetValue(__instance.pawn.ThingID, out currentLaborState);
 | 
			
		||||
 | 
			
		||||
			if (laborStateIsNull)
 | 
			
		||||
            {
 | 
			
		||||
				return;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
			if (currentLaborState.birthTotal == currentLaborState.birthCount)
 | 
			
		||||
			{
 | 
			
		||||
				laborStateMap.Remove(__instance.pawn.ThingID);
 | 
			
		||||
				if (__instance.pawn.health.hediffSet.HasHediff(HediffDef.Named("Bioscaffold"))) {
 | 
			
		||||
					__instance.pawn.health.RemoveHediff(__instance.pawn.health.hediffSet.GetFirstHediffOfDef(LewdBiotech.HediffDefOf.Bioscaffold));
 | 
			
		||||
                }
 | 
			
		||||
				return;
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			((Hediff_Labor)__instance.pawn.health.AddHediff(RimWorld.HediffDefOf.PregnancyLabor)).SetParents(__instance.pawn, __instance.Father, PregnancyUtility.GetInheritedGeneSet(__instance.Father, __instance.pawn));
 | 
			
		||||
			currentLaborState.birthCount++;
 | 
			
		||||
 | 
			
		||||
			if (!hasAgitator && !hasLitteredBirthsGene)
 | 
			
		||||
			{
 | 
			
		||||
				if (LBTSettings.devMode)
 | 
			
		||||
                {
 | 
			
		||||
					LBTLogger.Message("Pawn " + __instance.pawn.NameShortColored + " (" + __instance.pawn.ThingID + ") is having random twins");
 | 
			
		||||
                }
 | 
			
		||||
				Find.LetterStack.ReceiveLetter("Twins!", __instance.pawn.NameShortColored + " is still in labor and is having twins!\n\nBe sure to gather your doctor and additional friends and family to ensure the other baby is also born healthy!", LewdBiotech.LetterDefOf.AnotherBaby, __instance.pawn);
 | 
			
		||||
				return;
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			Find.LetterStack.ReceiveLetter("Another baby!", __instance.pawn.NameShortColored + " is still in labor and is having another baby!\n\nBe sure to gather your doctor and additional friends and family to ensure the next baby is also born healthy!", LewdBiotech.LetterDefOf.AnotherBaby, __instance.pawn);
 | 
			
		||||
        }
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										77
									
								
								Source/LewdBiotech.csproj
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										77
									
								
								Source/LewdBiotech.csproj
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,77 @@
 | 
			
		|||
<?xml version="1.0" encoding="utf-8"?>
 | 
			
		||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
 | 
			
		||||
  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
 | 
			
		||||
  <PropertyGroup>
 | 
			
		||||
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
 | 
			
		||||
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
 | 
			
		||||
    <ProjectGuid>{D7D21B4A-1DA7-41D8-B202-C58CA8FA62AA}</ProjectGuid>
 | 
			
		||||
    <OutputType>Library</OutputType>
 | 
			
		||||
    <AppDesignerFolder>Properties</AppDesignerFolder>
 | 
			
		||||
    <RootNamespace>LewdBiotech</RootNamespace>
 | 
			
		||||
    <AssemblyName>LewdBiotech</AssemblyName>
 | 
			
		||||
    <TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
 | 
			
		||||
    <FileAlignment>512</FileAlignment>
 | 
			
		||||
    <TargetFrameworkProfile />
 | 
			
		||||
  </PropertyGroup>
 | 
			
		||||
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
 | 
			
		||||
    <DebugType>none</DebugType>
 | 
			
		||||
    <Optimize>true</Optimize>
 | 
			
		||||
    <OutputPath>..\1.4\Assemblies\</OutputPath>
 | 
			
		||||
    <ErrorReport>prompt</ErrorReport>
 | 
			
		||||
    <WarningLevel>4</WarningLevel>
 | 
			
		||||
    <Prefer32Bit>false</Prefer32Bit>
 | 
			
		||||
  </PropertyGroup>
 | 
			
		||||
  <PropertyGroup>
 | 
			
		||||
    <RunPostBuildEvent>Always</RunPostBuildEvent>
 | 
			
		||||
  </PropertyGroup>
 | 
			
		||||
  <ItemGroup>
 | 
			
		||||
    <Reference Include="0Harmony">
 | 
			
		||||
      <HintPath>..\..\..\..\..\workshop\content\294100\2009463077\Current\Assemblies\0Harmony.dll</HintPath>
 | 
			
		||||
    </Reference>
 | 
			
		||||
    <Reference Include="0MultiplayerAPI">
 | 
			
		||||
      <HintPath>..\..\rjw\1.4\Assemblies\0MultiplayerAPI.dll</HintPath>
 | 
			
		||||
    </Reference>
 | 
			
		||||
    <Reference Include="Assembly-CSharp">
 | 
			
		||||
      <HintPath>..\..\..\RimWorldWin64_Data\Managed\Assembly-CSharp.dll</HintPath>
 | 
			
		||||
      <Private>False</Private>
 | 
			
		||||
    </Reference>
 | 
			
		||||
    <Reference Include="HarmonyMod">
 | 
			
		||||
      <HintPath>..\..\..\..\..\workshop\content\294100\2009463077\Current\Assemblies\HarmonyMod.dll</HintPath>
 | 
			
		||||
    </Reference>
 | 
			
		||||
    <Reference Include="RJW">
 | 
			
		||||
      <HintPath>..\..\rjw\1.4\Assemblies\RJW.dll</HintPath>
 | 
			
		||||
    </Reference>
 | 
			
		||||
    <Reference Include="System" />
 | 
			
		||||
    <Reference Include="System.Core" />
 | 
			
		||||
    <Reference Include="System.Xml.Linq" />
 | 
			
		||||
    <Reference Include="System.Data.DataSetExtensions" />
 | 
			
		||||
    <Reference Include="System.Data" />
 | 
			
		||||
    <Reference Include="System.Xml" />
 | 
			
		||||
    <Reference Include="UnityEngine">
 | 
			
		||||
      <HintPath>..\..\..\RimWorldWin64_Data\Managed\UnityEngine.CoreModule.dll</HintPath>
 | 
			
		||||
      <Private>False</Private>
 | 
			
		||||
    </Reference>
 | 
			
		||||
    <None Include="..\About\**" />
 | 
			
		||||
    <None Include="..\Common\Defs\**" />
 | 
			
		||||
    <None Include="..\Common\Languages\**" />
 | 
			
		||||
    <None Include="..\Common\Patches\**" />
 | 
			
		||||
  </ItemGroup>
 | 
			
		||||
  <ItemGroup>
 | 
			
		||||
    <Compile Include="DefOf\GeneDefOf.cs" />
 | 
			
		||||
    <Compile Include="DefOf\HediffDefOf.cs" />
 | 
			
		||||
    <Compile Include="Hediffs\Infatuo.cs" />
 | 
			
		||||
    <Compile Include="Helpers\LBTLogger.cs" />
 | 
			
		||||
    <Compile Include="Helpers\LaborState.cs" />
 | 
			
		||||
    <Compile Include="DefOf\LetterDefOf.cs" />
 | 
			
		||||
    <Compile Include="LewdBiotech.cs" />
 | 
			
		||||
    <Compile Include="Properties\AssemblyInfo.cs" />
 | 
			
		||||
    <Compile Include="Settings\LBTSettings.cs" />
 | 
			
		||||
  </ItemGroup>
 | 
			
		||||
  <ItemGroup />
 | 
			
		||||
  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
 | 
			
		||||
  <PropertyGroup>
 | 
			
		||||
    <PostBuildEvent>copy "$(SolutionDir)Source\obj\Release\$(SolutionName).dll" "$(SolutionDir)1.4\Assemblies"
 | 
			
		||||
$(SolutionDir)..\..\RimWorldWin64.exe
 | 
			
		||||
</PostBuildEvent>
 | 
			
		||||
  </PropertyGroup>
 | 
			
		||||
</Project>
 | 
			
		||||
							
								
								
									
										36
									
								
								Source/Properties/AssemblyInfo.cs
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										36
									
								
								Source/Properties/AssemblyInfo.cs
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,36 @@
 | 
			
		|||
using System.Reflection;
 | 
			
		||||
using System.Runtime.CompilerServices;
 | 
			
		||||
using System.Runtime.InteropServices;
 | 
			
		||||
 | 
			
		||||
// General Information about an assembly is controlled through the following
 | 
			
		||||
// set of attributes. Change these attribute values to modify the information
 | 
			
		||||
// associated with an assembly.
 | 
			
		||||
[assembly: AssemblyTitle("LewdBiotech")]
 | 
			
		||||
[assembly: AssemblyDescription("")]
 | 
			
		||||
[assembly: AssemblyConfiguration("")]
 | 
			
		||||
[assembly: AssemblyCompany("")]
 | 
			
		||||
[assembly: AssemblyProduct("LewdBiotech")]
 | 
			
		||||
[assembly: AssemblyCopyright("Copyright ©  2020")]
 | 
			
		||||
[assembly: AssemblyTrademark("")]
 | 
			
		||||
[assembly: AssemblyCulture("")]
 | 
			
		||||
 | 
			
		||||
// Setting ComVisible to false makes the types in this assembly not visible
 | 
			
		||||
// to COM components.  If you need to access a type in this assembly from
 | 
			
		||||
// COM, set the ComVisible attribute to true on that type.
 | 
			
		||||
[assembly: ComVisible(false)]
 | 
			
		||||
 | 
			
		||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
 | 
			
		||||
[assembly: Guid("d7d21b4a-1da7-41d8-b202-c58ca8fa62aa")]
 | 
			
		||||
 | 
			
		||||
// Version information for an assembly consists of the following four values:
 | 
			
		||||
//
 | 
			
		||||
//      Major Version
 | 
			
		||||
//      Minor Version
 | 
			
		||||
//      Build Number
 | 
			
		||||
//      Revision
 | 
			
		||||
//
 | 
			
		||||
// You can specify all the values or you can default the Build and Revision Numbers
 | 
			
		||||
// by using the '*' as shown below:
 | 
			
		||||
// [assembly: AssemblyVersion("1.0.*")]
 | 
			
		||||
[assembly: AssemblyVersion("1.0.0.0")]
 | 
			
		||||
[assembly: AssemblyFileVersion("1.0.0.0")]
 | 
			
		||||
							
								
								
									
										54
									
								
								Source/Settings/LBTSettings.cs
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										54
									
								
								Source/Settings/LBTSettings.cs
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,54 @@
 | 
			
		|||
using UnityEngine;
 | 
			
		||||
using Verse;
 | 
			
		||||
 | 
			
		||||
// If it isn't blatantly obvious, I unabashedly ripped this settings template from RJW, minus the fact that
 | 
			
		||||
// I won't be (personally) supporting multiplayer, and it's all in one file - but I digress ...
 | 
			
		||||
namespace LewdBiotech
 | 
			
		||||
{
 | 
			
		||||
    class LBTSettingsController : Mod
 | 
			
		||||
    {
 | 
			
		||||
        public LBTSettingsController(ModContentPack content) : base(content)
 | 
			
		||||
        {
 | 
			
		||||
            GetSettings<LBTSettings>();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public override string SettingsCategory()
 | 
			
		||||
        {
 | 
			
		||||
            return "LBTSettings".Translate();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public override void DoSettingsWindowContents(Rect inRect)
 | 
			
		||||
        {
 | 
			
		||||
            LBTSettings.DoWindowContents(inRect);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public class LBTSettings : ModSettings
 | 
			
		||||
    {
 | 
			
		||||
        // For my own sanity, all now and future settings will have a default disabled/false state (at least, that's the plan), and
 | 
			
		||||
        // the settings name and description should reflect that (not that I'm going to add that many settings, mind you)
 | 
			
		||||
		public static bool devMode = false;
 | 
			
		||||
        public static bool regretStealingLovinThoughtDisabled = false;
 | 
			
		||||
 | 
			
		||||
        public static void DoWindowContents(Rect inRect)
 | 
			
		||||
        {
 | 
			
		||||
            // Shrink the settings window a bit - don't need to be that w i d e
 | 
			
		||||
            inRect.width = inRect.width - 400;
 | 
			
		||||
            inRect.x = inRect.x + 200;
 | 
			
		||||
            Listing_Standard listingStandard = new Listing_Standard();
 | 
			
		||||
            listingStandard.Begin(inRect);
 | 
			
		||||
            listingStandard.Gap(4f);
 | 
			
		||||
            listingStandard.CheckboxLabeled("EnableLBTDevLogging".Translate(), ref devMode, "EnableLBTDevLoggingDesc".Translate());
 | 
			
		||||
            listingStandard.Gap(4f);
 | 
			
		||||
            listingStandard.CheckboxLabeled("RegretStealingLovinThoughtDisabled".Translate(), ref regretStealingLovinThoughtDisabled, "RegretStealingLovinThoughtDisabledDesc".Translate());
 | 
			
		||||
            listingStandard.End();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public override void ExposeData()
 | 
			
		||||
        {
 | 
			
		||||
            base.ExposeData();
 | 
			
		||||
            Scribe_Values.Look(ref devMode, "EnableLBTDevLogging", devMode, true);
 | 
			
		||||
            Scribe_Values.Look(ref regretStealingLovinThoughtDisabled, "regretStealingLovinThoughtDisabled", regretStealingLovinThoughtDisabled, true);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue