diff --git a/CHANGELOG.md b/CHANGELOG.md index 28a4e46..0db6c9f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,10 @@ Features: - Age-Transfer and Youth-Fountain per Sex Gene - Bisexual and Homosexual Genes with Placeholder Icon - Balancing some Genes by changing metabolism and complexity +- Pheromone Gene (#13, Shabakur) +- RJW Race-Support Compatibility (#12,#13, Shabakur) +- Animal Gene Inheritance Gene-Chance Multiplier per Setting (#13, Shabakur) +- Lots of Debug-Only Logging for Animal Gene Inheritance Succubus: @@ -17,6 +21,7 @@ Fixes: - Error on Game Load when Licentia Genes are tried to be added to Xenotypes for players without Licentia (#5) - Futa Gene only triggers if Pawn is not a futa already (#2) - Genitalia Resizing triggers on 20th Birthday (#11) +- RJW-Gene-Inheritance Settings now do things (#13, Shabakur) # 1.0.1 (2022-12-20) diff --git a/Source/Animal_Inheritance/BestialityGeneInheritanceDef.cs b/Source/Animal_Inheritance/BestialityGeneInheritanceDef.cs index 04a9735..ae0c51e 100644 --- a/Source/Animal_Inheritance/BestialityGeneInheritanceDef.cs +++ b/Source/Animal_Inheritance/BestialityGeneInheritanceDef.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace RJW_BGS +namespace RJW_BGS { public class BestialityGeneInheritanceDef { diff --git a/Source/Animal_Inheritance/InheritanceUtility.cs b/Source/Animal_Inheritance/InheritanceUtility.cs index d860b14..de486ae 100644 --- a/Source/Animal_Inheritance/InheritanceUtility.cs +++ b/Source/Animal_Inheritance/InheritanceUtility.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.Collections.Generic; using Verse; using RimWorld; using rjw; @@ -20,14 +16,18 @@ namespace RJW_BGS if (mother.RaceProps.Humanlike && father.RaceProps.Humanlike) return genelist; - + ModLog.Message($"Trigger an Animal-Gene-Inheritance for {father.Name} and {mother.Name}"); //One parent must be an animal and the other must be human, so only one needs to return if (father != null && !father.RaceProps.Humanlike) { + if (RJW_BGSSettings.rjw_bgs_detailed_debug) + ModLog.Message($"Father was found to be animal - looking up genes for {father.Name}"); return SelectGenes(father); } if (mother != null && !mother.RaceProps.Humanlike) { + if (RJW_BGSSettings.rjw_bgs_detailed_debug) + ModLog.Message($"Mother was found to be animal - looking up genes for {mother.Name}"); return SelectGenes(mother); } @@ -48,30 +48,48 @@ namespace RJW_BGS { foreach (BestialityGeneInheritanceDef gene in raceGeneDef.genes) { - if (gene.chance * RJW_BGSSettings.global_gene_chance >= Rand.Range(0.01f,1f)) + if (gene.chance * RJW_BGSSettings.rjw_bgs_global_gene_chance >= Rand.Range(0.01f,1f)) { genelist.Add(DefDatabase.GetNamed(gene.defName)); } } } + if (RJW_BGSSettings.rjw_bgs_detailed_debug) + ModLog.Message($"From {raceGeneDef.genes.Count} possible genes in {raceGeneDef.defName}, {genelist.Count} were added by chance ({RJW_BGSSettings.rjw_bgs_global_gene_chance} chance multiplier from Settings)."); return genelist; } + + /// + /// Adds a list of Genes to the pawns existing GeneSet. + /// Whether it is added as a Xenogene or Endogene is configured in Mod-Settings. + /// + /// The pawn for which Genes will be added + /// The Genes to add (Endogene by default, Xenogene with Mod Settings) public static void AddGenes(Pawn pawn, List genes) { foreach (GeneDef gene in genes) { - pawn.genes.AddGene(gene, false); + pawn.genes.AddGene(gene, RJW_BGSSettings.rjw_bgs_animal_genes_as_xenogenes); } } - //For ParchRJWHediffInsect_egg + /// + /// Initiates a bestiality baby with genes if the baby does not exist earlier. + /// This is used to make rjw-egg-pregnancies work. + /// Related file: PatchRJWHediffInsect_Egg.cs + /// + /// The mother of the baby. + /// The father of the baby. + /// The baby created in non-pregnancy-way (has 0 Genes yet) public static void NewGenes(Pawn mother, Pawn dad, Pawn baby) { - if (!RJW_BGSSettings.enabled) + if (!RJW_BGSSettings.rjw_bgs_enabled) { return; } + + ModLog.Message($"Triggering an New-Gene Animal-Gene-Inheritance for {baby.Name} ({dad.Name} + {mother.Name})"); if (baby.RaceProps.Humanlike) { if (baby.genes == null) diff --git a/Source/Animal_Inheritance/PatchRJWBestialityPregnancyUtility.cs b/Source/Animal_Inheritance/PatchRJWBestialityPregnancyUtility.cs index 31f9bfd..da5ac8d 100644 --- a/Source/Animal_Inheritance/PatchRJWBestialityPregnancyUtility.cs +++ b/Source/Animal_Inheritance/PatchRJWBestialityPregnancyUtility.cs @@ -16,7 +16,7 @@ namespace RJW_BGS [HarmonyPostfix] public static void AddGenes(Pawn mother, Pawn dad, ref Hediff_BasePregnancy __instance) { - if (!RJW_BGSSettings.enabled) + if (!RJW_BGSSettings.rjw_bgs_enabled) { return; } diff --git a/Source/Animal_Inheritance/PatchRJWHediffInsect_Egg.cs b/Source/Animal_Inheritance/PatchRJWHediffInsect_Egg.cs index d52f62d..587571f 100644 --- a/Source/Animal_Inheritance/PatchRJWHediffInsect_Egg.cs +++ b/Source/Animal_Inheritance/PatchRJWHediffInsect_Egg.cs @@ -1,14 +1,8 @@ -using System; -using System.Collections.Generic; +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; -using RimWorld; -using Verse; namespace RJW_BGS { diff --git a/Source/Animal_Inheritance/PatchVanillaPregnancyUtility.cs b/Source/Animal_Inheritance/PatchVanillaPregnancyUtility.cs index baa72f5..a076b6e 100644 --- a/Source/Animal_Inheritance/PatchVanillaPregnancyUtility.cs +++ b/Source/Animal_Inheritance/PatchVanillaPregnancyUtility.cs @@ -1,15 +1,17 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Text; -using System.Threading.Tasks; using HarmonyLib; using RimWorld; using Verse; -using rjw; namespace RJW_BGS { + /// + /// This Patch is applied to change the normal pregnancy to add animal-inheritance. + /// If the settings allow animal gene inheritance, + /// the genes are determined and "simply added". + /// [HarmonyPatch(typeof(PregnancyUtility), "GetInheritedGeneSet", new Type[] { typeof(Pawn), @@ -22,7 +24,7 @@ namespace RJW_BGS [HarmonyPostfix] public static void AnimalInheritedGenes(Pawn father, Pawn mother, ref GeneSet __result) { - if (!RJW_BGSSettings.enabled) + if (!RJW_BGSSettings.rjw_bgs_enabled) { return; } diff --git a/Source/Animal_Inheritance/RJW_BGSSettings.cs b/Source/Animal_Inheritance/RJW_BGSSettings.cs index 4847d89..d619354 100644 --- a/Source/Animal_Inheritance/RJW_BGSSettings.cs +++ b/Source/Animal_Inheritance/RJW_BGSSettings.cs @@ -21,23 +21,31 @@ namespace RJW_BGS listing_Standard.ColumnWidth = rect.width / 2.05f; listing_Standard.Begin(rect); listing_Standard.Gap(24f); - listing_Standard.CheckboxLabeled("enabled", ref enabled, "no function yet", 0f, 1f); + listing_Standard.CheckboxLabeled("enabled", ref rjw_bgs_enabled, "If toggled, Animal Pregnancies will try inherit genes.", 0f, 1f); //listing_Standard.CheckboxLabeled("sexfrenzy", ref sexfrenzy, "disable the effects", 0f, 1f); listing_Standard.Gap(5f); listing_Standard.Label("gene inheritance chance"+ ": " + - Math.Round((double)(RJW_BGSSettings.global_gene_chance * 100f), 0).ToString() + "%", -1f, "modify chance for a gene to be inherited."); - RJW_BGSSettings.global_gene_chance = listing_Standard.Slider(RJW_BGSSettings.global_gene_chance, 0f, 5f); + Math.Round((double)(RJW_BGSSettings.rjw_bgs_global_gene_chance * 100f), 0).ToString() + "%", -1f, "modify chance for a gene to be inherited."); + RJW_BGSSettings.rjw_bgs_global_gene_chance = listing_Standard.Slider(RJW_BGSSettings.rjw_bgs_global_gene_chance, 0f, 5f); + listing_Standard.Gap(5f); + listing_Standard.CheckboxLabeled("genes as xenogenes", ref rjw_bgs_animal_genes_as_xenogenes, "If toggled, animal genes will be added as xenogenes.", 0f, 1f); + listing_Standard.Gap(5f); + listing_Standard.CheckboxLabeled("detailed-debug", ref rjw_bgs_detailed_debug, "Adds detailed information to the log about pregnancies and genes.", 0f, 1f); listing_Standard.End(); } public override void ExposeData() { base.ExposeData(); - Scribe_Values.Look(ref RJW_BGSSettings.enabled, "enabled", RJW_BGSSettings.enabled, true); - Scribe_Values.Look(ref RJW_BGSSettings.global_gene_chance, "global_gene_chance", RJW_BGSSettings.global_gene_chance, true); + Scribe_Values.Look(ref RJW_BGSSettings.rjw_bgs_enabled, "rjw_bgs_enabled", RJW_BGSSettings.rjw_bgs_enabled, true); + Scribe_Values.Look(ref RJW_BGSSettings.rjw_bgs_global_gene_chance, "rjw_bgs_global_gene_chance", RJW_BGSSettings.rjw_bgs_global_gene_chance, true); + Scribe_Values.Look(ref RJW_BGSSettings.rjw_bgs_animal_genes_as_xenogenes, "rjw_bgs_animal_genes_as_xenogenes", RJW_BGSSettings.rjw_bgs_animal_genes_as_xenogenes, true); + Scribe_Values.Look(ref RJW_BGSSettings.rjw_bgs_detailed_debug, "rjw_bgs_detailed_debug", RJW_BGSSettings.rjw_bgs_detailed_debug, true); } - public static float global_gene_chance = 1f; - public static bool enabled = true; + public static float rjw_bgs_global_gene_chance = 1f; + public static bool rjw_bgs_enabled = true; + public static bool rjw_bgs_animal_genes_as_xenogenes = false; + public static bool rjw_bgs_detailed_debug = false; } } diff --git a/Source/Animal_Inheritance/RaceGeneDef_Helper.cs b/Source/Animal_Inheritance/RaceGeneDef_Helper.cs index 3e32609..f88084d 100644 --- a/Source/Animal_Inheritance/RaceGeneDef_Helper.cs +++ b/Source/Animal_Inheritance/RaceGeneDef_Helper.cs @@ -18,14 +18,14 @@ namespace RJW_BGS return result; } return null; - //First check if there is a matching pawnkinddef then race, then racegroup - } + public static List ValidRaceGeneDefs(Pawn pawn) { PawnKindDef kindDef = pawn.kindDef; if (kindDef == null) { + ModLog.Warning($"Error looking up PawnKindDef for {pawn.Name} - Could not lookup Animal Inheritance Genes"); return null; } string raceName = kindDef.race.defName; @@ -33,6 +33,9 @@ namespace RJW_BGS PawnData pawnData = SaveStorage.DataStore.GetPawnData(pawn); RaceGroupDef raceGroupDef = pawnData.RaceSupportDef; + if (RJW_BGSSettings.rjw_bgs_detailed_debug) + ModLog.Message($"Looking up Animal-Inheritable Genes for {pawn.Name} with KindDef {kindDef.defName},RaceName {raceName}, PawnKind {pawnKindName} and RaceGroup {raceGroupDef.defName}"); + IEnumerable allDefs = DefDatabase.AllDefs; List pawnKindDefs = allDefs.Where(delegate (RaceGeneDef group) { @@ -40,7 +43,12 @@ namespace RJW_BGS return pawnKindNames != null && pawnKindNames.Contains(pawnKindName); }).ToList(); if (pawnKindDefs.Count() > 0) + { + DebugPrintRaceGeneDefs("PawnKindDefs",pawn.Name.ToStringFull,pawnKindDefs); return pawnKindDefs; + } + else if (RJW_BGSSettings.rjw_bgs_detailed_debug) + ModLog.Message($"Did not find PawnKindDefs for {pawn.Name.ToStringFull}"); List raceKindDefs = allDefs.Where(delegate (RaceGeneDef group) { @@ -48,7 +56,12 @@ namespace RJW_BGS return raceNames != null && raceNames.Contains(raceName); }).ToList(); if (raceKindDefs.Count() > 0) + { + DebugPrintRaceGeneDefs("PawnKindDefs", pawn.Name.ToStringFull, raceKindDefs); return raceKindDefs; + } + else if (RJW_BGSSettings.rjw_bgs_detailed_debug) + ModLog.Message($"Did not find RaceKindDefs for {pawn.Name.ToStringFull}"); List raceGroupDefs = new List(); if (raceGroupDef != null) @@ -61,11 +74,29 @@ namespace RJW_BGS || (list_raceGroupDefName != null && list_raceGroupDefName.Contains(raceGroupDef.defName)); }).ToList(); } - + if (raceGroupDefs.Count() > 0) + { + DebugPrintRaceGeneDefs("RaceKindDefs", pawn.Name.ToStringFull, raceGroupDefs); return raceGroupDefs; + } + else if (RJW_BGSSettings.rjw_bgs_detailed_debug) + ModLog.Message($"Did not find RaceGroupDefs for {pawn.Name.ToStringFull}"); + ModLog.Message($"Did not find any Genes inheritable for {pawn.Name.ToStringFull}"); return new List(); } + + private static void DebugPrintRaceGeneDefs(String header,String identifier,List defs) + { + if (RJW_BGSSettings.rjw_bgs_detailed_debug) + { + var defString = "["; + foreach (RaceGeneDef raceGeneDef in defs) + defString += $"({raceGeneDef.priority}:{raceGeneDef.defName} - {raceGeneDef.genes.Count} Genes)"; + defString += "]"; + ModLog.Message($"Found the following {header}-Genes for {identifier}: {defString}"); + } + } } } diff --git a/Source/Rjw-Genes.csproj b/Source/Rjw-Genes.csproj index 8c92644..9473ed9 100644 --- a/Source/Rjw-Genes.csproj +++ b/Source/Rjw-Genes.csproj @@ -60,7 +60,6 @@ - @@ -71,6 +70,7 @@ + @@ -82,6 +82,7 @@ + @@ -98,6 +99,7 @@ + @@ -105,6 +107,7 @@ + @@ -117,7 +120,9 @@ + +