Add files via upload

This commit is contained in:
Shabakur 2022-11-30 11:29:45 +01:00 committed by GitHub
parent 247e5355fa
commit 601f7d156e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
20 changed files with 665 additions and 0 deletions

31
About/About.xml Normal file
View File

@ -0,0 +1,31 @@
<ModMetaData>
<name>RJW Animal Gene Inheritance</name>
<author>Shabakur</author>
<packageId>Shabakur.rjw.animal.gene.inheritance</packageId>
<supportedVersions>
<li>1.4</li>
</supportedVersions>
<description>Allows pawn to inherit genes from beasts.</description>
<modDependencies>
<li>
<packageId>ludeon.rimworld.biotech</packageId>
<displayName>Biotech</displayName>
</li>
<li>
<packageId>rim.job.world</packageId>
<displayName>RimJobWorld</displayName>
<downloadUrl>https://www.loverslab.com/files/file/7257-rimjobworld/</downloadUrl>
</li>
<li>
<packageId>brrainz.harmony</packageId>
<displayName>Harmony</displayName>
<steamWorkshopUrl>steam://url/CommunityFilePage/2009463077</steamWorkshopUrl>
<downloadUrl>https://github.com/pardeike/HarmonyRimWorld/releases/latest</downloadUrl>
</li>
</modDependencies>
<loadAfter>
<li>brrainz.harmony</li>
<li>ludeon.rimworld.biotech</li>
<li>rim.job.world</li>
</loadAfter>
</ModMetaData>

BIN
Assemblies/RJW_BGS.dll Normal file

Binary file not shown.

View File

@ -0,0 +1,38 @@
<?xml version="1.0" encoding="utf-8"?>
<Defs>
<!--
<RJW_BGS.RaceGeneDef>
<defName>Canine</defName>
defName can be anything you want, as long as it is unique
<raceGroup>Canine_Group</raceGroup>
RJW.Racegroupdef, all animals in the raceGroup will be part of this group
<raceNames>
<li> </li>
</raceNames>
For more direct control you can use raceNames directly.
<pawnKindNames>
<li> </li>
</pawnKindNames>
For even more direct control you can use pawnKindNames.
The RaceGeneDef for an animal will first be decided by if it is in the pawnkindNames, after that racenames and lastly racegroup,
so if there is for a wolf a RaceGeneDef with the canine group and a second which has wolf under raceNames it will always use the second one to determine
which genes can be inherited
<genes>
<li>Ears_Floppy</li>
</genes>
The genes which may be inherited.
<geneweights>
<li>90</li>
</geneweights>
WIP, the chance of each gene to be inherited. Is in same order as genes, so for the second gene the chance to inherit is based on the second line in geweights.
</RJW_BGS.RaceGeneDef>
-->
</Defs>

View File

@ -0,0 +1,109 @@
<?xml version="1.0" encoding="utf-8"?>
<Defs>
<RJW_BGS.RaceGeneDef>
<defName>Canine</defName>
<raceGroup>Canine_Group</raceGroup>
<genes>
<li>Ears_Floppy</li>
</genes>
<geneweights>
<li>90</li>
</geneweights>
</RJW_BGS.RaceGeneDef>
<RJW_BGS.RaceGeneDef>
<defName>Insect</defName>
<raceGroup>Insect_Group</raceGroup>
<genes>
<li>Beauty_Ugly</li>
</genes>
<geneweights>
<li>50</li>
</geneweights>
</RJW_BGS.RaceGeneDef>
<RJW_BGS.RaceGeneDef>
<defName>Feline</defName>
<raceGroup>Feline_Group</raceGroup>
<genes>
<li>Ears_Cat</li>
<li>Sleepy</li>
<li>DarkVision</li>
</genes>
<geneweights>
<li>90</li>
<li>25</li>
<li>25</li>
</geneweights>
</RJW_BGS.RaceGeneDef>
<!--
<RJW_BGS.RaceGeneDef>
<defName>Equine</defName>
<raceGroup>Equine_Group</raceGroup>
<genes>
<li>Ears_Floppy</li>
</genes>
<geneweights>
<li>10</li>
</geneweights>
</RJW_BGS.RaceGeneDef>
-->
<RJW_BGS.RaceGeneDef>
<defName>Dragon</defName>
<raceGroup>Dragon_Group</raceGroup>
<genes>
<li>Unstoppable</li>
<li>Headbone_CenterHorn</li>
</genes>
<geneweights>
<li>25</li>
<li>90</li>
</geneweights>
</RJW_BGS.RaceGeneDef>
<RJW_BGS.RaceGeneDef>
<defName>Rodent</defName>
<raceGroup>Rodent_Group</raceGroup>
<genes>
<li>Fertile</li>
</genes>
<geneweights>
<li>10</li>
</geneweights>
</RJW_BGS.RaceGeneDef>
<RJW_BGS.RaceGeneDef>
<defName>Racoon</defName>
<raceGroup>Raccon_Group</raceGroup>
<genes>
<li>StrongStomach</li>
</genes>
<geneweights>
<li>50</li>
</geneweights>
</RJW_BGS.RaceGeneDef>
<!--
<RJW_BGS.RaceGeneDef>
<defName>Needle</defName>
<raceGroup>Needle_Group</raceGroup>
<genes>
<li>Ears_Floppy</li>
</genes>
<geneweights>
<li>10</li>
</geneweights>
</RJW_BGS.RaceGeneDef>
-->
<!--
<RJW_BGS.RaceGeneDef>
<defName>Hemi</defName>
<raceGroup>Hemi_Group</raceGroup>
<genes>
<li>Ears_Floppy</li>
</genes>
<geneweights>
<li>10</li>
</geneweights>
</RJW_BGS.RaceGeneDef>
-->
</Defs>

