mirror of
https://github.com/vegapnk/RJW-Genes.git
synced 2024-08-15 00:23:31 +00:00
Changed Image for Insect Breeder Gene, new Approach for Insect Egg Fertilization
This commit is contained in:
parent
12c3b20971
commit
6304ccf475
5 changed files with 115 additions and 14 deletions
Binary file not shown.
|
@ -15,7 +15,7 @@
|
|||
<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>
|
||||
<iconPath>Genes/Icons/More_Egg_Space</iconPath>
|
||||
<displayOrderInCategory>52</displayOrderInCategory>
|
||||
<displayCategory>rjw_genes_breeding</displayCategory>
|
||||
</GeneDef>
|
||||
|
@ -24,7 +24,7 @@
|
|||
<defName>rjw_genes_insectbreeder</defName>
|
||||
<label>InsectBreeder</label>
|
||||
<description>Pawns with this gene are able to fertilize eggs with any fertile penis.</description>
|
||||
<iconPath>Genes/Icons/More_Egg_Space</iconPath>
|
||||
<iconPath>World/WorldObjects/Expanding/Insects</iconPath>
|
||||
<displayOrderInCategory>53</displayOrderInCategory>
|
||||
<displayCategory>rjw_genes_breeding</displayCategory>
|
||||
</GeneDef>
|
||||
|
|
99
Source/Genes/Breeding/Patch_EggFertilization.cs
Normal file
99
Source/Genes/Breeding/Patch_EggFertilization.cs
Normal file
|
@ -0,0 +1,99 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using HarmonyLib;
|
||||
using Verse;
|
||||
using rjw;
|
||||
|
||||
namespace RJW_Genes
|
||||
{
|
||||
/// <summary>
|
||||
/// This Class patches the AfterSexUtility to also fertilize eggs if Pawn A has "InsectBreeder" and Pawn B has Insect Eggs.
|
||||
/// Patched Class is https://gitgud.io/Ed86/rjw/-/blob/master/1.4/Source/Common/Helpers/SexUtility.cs
|
||||
///
|
||||
/// Normal Egg-Pregnancy logic is in https://gitgud.io/Ed86/rjw/-/blob/master/1.4/Source/Modules/Pregnancy/Pregnancy_Helper.cs
|
||||
/// </summary>
|
||||
[HarmonyPatch(typeof(SexUtility), "Aftersex")]
|
||||
static class PatchEggFertilizationHelper
|
||||
{
|
||||
[HarmonyTranspiler]
|
||||
public static void Postfix(SexProps props)
|
||||
{
|
||||
// Only Fertilize on vaginal / anal sex
|
||||
if (!(props.sexType == xxx.rjwSextype.Vaginal || props.sexType == xxx.rjwSextype.Anal))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (canDoEggFertilization(props.pawn, props.partner))
|
||||
{
|
||||
// Pawn has gene and Partner has eggs
|
||||
if (props.pawn.genes.GenesListForReading.Any(x => x.def == GeneDefOf.rjw_genes_insectbreeder) && !getEggsforPawn(props.partner).NullOrEmpty())
|
||||
{
|
||||
Pawn eggHolder = props.partner;
|
||||
Pawn impregnator = props.pawn;
|
||||
|
||||
foreach (Hediff_InsectEgg egg in getEggsforPawn(eggHolder))
|
||||
{
|
||||
if (!egg.fertilized)
|
||||
egg.Fertilize(impregnator);
|
||||
}
|
||||
}
|
||||
|
||||
// Partner has gene and Pawn has eggs
|
||||
if (props.partner.genes.GenesListForReading.Any(x => x.def == GeneDefOf.rjw_genes_insectbreeder) && !getEggsforPawn(props.pawn).NullOrEmpty())
|
||||
{
|
||||
Pawn eggHolder = props.pawn;
|
||||
Pawn impregnator = props.partner;
|
||||
|
||||
foreach (Hediff_InsectEgg egg in getEggsforPawn(eggHolder))
|
||||
{
|
||||
if (!egg.fertilized)
|
||||
egg.Fertilize(impregnator);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static Boolean canDoEggFertilization(Pawn a, Pawn b)
|
||||
{
|
||||
|
||||
// No Partner / Other Errors
|
||||
if (a != null || b != null)
|
||||
return false;
|
||||
// None of the pawns has the relevant gene
|
||||
if (!a.genes.GenesListForReading.Any(x => x.def == GeneDefOf.rjw_genes_insectbreeder) && !b.genes.GenesListForReading.Any(x => x.def == GeneDefOf.rjw_genes_insectbreeder))
|
||||
return false;
|
||||
// None of the pawns has eggs
|
||||
if (getEggsforPawn(a).NullOrEmpty() && getEggsforPawn(b).NullOrEmpty())
|
||||
return false;
|
||||
|
||||
// A has gene and B has eggs
|
||||
if (a.genes.GenesListForReading.Any(x => x.def == GeneDefOf.rjw_genes_insectbreeder) && !getEggsforPawn(b).NullOrEmpty())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
// B has gene and A has eggs
|
||||
if (b.genes.GenesListForReading.Any(x => x.def == GeneDefOf.rjw_genes_insectbreeder) && !getEggsforPawn(a).NullOrEmpty())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
// Any other case: Do nothing
|
||||
return false;
|
||||
}
|
||||
|
||||
private static List<Hediff_InsectEgg> getEggsforPawn(Pawn pawn)
|
||||
{
|
||||
List<Hediff_InsectEgg> eggs = new List<Hediff_InsectEgg>();
|
||||
pawn.health.hediffSet.GetHediffs(ref eggs);
|
||||
foreach (var egg in eggs)
|
||||
egg.Fertilize(pawn);
|
||||
|
||||
return eggs;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -23,16 +23,17 @@ namespace RJW_Genes
|
|||
if (!gene.Overridden)
|
||||
return gene.def;
|
||||
}
|
||||
|
||||
return GeneDefOf.rjw_genes_human_genitalia;
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public static HediffDef GetPenisForGene(GeneDef gene)
|
||||
{
|
||||
if (gene == null)
|
||||
return Genital_Helper.average_penis;
|
||||
|
||||
switch (gene.defName)
|
||||
{
|
||||
case "rjw_genes_human_genitalia": return Genital_Helper.average_penis;
|
||||
case "rjw_genes_equine_genitalia": return Genital_Helper.equine_penis;
|
||||
case "rjw_genes_canine_genitalia": return Genital_Helper.canine_penis;
|
||||
case "rjw_genes_feline_genitalia": return Genital_Helper.feline_penis;
|
||||
|
@ -48,9 +49,11 @@ namespace RJW_Genes
|
|||
|
||||
public static HediffDef GetVaginaForGene(GeneDef gene)
|
||||
{
|
||||
if (gene == null)
|
||||
return Genital_Helper.average_vagina;
|
||||
|
||||
switch (gene.defName)
|
||||
{
|
||||
case "rjw_genes_human_genitalia": return Genital_Helper.average_vagina;
|
||||
case "rjw_genes_equine_genitalia": return Genital_Helper.equine_vagina;
|
||||
case "rjw_genes_canine_genitalia": return Genital_Helper.canine_vagina;
|
||||
case "rjw_genes_feline_genitalia": return Genital_Helper.feline_vagina;
|
||||
|
@ -65,10 +68,11 @@ namespace RJW_Genes
|
|||
|
||||
public static HediffDef GetAnusForGene(GeneDef gene)
|
||||
{
|
||||
if (gene == null)
|
||||
return Genital_Helper.average_anus;
|
||||
switch (gene.defName)
|
||||
{
|
||||
//TODO: Do I want the default to be generic or average for feline,equine and canine?
|
||||
case "rjw_genes_human_genitalia": return Genital_Helper.average_anus;
|
||||
case "rjw_genes_equine_genitalia": return Genital_Helper.average_anus;
|
||||
case "rjw_genes_canine_genitalia": return Genital_Helper.average_anus;
|
||||
case "rjw_genes_feline_genitalia": return Genital_Helper.average_anus;
|
||||
|
@ -83,10 +87,12 @@ namespace RJW_Genes
|
|||
|
||||
public static HediffDef GetBreastsForGene(GeneDef gene)
|
||||
{
|
||||
if (gene == null)
|
||||
return Genital_Helper.average_breasts;
|
||||
|
||||
switch (gene.defName)
|
||||
{
|
||||
//TODO: Do I want the default to be generic or average?
|
||||
case "rjw_genes_human_genitalia": return Genital_Helper.average_breasts;
|
||||
case "rjw_genes_equine_genitalia": return Genital_Helper.average_breasts;
|
||||
case "rjw_genes_canine_genitalia": return Genital_Helper.average_breasts;
|
||||
case "rjw_genes_feline_genitalia": return Genital_Helper.average_breasts;
|
||||
|
|
|
@ -70,11 +70,12 @@
|
|||
<Compile Include="Animal_Inheritance\RJWcopies.cs" />
|
||||
<Compile Include="Animal_Inheritance\RJW_BGSSettings.cs" />
|
||||
<Compile Include="Animal_Inheritance\RJW_BGSSettingsController.cs" />
|
||||
<Compile Include="Animal_Inheritance\GeneChance.cs" />
|
||||
<Compile Include="Animal_Inheritance\BestialityGeneInheritanceDef.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\Patch_EggFertilization.cs" />
|
||||
<Compile Include="Genes\Breeding\PatchPregnancyHelper.cs" />
|
||||
<Compile Include="Genes\Cum\CumUtility.cs" />
|
||||
<Compile Include="Genes\Cum\Gene_VeryMuchCum.cs" />
|
||||
|
@ -99,10 +100,6 @@
|
|||
<Compile Include="Genes\GenitaliaSize\Gene_BigBreasts.cs" />
|
||||
<Compile Include="Genes\GenitaliaSize\Gene_LooseAnus.cs" />
|
||||
<Compile Include="Genes\GenitaliaSize\Gene_LooseFemaleGenitalia.cs" />
|
||||
<Compile Include="Genes\GenitaliaSize\Gene_NormalFemaleGenitalia.cs" />
|
||||
<Compile Include="Genes\GenitaliaSize\Gene_NormalAnus.cs" />
|
||||
<Compile Include="Genes\GenitaliaSize\Gene_NormalBreasts.cs" />
|
||||
<Compile Include="Genes\GenitaliaSize\Gene_NormalMaleGenitalia.cs" />
|
||||
<Compile Include="Genes\GenitaliaSize\Gene_TightAnus.cs" />
|
||||
<Compile Include="Genes\GenitaliaSize\Gene_SmallBreasts.cs" />
|
||||
<Compile Include="Genes\GenitaliaSize\Gene_TightFemaleGenitalia.cs" />
|
||||
|
@ -116,7 +113,6 @@
|
|||
<Compile Include="Genes\Genitalia\Gene_OvipositorGenitalia.cs" />
|
||||
<Compile Include="Genes\Genitalia\Gene_DemonicGenitalia.cs" />
|
||||
<Compile Include="Genes\Genitalia\Gene_EquineGenitalia.cs" />
|
||||
<Compile Include="Genes\Genitalia\Gene_HumanGenitalia.cs" />
|
||||
<Compile Include="Genes\Genitalia\GenitaliaChanger.cs" />
|
||||
<Compile Include="Genes\RJW_Gene.cs" />
|
||||
<Compile Include="Genes\Genitalia\GenitaliaUtility.cs" />
|
||||
|
|
Loading…
Reference in a new issue