diff --git a/About/About.xml b/About/About.xml
index a414d20..5d46796 100644
--- a/About/About.xml
+++ b/About/About.xml
@@ -13,13 +13,13 @@
RimJobWorld
https://www.loverslab.com/files/file/7257-rimjobworld/
-
diff --git a/Common/Assemblies/0Harmony.dll b/Common/Assemblies/0Harmony.dll
new file mode 100644
index 0000000..86fc5eb
Binary files /dev/null and b/Common/Assemblies/0Harmony.dll differ
diff --git a/Common/Assemblies/Rjw-Genes.dll b/Common/Assemblies/Rjw-Genes.dll
index 05fb3b0..db2c867 100644
Binary files a/Common/Assemblies/Rjw-Genes.dll and b/Common/Assemblies/Rjw-Genes.dll differ
diff --git a/Common/Defs/GeneDefs_Breeding.xml b/Common/Defs/GeneDefs_Breeding.xml
new file mode 100644
index 0000000..9e9a4a2
--- /dev/null
+++ b/Common/Defs/GeneDefs_Breeding.xml
@@ -0,0 +1,32 @@
+
+
+
+
+
+ rjw_genes_mechbreeder
+
+ Pawns with this gene are able to birth mechanoids unharmed.
+ World/WorldObjects/Expanding/Mechanoids
+ 51
+ rjw_genes_breeding
+
+
+
+ rjw_genes_insectincubator
+
+ Pawns with this gene are able to hold more insect eggs.
+ World/WorldObjects/Expanding/Mechanoids
+ 52
+ rjw_genes_breeding
+
+
+
+ rjw_genes_insectbreeder
+
+ Pawns with this gene are able to fertilize eggs with any fertile penis.
+ World/WorldObjects/Expanding/Mechanoids
+ 53
+ rjw_genes_breeding
+
+
+
\ No newline at end of file
diff --git a/Common/Defs/Genes/GeneCategories.xml b/Common/Defs/Genes/GeneCategories.xml
index 202545e..a5e53c1 100644
--- a/Common/Defs/Genes/GeneCategories.xml
+++ b/Common/Defs/Genes/GeneCategories.xml
@@ -18,4 +18,10 @@
16
+
+ rjw_genes_breeding
+
+ 15
+
+
\ No newline at end of file
diff --git a/Source/GeneDefOf.cs b/Source/GeneDefOf.cs
index cb300cd..e9a7362 100644
--- a/Source/GeneDefOf.cs
+++ b/Source/GeneDefOf.cs
@@ -47,5 +47,10 @@ namespace RJW_Genes
// Gender
[MayRequireBiotech] public static readonly GeneDef rjw_genes_female_only;
[MayRequireBiotech] public static readonly GeneDef rjw_genes_male_only;
+
+ // Breeding
+ public static readonly GeneDef rjw_genes_mechbreeder;
+ public static readonly GeneDef rjw_genes_insectincubator;
+ public static readonly GeneDef rjw_genes_insectbreeder;
}
}
diff --git a/Source/Genes/Breeding/Gene_MechBreeder.cs b/Source/Genes/Breeding/Gene_MechBreeder.cs
new file mode 100644
index 0000000..a0a8855
--- /dev/null
+++ b/Source/Genes/Breeding/Gene_MechBreeder.cs
@@ -0,0 +1,9 @@
+using Verse;
+
+namespace Genes.Breeding
+{
+ internal class Gene_MechBreeder : Gene
+ {
+ // This one does not do anything, the patch is some where else checking for the pawn to have this Gene!
+ }
+}
diff --git a/Source/Genes/Breeding/PatchMechBirth.cs b/Source/Genes/Breeding/PatchMechBirth.cs
new file mode 100644
index 0000000..c92e0a9
--- /dev/null
+++ b/Source/Genes/Breeding/PatchMechBirth.cs
@@ -0,0 +1,64 @@
+
+
+using System;
+using System.Collections.Generic;
+using System.Reflection;
+using System.Reflection.Emit;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using HarmonyLib;
+using rjw;
+
+namespace RJW_Genes
+{
+ ///
+ /// This Class patches the RJW-Mechbirth to not deal damage when the pawn has the MechBreeder Gene.
+ /// This harmony patch was kindly provided by 'shabalox' https://github.com/Shabalox/RJW_Genes_Addons/
+ ///
+ [HarmonyPatch(typeof(Hediff_MechanoidPregnancy), "GiveBirth")]
+ public static class PatchMechBirth
+ {
+ [HarmonyTranspiler]
+ public static IEnumerable Transpiler(IEnumerable instructions, ILGenerator il)
+ {
+ bool found_call = false;
+ bool found_skip = false;
+ Label skip_label = il.DefineLabel();
+ MethodInfo ismechbreeder = AccessTools.Method(typeof(GeneUtility), "IsMechbreeder");
+ foreach (CodeInstruction codeInstruction in instructions)
+ {
+ //Check if the first opcode after endfinally ldloc_0 is and in that case add the label to skip the code
+ if (found_skip && codeInstruction.opcode == OpCodes.Ldloc_0)
+ {
+ codeInstruction.labels.Add(skip_label);
+ }
+ found_skip = false;
+ if (codeInstruction.opcode == OpCodes.Endfinally)
+ {
+ found_skip = true;
+ }
+
+ yield return codeInstruction;
+
+ if (codeInstruction.opcode == OpCodes.Call)
+ {
+ if (codeInstruction.operand.ToString() == "Boolean TryMakeFilth(Verse.IntVec3, Verse.Map, Verse.ThingDef, System.String, Int32, RimWorld.FilthSourceFlags)")
+ {
+ found_call = true;
+ }
+ }
+ //Triggers after the pop opcode (after generating filth in c#).
+ else if (found_call)
+ {
+ //Load pawn, call function to check if a mechbreeder, and skip past the part which does damage
+ yield return new CodeInstruction(OpCodes.Ldloc_0, null);
+ yield return new CodeInstruction(OpCodes.Call, ismechbreeder);
+ yield return new CodeInstruction(OpCodes.Brtrue_S, skip_label);
+ found_call = false;
+ }
+ }
+ yield break;
+ }
+ }
+}
\ No newline at end of file
diff --git a/Source/Genes/Breeding/PatchPawnExtensions.cs b/Source/Genes/Breeding/PatchPawnExtensions.cs
new file mode 100644
index 0000000..2c36716
--- /dev/null
+++ b/Source/Genes/Breeding/PatchPawnExtensions.cs
@@ -0,0 +1,22 @@
+using HarmonyLib;
+using rjw;
+using Verse;
+
+namespace RJW_Genes
+{
+ ///
+ /// Kindly provided by 'shabalox' https://github.com/Shabalox/RJW_Genes_Addons/
+ ///
+ [HarmonyPatch(typeof(PawnExtensions), "RaceImplantEggs")]
+ public static class PatchPawnExtensions
+ {
+ [HarmonyPostfix]
+ public static void Postfix(Pawn pawn, ref bool __result)
+ {
+ if (!__result)
+ {
+ __result = GeneUtility.isInsectBreeder(pawn);
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/Source/Genes/Breeding/PatchPregnancyHelper.cs b/Source/Genes/Breeding/PatchPregnancyHelper.cs
new file mode 100644
index 0000000..81a0ad4
--- /dev/null
+++ b/Source/Genes/Breeding/PatchPregnancyHelper.cs
@@ -0,0 +1,54 @@
+using System;
+using System.Collections.Generic;
+using System.Reflection.Emit;
+using System.Reflection;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using HarmonyLib;
+using Verse;
+using RimWorld;
+using rjw;
+
+namespace RJW_Genes
+{
+ ///
+ /// This Class patches the RJW-DoEgg to allow up to MaxEggSizeMul times the original amount of eggs.
+ /// This harmony patch was kindly provided by 'shabalox' https://github.com/Shabalox/RJW_Genes_Addons/
+ ///
+ [HarmonyPatch(typeof(PregnancyHelper), "DoEgg")]
+ static class PatchPregnancyHelper
+ {
+ [HarmonyTranspiler]
+ public static IEnumerable Transpiler(IEnumerable instructions, ILGenerator il)
+ {
+ //MethodInfo isinsectincubator = AccessTools.Method(typeof(GeneUtility), "IsInsectIncubator");
+ MethodInfo maxeggsizemul = AccessTools.Method(typeof(GeneUtility), "MaxEggSizeMul");
+ FieldInfo partner = AccessTools.Field(typeof(SexProps), "partner");
+
+ Label skiplabel = il.DefineLabel();
+ bool finished = false;
+ foreach (CodeInstruction codeInstruction in instructions)
+ {
+ if (!finished)
+ {
+ if (codeInstruction.opcode == OpCodes.Ldc_R4 && codeInstruction.operand.ToString() == "0")
+ {
+ yield return new CodeInstruction(OpCodes.Ldarg_0, null);
+ yield return new CodeInstruction(OpCodes.Ldfld, partner);
+ //yield return new CodeInstruction(OpCodes.Call, isinsectincubator);
+ yield return new CodeInstruction(OpCodes.Callvirt, maxeggsizemul);
+ //yield return new CodeInstruction(OpCodes.Brfalse_S, skiplabel);
+ yield return new CodeInstruction(OpCodes.Ldloc_0, null);
+ //yield return new CodeInstruction(OpCodes.Ldc_R4, 2f);
+ yield return new CodeInstruction(OpCodes.Mul, null);
+ yield return new CodeInstruction(OpCodes.Stloc_0, null);
+ //codeInstruction.labels.Add(skiplabel);
+ finished = true;
+ }
+ }
+ yield return codeInstruction;
+ }
+ }
+ }
+}
diff --git a/Source/Genes/GeneUtility.cs b/Source/Genes/GeneUtility.cs
new file mode 100644
index 0000000..5144aad
--- /dev/null
+++ b/Source/Genes/GeneUtility.cs
@@ -0,0 +1,44 @@
+using Verse;
+
+namespace RJW_Genes
+{
+ public class GeneUtility
+ {
+ public static bool IsMechbreeder(Pawn pawn)
+ {
+ if (pawn.genes == null)
+ {
+ return false;
+ }
+ return pawn.genes.HasGene(GeneDefOf.rjw_genes_mechbreeder);
+ }
+
+ public static bool IsInsectIncubator(Pawn pawn)
+ {
+ if (pawn.genes == null)
+ {
+ return false;
+ }
+ return pawn.genes.HasGene(GeneDefOf.rjw_genes_insectincubator);
+ }
+
+ public static bool isInsectBreeder(Pawn pawn)
+ {
+ if (pawn.genes == null)
+ {
+ return false;
+ }
+ return pawn.genes.HasGene(GeneDefOf.rjw_genes_insectbreeder);
+ }
+
+ public static float MaxEggSizeMul(Pawn pawn)
+ {
+ float MaxEggSize = 1;
+ if (IsInsectIncubator(pawn))
+ {
+ MaxEggSize *= 2;
+ }
+ return MaxEggSize;
+ }
+ }
+}
\ No newline at end of file
diff --git a/Source/GenitaliaUtility.cs b/Source/Genes/Genitalia/GenitaliaUtility.cs
similarity index 100%
rename from Source/GenitaliaUtility.cs
rename to Source/Genes/Genitalia/GenitaliaUtility.cs
diff --git a/Source/HarmonyInit.cs b/Source/HarmonyInit.cs
new file mode 100644
index 0000000..c2f288e
--- /dev/null
+++ b/Source/HarmonyInit.cs
@@ -0,0 +1,16 @@
+using Verse;
+using HarmonyLib;
+
+
+namespace RJW_Genes
+{
+ [StaticConstructorOnStartup]
+ internal static class HarmonyInit
+ {
+ static HarmonyInit()
+ {
+ Harmony harmony = new Harmony("rjw_genes");
+ harmony.PatchAll();
+ }
+ }
+}
\ No newline at end of file
diff --git a/Source/Rjw-Genes.csproj b/Source/Rjw-Genes.csproj
index a284e5d..708cdb8 100644
--- a/Source/Rjw-Genes.csproj
+++ b/Source/Rjw-Genes.csproj
@@ -22,6 +22,9 @@
false
+
+ ..\..\..\..\..\workshop\content\294100\2009463077\Current\Assemblies\0Harmony.dll
+
..\..\..\RimWorldWin64_Data\Managed\Assembly-CSharp.dll
False
@@ -49,6 +52,10 @@
+
+
+
+
@@ -61,6 +68,7 @@
+
@@ -84,7 +92,8 @@
-
+
+