diff --git a/Common/Assemblies/Rjw-Genes.dll b/Common/Assemblies/Rjw-Genes.dll index b65ab1a..9eef3ca 100644 Binary files a/Common/Assemblies/Rjw-Genes.dll and b/Common/Assemblies/Rjw-Genes.dll differ diff --git a/Source/Animal_Inheritance/First.cs b/Source/Animal_Inheritance/First.cs index 8d353f7..8194ab3 100644 --- a/Source/Animal_Inheritance/First.cs +++ b/Source/Animal_Inheritance/First.cs @@ -14,7 +14,7 @@ namespace RJW_BGS { static First() { - RJWcopy.Racegroupdictbuilder(); + //RJWcopy.Racegroupdictbuilder(); //Prints all found race dicts (debugging only) //logAllFoundRaceGroupGenes diff --git a/Source/Animal_Inheritance/InheritanceUtility.cs b/Source/Animal_Inheritance/InheritanceUtility.cs index 8456f45..2b260dd 100644 --- a/Source/Animal_Inheritance/InheritanceUtility.cs +++ b/Source/Animal_Inheritance/InheritanceUtility.cs @@ -42,8 +42,7 @@ namespace RJW_BGS public static List SelectGenes(Pawn pawn) { List genelist = new List(); - PawnKindDef pawnKindDef = pawn.kindDef; - RaceGeneDef raceGeneDef = RJWcopy.GetRaceGenDefInternal(pawnKindDef); + RaceGeneDef raceGeneDef = RJWcopy.GetRaceGeneDefInternal(pawn); if (raceGeneDef != null) { foreach (BestialityGeneInheritanceDef gene in raceGeneDef.genes) diff --git a/Source/Animal_Inheritance/RJW_BGSSettings.cs b/Source/Animal_Inheritance/RJW_BGSSettings.cs index 180567c..1d5d859 100644 --- a/Source/Animal_Inheritance/RJW_BGSSettings.cs +++ b/Source/Animal_Inheritance/RJW_BGSSettings.cs @@ -5,6 +5,7 @@ using System.Text; using System.Threading.Tasks; using Verse; using UnityEngine; + namespace RJW_Genes.Animal_Inheritance { public class RJW_BGSSettings : ModSettings diff --git a/Source/Animal_Inheritance/RJWcopies.cs b/Source/Animal_Inheritance/RJWcopies.cs deleted file mode 100644 index 2c11074..0000000 --- a/Source/Animal_Inheritance/RJWcopies.cs +++ /dev/null @@ -1,157 +0,0 @@ -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 pawnKindDefs = allDefs.Where(delegate (RaceGroupDef group) - { - List pawnKindNames = group.pawnKindNames; - return pawnKindNames != null && pawnKindNames.Contains(pawnKindName); - }).ToList(); - List raceNameDefs = allDefs.Where(delegate (RaceGroupDef group) - { - List raceNames = group.raceNames; - return raceNames != null && raceNames.Contains(raceName); - }).ToList(); - - int availableDefs = pawnKindDefs.Count() + raceNameDefs.Count(); - if (availableDefs == 0) - { - //Exit Early - return null; - } - if (availableDefs == 1) - { - return pawnKindDefs.Concat(raceNameDefs).Single(); - } - - RaceGroupDef result; - if ((result = pawnKindDefs.FirstOrDefault((RaceGroupDef match) => !IsThisMod(match))) == null) - { - if ((result = raceNameDefs.FirstOrDefault((RaceGroupDef match) => !IsThisMod(match))) == null) - { - result = (pawnKindDefs.FirstOrDefault() ?? raceNameDefs.FirstOrDefault()); - } - } - - return result; - } - - //slightly modified copy of code above so it also works for racegenedefs - public static RaceGeneDef GetRaceGenDefInternal(PawnKindDef kindDef) - { - if (kindDef == null) - { - return null; - } - string raceName = kindDef.race.defName; - string pawnKindName = kindDef.defName; - RaceGroupDef raceGroupDef = GetRaceGroupDef(kindDef); - IEnumerable allDefs = DefDatabase.AllDefs; - Log.Message(allDefs.Count().ToString()); - List pawnKindDefs = allDefs.Where(delegate (RaceGeneDef group) - { - List pawnKindNames = group.pawnKindNames; - return pawnKindNames != null && pawnKindNames.Contains(pawnKindName); - }).ToList(); - List raceKindDefs = allDefs.Where(delegate (RaceGeneDef group) - { - List raceNames = group.raceNames; - return raceNames != null && raceNames.Contains(raceName); - }).ToList(); - List raceGroupDefs = new List(); - if (raceGroupDef != null) - { - /* - // Log Messages for Debugging Only, prints the Genes found for this individual - Log.Message("found a raceGroupDef"); - Log.Message(raceGroupDef.defName); - foreach (RaceGeneDef rgd in allDefs) - { - Log.Message(rgd.defName); - } - */ - raceGroupDefs = allDefs.Where(delegate (RaceGeneDef group) - { - String raceGroupDefName = group.raceGroup; - return raceGroupDefName != null && raceGroupDefName == raceGroupDef.defName; - }).ToList(); - } - RaceGeneDef result = null; - //First check if there is a matching pawnkinddef then race, then racegroup - if (pawnKindDefs.Any()) - { - result = pawnKindDefs.RandomElement(); - } - else if (raceKindDefs.Any() && result == null) - { - result = raceKindDefs.RandomElement(); - } - else if (raceGroupDefs.Any() && result == null) - { - result = raceGroupDefs.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/Animal_Inheritance/RaceGeneDef_Helper.cs b/Source/Animal_Inheritance/RaceGeneDef_Helper.cs new file mode 100644 index 0000000..ed6541a --- /dev/null +++ b/Source/Animal_Inheritance/RaceGeneDef_Helper.cs @@ -0,0 +1,69 @@ +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 based on racegroupdefinternal which has a similar function + public static RaceGeneDef GetRaceGeneDefInternal(Pawn pawn) + { + PawnKindDef kindDef = pawn.kindDef; + if (kindDef == null) + { + return null; + } + string raceName = kindDef.race.defName; + string pawnKindName = kindDef.defName; + IEnumerable allDefs = DefDatabase.AllDefs; + PawnData pawnData = SaveStorage.DataStore.GetPawnData(pawn); + RaceGroupDef raceGroupDef = pawnData.RaceSupportDef; + List pawnKindDefs = allDefs.Where(delegate (RaceGeneDef group) + { + List pawnKindNames = group.pawnKindNames; + return pawnKindNames != null && pawnKindNames.Contains(pawnKindName); + }).ToList(); + List raceKindDefs = allDefs.Where(delegate (RaceGeneDef group) + { + List raceNames = group.raceNames; + return raceNames != null && raceNames.Contains(raceName); + }).ToList(); + List raceGroupDefs = new List(); + if (raceGroupDef != null) + { + raceGroupDefs = allDefs.Where(delegate (RaceGeneDef group) + { + String raceGroupDefName = group.raceGroup; + return raceGroupDefName != null && raceGroupDefName == raceGroupDef.defName; + }).ToList(); + } + RaceGeneDef result = null; + //First check if there is a matching pawnkinddef then race, then racegroup + if (pawnKindDefs.Any()) + { + result = pawnKindDefs.RandomElement(); + } + else if (raceKindDefs.Any() && result == null) + { + result = raceKindDefs.RandomElement(); + } + else if (raceGroupDefs.Any() && result == null) + { + result = raceGroupDefs.RandomElement(); + } + else + { + result = null; + } + return result; + + + } + } +} diff --git a/Source/Genes/Special/Patch_OrgasmRush.cs b/Source/Genes/Special/Patch_OrgasmRush.cs index 7f4c167..0b881f2 100644 --- a/Source/Genes/Special/Patch_OrgasmRush.cs +++ b/Source/Genes/Special/Patch_OrgasmRush.cs @@ -21,7 +21,7 @@ namespace RJW_Genes if (props.pawn == null || !props.hasPartner()) return; - if (props.pawn.genes.HasGene(GeneDefOf.rjw_genes_orgasm_rush)) + if (props.pawn.genes != null && props.pawn.genes.HasGene(GeneDefOf.rjw_genes_orgasm_rush)) { props.pawn.needs.rest.CurLevel += REST_INCREASE; } diff --git a/Source/Rjw-Genes.csproj b/Source/Rjw-Genes.csproj index 554b542..c7b5a48 100644 --- a/Source/Rjw-Genes.csproj +++ b/Source/Rjw-Genes.csproj @@ -27,7 +27,7 @@ False - ..\..\..\RimWorldWin64_Data\Managed\Assembly-CSharp.dll + ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\RimWorld\RimWorldWin64_Data\Managed\Assembly-CSharp.dll False @@ -35,7 +35,7 @@ False - ..\..\rjw\1.4\Assemblies\RJW.dll + ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\RimWorld\Mods\rjw-master\1.4\Assemblies\RJW.dll False @@ -50,12 +50,12 @@ - - ..\..\..\RimWorldWin64_Data\Managed\UnityEngine.CoreModule.dll + + ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\RimWorld\RimWorldWin64_Data\Managed\UnityEngine.dll False - - ..\..\..\RimWorldWin64_Data\Managed\UnityEngine.IMGUIModule.dll + + ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\RimWorld\RimWorldWin64_Data\Managed\UnityEngine.CoreModule.dll False @@ -67,7 +67,7 @@ - +