mirror of
https://github.com/vegapnk/RJW-Genes.git
synced 2024-08-15 00:23:31 +00:00
Adopted Breeding Genes by Shabalox
This commit is contained in:
parent
95fc9b89a0
commit
21fc56fe2b
14 changed files with 264 additions and 3 deletions
|
@ -13,13 +13,13 @@
|
||||||
<displayName>RimJobWorld</displayName>
|
<displayName>RimJobWorld</displayName>
|
||||||
<downloadUrl>https://www.loverslab.com/files/file/7257-rimjobworld/</downloadUrl>
|
<downloadUrl>https://www.loverslab.com/files/file/7257-rimjobworld/</downloadUrl>
|
||||||
</li>
|
</li>
|
||||||
<!--
|
|
||||||
<li>
|
<li>
|
||||||
<packageId>brrainz.harmony</packageId>
|
<packageId>brrainz.harmony</packageId>
|
||||||
<displayName>Harmony</displayName>
|
<displayName>Harmony</displayName>
|
||||||
<steamWorkshopUrl>steam://url/CommunityFilePage/2009463077</steamWorkshopUrl>
|
<steamWorkshopUrl>steam://url/CommunityFilePage/2009463077</steamWorkshopUrl>
|
||||||
<downloadUrl>https://github.com/pardeike/HarmonyRimWorld/releases/latest</downloadUrl>
|
<downloadUrl>https://github.com/pardeike/HarmonyRimWorld/releases/latest</downloadUrl>
|
||||||
</li>
|
</li>
|
||||||
|
<!--
|
||||||
<li>
|
<li>
|
||||||
<packageId>UnlimitedHugs.HugsLib</packageId>
|
<packageId>UnlimitedHugs.HugsLib</packageId>
|
||||||
<displayName>HugsLib</displayName>
|
<displayName>HugsLib</displayName>
|
||||||
|
@ -30,8 +30,8 @@
|
||||||
</modDependencies>
|
</modDependencies>
|
||||||
<loadAfter>
|
<loadAfter>
|
||||||
<li>rim.job.world</li>
|
<li>rim.job.world</li>
|
||||||
<!--
|
|
||||||
<li>brrainz.harmony</li>
|
<li>brrainz.harmony</li>
|
||||||
|
<!--
|
||||||
<li>UnlimitedHugs.HugsLib</li>
|
<li>UnlimitedHugs.HugsLib</li>
|
||||||
-->
|
-->
|
||||||
</loadAfter>
|
</loadAfter>
|
||||||
|
|
BIN
Common/Assemblies/0Harmony.dll
Normal file
BIN
Common/Assemblies/0Harmony.dll
Normal file
Binary file not shown.
Binary file not shown.
32
Common/Defs/GeneDefs_Breeding.xml
Normal file
32
Common/Defs/GeneDefs_Breeding.xml
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<Defs>
|
||||||
|
<!-- rjw_genes_mechbreeder,rjw_genes_insectincubator and rjw_genes_insectbreeder were kindly supplied by `Shabalox` https://github.com/Shabalox/RJW_Genes_Addons/ -->
|
||||||
|
|
||||||
|
<GeneDef>
|
||||||
|
<defName>rjw_genes_mechbreeder</defName>
|
||||||
|
<label>Mechbreeder</label>
|
||||||
|
<description>Pawns with this gene are able to birth mechanoids unharmed.</description>
|
||||||
|
<iconPath>World/WorldObjects/Expanding/Mechanoids</iconPath>
|
||||||
|
<displayOrderInCategory>51</displayOrderInCategory>
|
||||||
|
<displayCategory>rjw_genes_breeding</displayCategory>
|
||||||
|
</GeneDef>
|
||||||
|
|
||||||
|
<GeneDef>
|
||||||
|
<defName>rjw_genes_insectincubator</defName>
|
||||||
|
<label>InsectIncubator</label>
|
||||||
|
<description>Pawns with this gene are able to hold more insect eggs.</description>
|
||||||
|
<iconPath>World/WorldObjects/Expanding/Mechanoids</iconPath>
|
||||||
|
<displayOrderInCategory>52</displayOrderInCategory>
|
||||||
|
<displayCategory>rjw_genes_breeding</displayCategory>
|
||||||
|
</GeneDef>
|
||||||
|
|
||||||
|
<GeneDef>
|
||||||
|
<defName>rjw_genes_insectbreeder</defName>
|
||||||
|
<label>InsectBreeder</label>
|
||||||
|
<description>Pawns with this gene are able to fertilize eggs with any fertile penis.</description>
|
||||||
|
<iconPath>World/WorldObjects/Expanding/Mechanoids</iconPath>
|
||||||
|
<displayOrderInCategory>53</displayOrderInCategory>
|
||||||
|
<displayCategory>rjw_genes_breeding</displayCategory>
|
||||||
|
</GeneDef>
|
||||||
|
|
||||||
|
</Defs>
|
|
@ -18,4 +18,10 @@
|
||||||
<displayPriorityInXenotype>16</displayPriorityInXenotype>
|
<displayPriorityInXenotype>16</displayPriorityInXenotype>
|
||||||
</GeneCategoryDef>
|
</GeneCategoryDef>
|
||||||
|
|
||||||
|
<GeneCategoryDef>
|
||||||
|
<defName>rjw_genes_breeding</defName>
|
||||||
|
<label>Breeding</label>
|
||||||
|
<displayPriorityInXenotype>15</displayPriorityInXenotype>
|
||||||
|
</GeneCategoryDef>
|
||||||
|
|
||||||
</Defs>
|
</Defs>
|
|
@ -47,5 +47,10 @@ namespace RJW_Genes
|
||||||
// Gender
|
// Gender
|
||||||
[MayRequireBiotech] public static readonly GeneDef rjw_genes_female_only;
|
[MayRequireBiotech] public static readonly GeneDef rjw_genes_female_only;
|
||||||
[MayRequireBiotech] public static readonly GeneDef rjw_genes_male_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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
9
Source/Genes/Breeding/Gene_MechBreeder.cs
Normal file
9
Source/Genes/Breeding/Gene_MechBreeder.cs
Normal file
|
@ -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!
|
||||||
|
}
|
||||||
|
}
|
64
Source/Genes/Breeding/PatchMechBirth.cs
Normal file
64
Source/Genes/Breeding/PatchMechBirth.cs
Normal file
|
@ -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
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 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/
|
||||||
|
/// </summary>
|
||||||
|
[HarmonyPatch(typeof(Hediff_MechanoidPregnancy), "GiveBirth")]
|
||||||
|
public static class PatchMechBirth
|
||||||
|
{
|
||||||
|
[HarmonyTranspiler]
|
||||||
|
public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
22
Source/Genes/Breeding/PatchPawnExtensions.cs
Normal file
22
Source/Genes/Breeding/PatchPawnExtensions.cs
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
using HarmonyLib;
|
||||||
|
using rjw;
|
||||||
|
using Verse;
|
||||||
|
|
||||||
|
namespace RJW_Genes
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Kindly provided by 'shabalox' https://github.com/Shabalox/RJW_Genes_Addons/
|
||||||
|
/// </summary>
|
||||||
|
[HarmonyPatch(typeof(PawnExtensions), "RaceImplantEggs")]
|
||||||
|
public static class PatchPawnExtensions
|
||||||
|
{
|
||||||
|
[HarmonyPostfix]
|
||||||
|
public static void Postfix(Pawn pawn, ref bool __result)
|
||||||
|
{
|
||||||
|
if (!__result)
|
||||||
|
{
|
||||||
|
__result = GeneUtility.isInsectBreeder(pawn);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
54
Source/Genes/Breeding/PatchPregnancyHelper.cs
Normal file
54
Source/Genes/Breeding/PatchPregnancyHelper.cs
Normal file
|
@ -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
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 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/
|
||||||
|
/// </summary>
|
||||||
|
[HarmonyPatch(typeof(PregnancyHelper), "DoEgg")]
|
||||||
|
static class PatchPregnancyHelper
|
||||||
|
{
|
||||||
|
[HarmonyTranspiler]
|
||||||
|
public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
44
Source/Genes/GeneUtility.cs
Normal file
44
Source/Genes/GeneUtility.cs
Normal file
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
16
Source/HarmonyInit.cs
Normal file
16
Source/HarmonyInit.cs
Normal file
|
@ -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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -22,6 +22,9 @@
|
||||||
<Prefer32Bit>false</Prefer32Bit>
|
<Prefer32Bit>false</Prefer32Bit>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Reference Include="0Harmony">
|
||||||
|
<HintPath>..\..\..\..\..\workshop\content\294100\2009463077\Current\Assemblies\0Harmony.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
<Reference Include="Assembly-CSharp">
|
<Reference Include="Assembly-CSharp">
|
||||||
<HintPath>..\..\..\RimWorldWin64_Data\Managed\Assembly-CSharp.dll</HintPath>
|
<HintPath>..\..\..\RimWorldWin64_Data\Managed\Assembly-CSharp.dll</HintPath>
|
||||||
<Private>False</Private>
|
<Private>False</Private>
|
||||||
|
@ -49,6 +52,10 @@
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="GeneDefOf.cs" />
|
<Compile Include="GeneDefOf.cs" />
|
||||||
|
<Compile Include="Genes\Breeding\Gene_MechBreeder.cs" />
|
||||||
|
<Compile Include="Genes\Breeding\PatchMechBirth.cs" />
|
||||||
|
<Compile Include="Genes\Breeding\PatchPawnExtensions.cs" />
|
||||||
|
<Compile Include="Genes\Breeding\PatchPregnancyHelper.cs" />
|
||||||
<Compile Include="Genes\ExtraGenitalia\Gene_ExtraBreasts.cs" />
|
<Compile Include="Genes\ExtraGenitalia\Gene_ExtraBreasts.cs" />
|
||||||
<Compile Include="Genes\ExtraGenitalia\Gene_ExtraAnus.cs" />
|
<Compile Include="Genes\ExtraGenitalia\Gene_ExtraAnus.cs" />
|
||||||
<Compile Include="Genes\ExtraGenitalia\Gene_Futa.cs" />
|
<Compile Include="Genes\ExtraGenitalia\Gene_Futa.cs" />
|
||||||
|
@ -61,6 +68,7 @@
|
||||||
<Compile Include="Genes\Gender\GenderUtility.cs" />
|
<Compile Include="Genes\Gender\GenderUtility.cs" />
|
||||||
<Compile Include="Genes\Gender\Gene_FemaleOnly.cs" />
|
<Compile Include="Genes\Gender\Gene_FemaleOnly.cs" />
|
||||||
<Compile Include="Genes\Gender\Gene_MaleOnly.cs" />
|
<Compile Include="Genes\Gender\Gene_MaleOnly.cs" />
|
||||||
|
<Compile Include="Genes\GeneUtility.cs" />
|
||||||
<Compile Include="Genes\GenitaliaSize\Gene_BigBreasts.cs" />
|
<Compile Include="Genes\GenitaliaSize\Gene_BigBreasts.cs" />
|
||||||
<Compile Include="Genes\GenitaliaSize\Gene_LooseAnus.cs" />
|
<Compile Include="Genes\GenitaliaSize\Gene_LooseAnus.cs" />
|
||||||
<Compile Include="Genes\GenitaliaSize\Gene_LooseFemaleGenitalia.cs" />
|
<Compile Include="Genes\GenitaliaSize\Gene_LooseFemaleGenitalia.cs" />
|
||||||
|
@ -84,7 +92,8 @@
|
||||||
<Compile Include="Genes\Genitalia\Gene_HumanGenitalia.cs" />
|
<Compile Include="Genes\Genitalia\Gene_HumanGenitalia.cs" />
|
||||||
<Compile Include="Genes\Genitalia\GenitaliaChanger.cs" />
|
<Compile Include="Genes\Genitalia\GenitaliaChanger.cs" />
|
||||||
<Compile Include="Genes\RJW_Gene.cs" />
|
<Compile Include="Genes\RJW_Gene.cs" />
|
||||||
<Compile Include="GenitaliaUtility.cs" />
|
<Compile Include="Genes\Genitalia\GenitaliaUtility.cs" />
|
||||||
|
<Compile Include="HarmonyInit.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="RJW_Genes.cs" />
|
<Compile Include="RJW_Genes.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
Loading…
Reference in a new issue