diff --git a/About/About.xml b/About/About.xml new file mode 100644 index 0000000..d445da6 --- /dev/null +++ b/About/About.xml @@ -0,0 +1,31 @@ + + RJW Animal Gene Inheritance + Shabakur + Shabakur.rjw.animal.gene.inheritance + +
  • 1.4
  • +
    + Allows pawn to inherit genes from beasts. + +
  • + ludeon.rimworld.biotech + Biotech +
  • +
  • + rim.job.world + RimJobWorld + https://www.loverslab.com/files/file/7257-rimjobworld/ +
  • +
  • + brrainz.harmony + Harmony + steam://url/CommunityFilePage/2009463077 + https://github.com/pardeike/HarmonyRimWorld/releases/latest +
  • +
    + +
  • brrainz.harmony
  • +
  • ludeon.rimworld.biotech
  • +
  • rim.job.world
  • +
    +
    \ No newline at end of file diff --git a/Assemblies/RJW_BGS.dll b/Assemblies/RJW_BGS.dll new file mode 100644 index 0000000..6a03c3a Binary files /dev/null and b/Assemblies/RJW_BGS.dll differ diff --git a/Defs/RaceGeneDefs/RaceGeneDefs _template.xml b/Defs/RaceGeneDefs/RaceGeneDefs _template.xml new file mode 100644 index 0000000..d80ce97 --- /dev/null +++ b/Defs/RaceGeneDefs/RaceGeneDefs _template.xml @@ -0,0 +1,38 @@ + + + + \ No newline at end of file diff --git a/Defs/RaceGeneDefs/RaceGeneDefs.xml b/Defs/RaceGeneDefs/RaceGeneDefs.xml new file mode 100644 index 0000000..7802539 --- /dev/null +++ b/Defs/RaceGeneDefs/RaceGeneDefs.xml @@ -0,0 +1,109 @@ + + + + Canine + Canine_Group + +
  • Ears_Floppy
  • +
    + +
  • 90
  • +
    +
    + + + Insect + Insect_Group + +
  • Beauty_Ugly
  • +
    + +
  • 50
  • +
    +
    + + + Feline + Feline_Group + +
  • Ears_Cat
  • +
  • Sleepy
  • +
  • DarkVision
  • +
    + +
  • 90
  • +
  • 25
  • +
  • 25
  • +
    +
    + + + Dragon + Dragon_Group + +
  • Unstoppable
  • +
  • Headbone_CenterHorn
  • +
    + +
  • 25
  • +
  • 90
  • +
    +
    + + + Rodent + Rodent_Group + +
  • Fertile
  • +
    + +
  • 10
  • +
    +
    + + + Racoon + Raccon_Group + +
  • StrongStomach
  • +
    + +
  • 50
  • +
    +
    + + +
    \ No newline at end of file diff --git a/Source/RJW_BGS/Class1.cs b/Source/RJW_BGS/Class1.cs new file mode 100644 index 0000000..b987f18 --- /dev/null +++ b/Source/RJW_BGS/Class1.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using rjw; +using Verse; +using RimWorld; +namespace RJW_BGS +{ + [StaticConstructorOnStartup] + internal static class Class1 + { + static Class1() + { + RJWcopy.Racegroupdictbuilder(); + foreach (RaceGroupDef raceGroupDef2 in DefDatabase.AllDefs) + { + //Log.Message("defName = " + raceGroupDef2.defName); + if (raceGroupDef2.raceNames != null) + { + foreach (string race in raceGroupDef2.raceNames) + { + //Log.Message(race); + } + } + } + } + } +} diff --git a/Source/RJW_BGS/Harmony_Init.cs b/Source/RJW_BGS/Harmony_Init.cs new file mode 100644 index 0000000..120a4e8 --- /dev/null +++ b/Source/RJW_BGS/Harmony_Init.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using HarmonyLib; +using Verse; + +namespace RJW_BGS +{ + [StaticConstructorOnStartup] + internal static class HarmonyInit + { + // Token: 0x0600001F RID: 31 RVA: 0x000029A4 File Offset: 0x00000BA4 + static HarmonyInit() + { + Harmony harmony = new Harmony("RJW_BGS"); + harmony.PatchAll(); + } + } +} diff --git a/Source/RJW_BGS/InheritanceUtility.cs b/Source/RJW_BGS/InheritanceUtility.cs new file mode 100644 index 0000000..20724fa --- /dev/null +++ b/Source/RJW_BGS/InheritanceUtility.cs @@ -0,0 +1,64 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Verse; +using RimWorld; + +namespace RJW_BGS +{ + public class InheritanceUtility + { + public static List AnimalInheritedGenes(Pawn father, Pawn mother) + { + List genelist = new List(); + if (father != null && !father.RaceProps.Humanlike) + { + PawnKindDef pawnKindDef = father.kindDef; + RaceGeneDef raceGeneDef = RJWcopy.GetRaceGenDefInternal(pawnKindDef); + if (raceGeneDef != null) + { + GeneDef gene = null; + //In case you hit a modded gene not currently active try again. + for (int i = 0; i < 50 || gene == null; i++) + { + if (raceGeneDef.genes.Any()) + { + gene = DefDatabase.GetNamed(raceGeneDef.genes.RandomElement()); + } + } + if (gene != null) + { + genelist.Add(gene); + } + } + } + + if (mother != null && !mother.RaceProps.Humanlike) + { + PawnKindDef pawnKindDef = mother.kindDef; + RaceGeneDef raceGeneDef = RJWcopy.GetRaceGenDefInternal(pawnKindDef); + if (raceGeneDef != null) + { + GeneDef gene = null; + //In case you hit a modded gene not currently active try again. + for (int i = 0; i < 50 || gene == null; i++) + { + if (raceGeneDef.genes.Any()) + { + gene = DefDatabase.GetNamed(raceGeneDef.genes.RandomElement()); + } + } + if (gene != null) + { + genelist.Add(gene); + + } + + } + } + return genelist; + } + } +} diff --git a/Source/RJW_BGS/PatchRJWBestialityPregnancyUtility.cs b/Source/RJW_BGS/PatchRJWBestialityPregnancyUtility.cs new file mode 100644 index 0000000..fc2bbc6 --- /dev/null +++ b/Source/RJW_BGS/PatchRJWBestialityPregnancyUtility.cs @@ -0,0 +1,49 @@ +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 +{ + [HarmonyPatch(typeof(Hediff_BasePregnancy), "Initialize")] + public static class PatchRJWBestialityPregnancyUtility + { + [HarmonyPostfix] + public static void AddGenes(Pawn mother, Pawn dad, ref Hediff_BasePregnancy __instance) + { + foreach (Pawn baby in __instance.babies) + { + if (baby.RaceProps.Humanlike) + { + if (baby.genes == null) + { + baby.genes = new Pawn_GeneTracker(baby); + } + + //Remove the hair and skin genes pawns always start with, should get correct ones from human parent anyway. + for (int i = baby.genes.Endogenes.Count - 1; i >= 0; i--) + { + baby.genes.RemoveGene(baby.genes.Endogenes[i]); + } + + List genes = PregnancyUtility.GetInheritedGenes(dad, mother); + List beastgenes = InheritanceUtility.AnimalInheritedGenes(dad, mother); + + foreach (GeneDef gene in beastgenes) + { + baby.genes.AddGene(gene, false); + } + foreach (GeneDef gene in genes) + { + baby.genes.AddGene(gene, false); + } + } + } + } + } +} diff --git a/Source/RJW_BGS/PatchVanillaPregnancyUtility.cs b/Source/RJW_BGS/PatchVanillaPregnancyUtility.cs new file mode 100644 index 0000000..4321667 --- /dev/null +++ b/Source/RJW_BGS/PatchVanillaPregnancyUtility.cs @@ -0,0 +1,34 @@ +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 +{ + [HarmonyPatch(typeof(PregnancyUtility), "GetInheritedGeneSet", new Type[] + { + typeof(Pawn), + typeof(Pawn), + //typeof(bool) + } + )] + public static class PatchVanillaPregnancyUtility + { + [HarmonyPostfix] + public static void AnimalInheritedGenes(Pawn father, Pawn mother, ref GeneSet __result) + { + List genes = InheritanceUtility.AnimalInheritedGenes(father, mother); + if (genes.Any()) + { + foreach (GeneDef gene in genes) + { + __result.AddGene(gene); + } + } + } + } +} diff --git a/Source/RJW_BGS/Properties/AssemblyInfo.cs b/Source/RJW_BGS/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..e1325ac --- /dev/null +++ b/Source/RJW_BGS/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("RJW_BGS")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("HP Inc.")] +[assembly: AssemblyProduct("RJW_BGS")] +[assembly: AssemblyCopyright("Copyright © HP Inc. 2022")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("357a0848-8709-46ab-bd98-49fd8fd5dd13")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Source/RJW_BGS/RJW_BGS.csproj b/Source/RJW_BGS/RJW_BGS.csproj new file mode 100644 index 0000000..b1eb624 --- /dev/null +++ b/Source/RJW_BGS/RJW_BGS.csproj @@ -0,0 +1,70 @@ + + + + + Debug + AnyCPU + {357A0848-8709-46AB-BD98-49FD8FD5DD13} + Library + Properties + RJW_BGS + RJW_BGS + v4.7.2 + 512 + true + + + false + none + false + ..\..\Assemblies\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\..\..\..\..\..\workshop\content\294100\2009463077\Current\Assemblies\0Harmony.dll + False + + + ..\..\..\..\RimWorldWin64_Data\Managed\Assembly-CSharp.dll + False + + + ..\..\..\RJW\1.4\Assemblies\RJW.dll + False + + + + + + + + + + + ..\..\..\..\RimWorldWin64_Data\Managed\UnityEngine.dll + False + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Source/RJW_BGS/RJW_BGS.sln b/Source/RJW_BGS/RJW_BGS.sln new file mode 100644 index 0000000..d256888 --- /dev/null +++ b/Source/RJW_BGS/RJW_BGS.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.2.32519.379 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RJW_BGS", "RJW_BGS.csproj", "{357A0848-8709-46AB-BD98-49FD8FD5DD13}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {357A0848-8709-46AB-BD98-49FD8FD5DD13}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {357A0848-8709-46AB-BD98-49FD8FD5DD13}.Debug|Any CPU.Build.0 = Debug|Any CPU + {357A0848-8709-46AB-BD98-49FD8FD5DD13}.Release|Any CPU.ActiveCfg = Release|Any CPU + {357A0848-8709-46AB-BD98-49FD8FD5DD13}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {BAF54302-9171-409B-BCFA-9817A3BF9A66} + EndGlobalSection +EndGlobal diff --git a/Source/RJW_BGS/RJWcopies.cs b/Source/RJW_BGS/RJWcopies.cs new file mode 100644 index 0000000..c09f95a --- /dev/null +++ b/Source/RJW_BGS/RJWcopies.cs @@ -0,0 +1,133 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using rjw; +using Verse; +using RimWorld; +namespace RJW_BGS +{ + internal class RJWcopy + { + //Code copied from rjw, as their code was internal and I need the dictionary to know which genes to add to the pawn + public static void Racegroupdictbuilder() + { + foreach (PawnKindDef pawnKindDef2 in from pawnKindDef in DefDatabase.AllDefs + where pawnKindDef.race.race != null + select pawnKindDef) + { + RaceGroupDef raceGroupDef = null; + bool temp = TryGetRaceGroupDef(pawnKindDef2, out raceGroupDef); + } + } + + public static bool TryGetRaceGroupDef(PawnKindDef pawnKindDef, out RaceGroupDef raceGroupDef) + { + + if (RaceGroupByPawnKind.TryGetValue(pawnKindDef, out raceGroupDef)) + { + return raceGroupDef != null; + } + raceGroupDef = GetRaceGroupDefInternal(pawnKindDef); + RaceGroupByPawnKind.Add(pawnKindDef, raceGroupDef); + return raceGroupDef != null; + } + + public static RaceGroupDef GetRaceGroupDefInternal(PawnKindDef kindDef) + { + string raceName = kindDef.race.defName; + string pawnKindName = kindDef.defName; + IEnumerable allDefs = DefDatabase.AllDefs; + List list = allDefs.Where(delegate (RaceGroupDef group) + { + List pawnKindNames = group.pawnKindNames; + return pawnKindNames != null && pawnKindNames.Contains(pawnKindName); + }).ToList(); + List list2 = allDefs.Where(delegate (RaceGroupDef group) + { + List raceNames = group.raceNames; + return raceNames != null && raceNames.Contains(raceName); + }).ToList(); + int num = list.Count() + list2.Count(); + if (num == 0) + { + return null; + } + if (num == 1) + { + return list.Concat(list2).Single(); + } + RaceGroupDef result; + if ((result = list.FirstOrDefault((RaceGroupDef match) => !IsThisMod(match))) == null) + { + if ((result = list2.FirstOrDefault((RaceGroupDef match) => !IsThisMod(match))) == null) + { + result = (list.FirstOrDefault() ?? list2.FirstOrDefault()); + } + } + return result; + } + + public static RaceGeneDef GetRaceGenDefInternal(PawnKindDef kindDef) + { + string raceName = kindDef.race.defName; + string pawnKindName = kindDef.defName; + string raceGroupName = GetRaceGroupDef(kindDef).defName; + IEnumerable allDefs = DefDatabase.AllDefs; + List list = allDefs.Where(delegate (RaceGeneDef group) + { + List pawnKindNames = group.pawnKindNames; + return pawnKindNames != null && pawnKindNames.Contains(pawnKindName); + }).ToList(); + List list2 = allDefs.Where(delegate (RaceGeneDef group) + { + List raceNames = group.raceNames; + return raceNames != null && raceNames.Contains(raceName); + }).ToList(); + List list3 = allDefs.Where(delegate (RaceGeneDef group) + { + String raceGroupDefName = group.raceGroup; + return raceGroupDefName != null && raceGroupDefName == raceGroupName; + }).ToList(); + + RaceGeneDef result = null; + //First check if there is a matching pawnkinddef then race, then racegroup + if (list.Any()) + { + result = list.RandomElement(); + } + else if (list2.Any() && result == null) + { + result = list2.RandomElement(); + } + else if (list3.Any() && result == null) + { + result = list3.RandomElement(); + } + else + { + result = null; + } + return result; + + + } + + private static RaceGroupDef GetRaceGroupDef(PawnKindDef kindDef) + { + RaceGroupDef raceGroupDef = null; + bool temp = TryGetRaceGroupDef(kindDef, out raceGroupDef); + return raceGroupDef; + } + + private static bool IsThisMod(Def def) + { + return LoadedModManager.RunningMods.Single((ModContentPack pack) => pack.Name == "RimJobWorld").AllDefs.Contains(def); + } + + private static readonly IDictionary RaceGroupByPawnKind = new Dictionary(); + } + + +} diff --git a/Source/RJW_BGS/RaceGeneDef.cs b/Source/RJW_BGS/RaceGeneDef.cs new file mode 100644 index 0000000..9e9b01e --- /dev/null +++ b/Source/RJW_BGS/RaceGeneDef.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Verse; +using rjw; + +namespace RJW_BGS +{ + public class RaceGeneDef : Def + { + public String raceGroup; + public List raceNames; + public List pawnKindNames; + public List genes; + public List geneweights; + public String hybridName; + } +} diff --git a/Source/RJW_BGS/obj/Debug/DesignTimeResolveAssemblyReferences.cache b/Source/RJW_BGS/obj/Debug/DesignTimeResolveAssemblyReferences.cache new file mode 100644 index 0000000..c5634ba Binary files /dev/null and b/Source/RJW_BGS/obj/Debug/DesignTimeResolveAssemblyReferences.cache differ diff --git a/Source/RJW_BGS/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache b/Source/RJW_BGS/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache new file mode 100644 index 0000000..91c9a9d Binary files /dev/null and b/Source/RJW_BGS/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache differ diff --git a/Source/RJW_BGS/obj/Debug/RJW_BGS.csproj.AssemblyReference.cache b/Source/RJW_BGS/obj/Debug/RJW_BGS.csproj.AssemblyReference.cache new file mode 100644 index 0000000..b25e0d3 Binary files /dev/null and b/Source/RJW_BGS/obj/Debug/RJW_BGS.csproj.AssemblyReference.cache differ diff --git a/Source/RJW_BGS/obj/Debug/RJW_BGS.csproj.CoreCompileInputs.cache b/Source/RJW_BGS/obj/Debug/RJW_BGS.csproj.CoreCompileInputs.cache new file mode 100644 index 0000000..2079049 --- /dev/null +++ b/Source/RJW_BGS/obj/Debug/RJW_BGS.csproj.CoreCompileInputs.cache @@ -0,0 +1 @@ +a5d60a90fbe0915a4fbdad7293220b682c74b0b1 diff --git a/Source/RJW_BGS/obj/Debug/RJW_BGS.csproj.FileListAbsolute.txt b/Source/RJW_BGS/obj/Debug/RJW_BGS.csproj.FileListAbsolute.txt new file mode 100644 index 0000000..01ed640 --- /dev/null +++ b/Source/RJW_BGS/obj/Debug/RJW_BGS.csproj.FileListAbsolute.txt @@ -0,0 +1,4 @@ +C:\Program Files (x86)\Steam\steamapps\common\RimWorld\Mods\RJW_Bestiality_Gene_Support\Assemblies\RJW_BGS.dll +C:\Program Files (x86)\Steam\steamapps\common\RimWorld\Mods\RJW_Bestiality_Gene_Support\Source\RJW_BGS\obj\Debug\RJW_BGS.csproj.AssemblyReference.cache +C:\Program Files (x86)\Steam\steamapps\common\RimWorld\Mods\RJW_Bestiality_Gene_Support\Source\RJW_BGS\obj\Debug\RJW_BGS.csproj.CoreCompileInputs.cache +C:\Program Files (x86)\Steam\steamapps\common\RimWorld\Mods\RJW_Bestiality_Gene_Support\Source\RJW_BGS\obj\Debug\RJW_BGS.dll diff --git a/Source/RJW_BGS/obj/Debug/RJW_BGS.dll b/Source/RJW_BGS/obj/Debug/RJW_BGS.dll new file mode 100644 index 0000000..6a03c3a Binary files /dev/null and b/Source/RJW_BGS/obj/Debug/RJW_BGS.dll differ