From 710efc7d8503362226ff15646933d02e1c0d3a5c Mon Sep 17 00:00:00 2001 From: Vegapnk Date: Tue, 4 Jun 2024 16:44:50 +0200 Subject: [PATCH] Some documentation --- .../Patches/BasePregnancyPatcher.cs | 48 +++++-------------- .../Patches/PregnancyHelperPatcher.cs | 18 +++---- 2 files changed, 20 insertions(+), 46 deletions(-) diff --git a/Source/Animal_Inheritance/Patches/BasePregnancyPatcher.cs b/Source/Animal_Inheritance/Patches/BasePregnancyPatcher.cs index a180e7c..156aab9 100644 --- a/Source/Animal_Inheritance/Patches/BasePregnancyPatcher.cs +++ b/Source/Animal_Inheritance/Patches/BasePregnancyPatcher.cs @@ -14,7 +14,10 @@ namespace RJW_BGS [HarmonyPatch(typeof(Hediff_BasePregnancy))] public class BasePregnancyPatcher { - public static List racesgen1 = new List() + /// + /// The supported races that are produced by Vanilla Genetics Expanded, that can lead to different offsprings when in Human - Animal Sex + /// + public static List firstGenerationOffspringRaces = new List() { "GR_Manbear", "GR_Bearman", @@ -36,7 +39,10 @@ namespace RJW_BGS "GR_Lizardman" }; - public static List racesgen0 = new List() + /// + /// The supported races that can produce Vanilla Genetics hybrids as Human - Animal Sex results. + /// + public static List parentGenerationOffspringRaces = new List() { "Bear_Grizzly", "Bear_Polar", @@ -85,50 +91,18 @@ namespace RJW_BGS "Tortoise" }; - //public static HediffDef controler = DefDatabase.GetNamed("RJWGenes_AnimalControlHediff", true); - [HarmonyPostfix] [HarmonyPatch("GenerateBabies")] public static void AddComfortableWithHumansHediff (Hediff_BasePregnancy __instance) { - //if (controler == null) return; - - foreach (Pawn p in __instance.babies) + foreach (Pawn baby in __instance.babies) { - if(p != null) + if (baby != null && firstGenerationOffspringRaces.Contains(baby.kindDef.race.defName)) { - if (racesgen1.Contains(p.kindDef.race.defName)) - { - p.health.AddHediff(RJW_Genes.HediffDefOf.rjw_genes_animal_control_hediff); - } + baby.health.AddHediff(RJW_Genes.HediffDefOf.rjw_genes_animal_control_hediff); } } } - - } } - -/* - * Error Received on 04.06.2024 - * Failed to find Verse.HediffDef named RJWGenes_AnimalControlHediff. There are 446 defs of this type loaded. -UnityEngine.StackTraceUtility:ExtractStackTrace () -(wrapper dynamic-method) MonoMod.Utils.DynamicMethodDefinition:Verse.Log.Error_Patch1 (string) -Verse.DefDatabase`1:GetNamed (string,bool) -RJW_BGS.BasePregnancyPatcher:.cctor () -(wrapper dynamic-method) MonoMod.Utils.DynamicMethodDefinition:rjw.PregnancyHelper.AddPregnancyHediff_Patch1 (Verse.Pawn,Verse.Pawn) -rjw.PregnancyHelper:DoImpregnate (Verse.Pawn,Verse.Pawn) -(wrapper dynamic-method) MonoMod.Utils.DynamicMethodDefinition:rjw.PregnancyHelper.impregnate_Patch1 (rjw.SexProps) -(wrapper dynamic-method) MonoMod.Utils.DynamicMethodDefinition:rjw.JobDriver_Sex.Orgasm_Patch1 (rjw.JobDriver_Sex) -(wrapper dynamic-method) MonoMod.Utils.DynamicMethodDefinition:rjw.JobDriver_Sex.SexTick_Patch2 (rjw.JobDriver_Sex,Verse.Pawn,Verse.Thing,bool,bool) -rjw.JobDriver_Mating/<>c__DisplayClass1_0:b__5 () -Verse.AI.JobDriver:DriverTick () -Verse.AI.Pawn_JobTracker:JobTrackerTick () -Verse.Pawn:Tick () -Verse.TickList:Tick () -(wrapper dynamic-method) MonoMod.Utils.DynamicMethodDefinition:Verse.TickManager.DoSingleTick_Patch2 (Verse.TickManager) -Verse.TickManager:TickManagerUpdate () -Verse.Game:UpdatePlay () -Verse.Root_Play:Update () - */ \ No newline at end of file diff --git a/Source/Animal_Inheritance/Patches/PregnancyHelperPatcher.cs b/Source/Animal_Inheritance/Patches/PregnancyHelperPatcher.cs index a0893df..50e7379 100644 --- a/Source/Animal_Inheritance/Patches/PregnancyHelperPatcher.cs +++ b/Source/Animal_Inheritance/Patches/PregnancyHelperPatcher.cs @@ -21,29 +21,29 @@ namespace RJW_BGS { if (!RJW_BGSSettings.rjw_bgs_VE_genetics) return true; if (mother == null || father == null) return true; - bool a = mother.IsHuman() && BasePregnancyPatcher.racesgen0.Contains(father.kindDef.race.defName); - bool b = mother.IsHuman() && BasePregnancyPatcher.racesgen1.Contains(father.kindDef.race.defName); - bool c = father.IsHuman() && BasePregnancyPatcher.racesgen0.Contains(mother.kindDef.race.defName); - bool d = father.IsHuman() && BasePregnancyPatcher.racesgen1.Contains(mother.kindDef.race.defName); + bool humanMotherAndSupportedAnimal = mother.IsHuman() && BasePregnancyPatcher.parentGenerationOffspringRaces.Contains(father.kindDef.race.defName); + bool humanMotherAndSupportedHybrid = mother.IsHuman() && BasePregnancyPatcher.firstGenerationOffspringRaces.Contains(father.kindDef.race.defName); + bool humanFatherAndSupportedAnimal = father.IsHuman() && BasePregnancyPatcher.parentGenerationOffspringRaces.Contains(mother.kindDef.race.defName); + bool humanFatherAndSupportedHybrid = father.IsHuman() && BasePregnancyPatcher.firstGenerationOffspringRaces.Contains(mother.kindDef.race.defName); - if (!(a || b||c|| d)) return true; - if (a) + if (!(humanMotherAndSupportedAnimal || humanMotherAndSupportedHybrid||humanFatherAndSupportedAnimal|| humanFatherAndSupportedHybrid)) return true; + if (humanMotherAndSupportedAnimal) { Hediff_BasePregnancy.Create(mother, father, DnaGivingParent.Father); return false; } - else if (b) + else if (humanMotherAndSupportedHybrid) { ModLog.Message("preg hediffdefof PregnantHuman " + RimWorld.HediffDefOf.PregnantHuman); PregnancyHelper.StartVanillaPregnancy(mother, father); return false; } - else if (c) + else if (humanFatherAndSupportedAnimal) { Hediff_BasePregnancy.Create(mother, father, DnaGivingParent.Mother); return false; } - else if (d) + else if (humanFatherAndSupportedHybrid) { Hediff_BasePregnancy.Create(mother, father, DnaGivingParent.Father); return false;