30
Source/RJW_BGS/Class1.cs Normal file
View File

@ -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<RaceGroupDef>.AllDefs)
{
//Log.Message("defName = " + raceGroupDef2.defName);
if (raceGroupDef2.raceNames != null)
{
foreach (string race in raceGroupDef2.raceNames)
{
//Log.Message(race);
}
}
}
}
}
}

View File

@ -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();
}
}
}

View File

@ -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<GeneDef> AnimalInheritedGenes(Pawn father, Pawn mother)
{
List<GeneDef> genelist = new List<GeneDef>();
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<GeneDef>.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<GeneDef>.GetNamed(raceGeneDef.genes.RandomElement());
}
}
if (gene != null)
{
genelist.Add(gene);
}
}
}
return genelist;
}
}
}

View File

@ -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<GeneDef> genes = PregnancyUtility.GetInheritedGenes(dad, mother);
List<GeneDef> 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);
}
}
}
}
}
}

View File

@ -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<GeneDef> genes = InheritanceUtility.AnimalInheritedGenes(father, mother);
if (genes.Any())
{
foreach (GeneDef gene in genes)
{
__result.AddGene(gene);
}
}
}
}
}

View File

@ -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")]

View File

@ -0,0 +1,70 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{357A0848-8709-46AB-BD98-49FD8FD5DD13}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>RJW_BGS</RootNamespace>
<AssemblyName>RJW_BGS</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>false</DebugSymbols>
<DebugType>none</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\..\Assemblies\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="0Harmony">
<HintPath>..\..\..\..\..\..\workshop\content\294100\2009463077\Current\Assemblies\0Harmony.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Assembly-CSharp">
<HintPath>..\..\..\..\RimWorldWin64_Data\Managed\Assembly-CSharp.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="RJW">
<HintPath>..\..\..\RJW\1.4\Assemblies\RJW.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
<Reference Include="UnityEngine">
<HintPath>..\..\..\..\RimWorldWin64_Data\Managed\UnityEngine.dll</HintPath>
<Private>False</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Class1.cs" />
<Compile Include="Harmony_Init.cs" />
<Compile Include="InheritanceUtility.cs" />
<Compile Include="PatchRJWBestialityPregnancyUtility.cs" />
<Compile Include="PatchVanillaPregnancyUtility.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="RaceGeneDef.cs" />
<Compile Include="RJWcopies.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View File

@ -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

133
Source/RJW_BGS/RJWcopies.cs Normal file
View File

@ -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<PawnKindDef>.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<RaceGroupDef> allDefs = DefDatabase<RaceGroupDef>.AllDefs;
List<RaceGroupDef> list = allDefs.Where(delegate (RaceGroupDef group)
{
List<string> pawnKindNames = group.pawnKindNames;
return pawnKindNames != null && pawnKindNames.Contains(pawnKindName);
}).ToList<RaceGroupDef>();
List<RaceGroupDef> list2 = allDefs.Where(delegate (RaceGroupDef group)
{
List<string> raceNames = group.raceNames;
return raceNames != null && raceNames.Contains(raceName);
}).ToList<RaceGroupDef>();
int num = list.Count<RaceGroupDef>() + list2.Count<RaceGroupDef>();
if (num == 0)
{
return null;
}
if (num == 1)
{
return list.Concat(list2).Single<RaceGroupDef>();
}
RaceGroupDef result;
if ((result = list.FirstOrDefault((RaceGroupDef match) => !IsThisMod(match))) == null)
{
if ((result = list2.FirstOrDefault((RaceGroupDef match) => !IsThisMod(match))) == null)
{
result = (list.FirstOrDefault<RaceGroupDef>() ?? list2.FirstOrDefault<RaceGroupDef>());
}
}
return result;
}
public static RaceGeneDef GetRaceGenDefInternal(PawnKindDef kindDef)
{
string raceName = kindDef.race.defName;
string pawnKindName = kindDef.defName;
string raceGroupName = GetRaceGroupDef(kindDef).defName;
IEnumerable<RaceGeneDef> allDefs = DefDatabase<RaceGeneDef>.AllDefs;
List<RaceGeneDef> list = allDefs.Where(delegate (RaceGeneDef group)
{
List<string> pawnKindNames = group.pawnKindNames;
return pawnKindNames != null && pawnKindNames.Contains(pawnKindName);
}).ToList<RaceGeneDef>();
List<RaceGeneDef> list2 = allDefs.Where(delegate (RaceGeneDef group)
{
List<string> raceNames = group.raceNames;
return raceNames != null && raceNames.Contains(raceName);
}).ToList<RaceGeneDef>();
List<RaceGeneDef> list3 = allDefs.Where(delegate (RaceGeneDef group)
{
String raceGroupDefName = group.raceGroup;
return raceGroupDefName != null && raceGroupDefName == raceGroupName;
}).ToList<RaceGeneDef>();
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<PawnKindDef, RaceGroupDef> RaceGroupByPawnKind = new Dictionary<PawnKindDef, RaceGroupDef>();
}
}

View File

@ -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<string> raceNames;
public List<string> pawnKindNames;
public List<string> genes;
public List<float> geneweights;
public String hybridName;
}
}

View File

@ -0,0 +1 @@
a5d60a90fbe0915a4fbdad7293220b682c74b0b1

View File

@ -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

Binary file not shown.