diff --git a/Common/Assemblies/.gitignore b/Common/Assemblies/.gitignore new file mode 100644 index 0000000..8550acb --- /dev/null +++ b/Common/Assemblies/.gitignore @@ -0,0 +1,2 @@ +*dll +!RJW-Genes.dll diff --git a/Common/Assemblies/Rjw-Genes.dll b/Common/Assemblies/Rjw-Genes.dll index b1fd66c..e5045f9 100644 Binary files a/Common/Assemblies/Rjw-Genes.dll and b/Common/Assemblies/Rjw-Genes.dll differ diff --git a/Common/Defs/Genes/GeneCategories.xml b/Common/Defs/Genes/GeneCategories.xml index 10aa8e9..68dc199 100644 --- a/Common/Defs/Genes/GeneCategories.xml +++ b/Common/Defs/Genes/GeneCategories.xml @@ -4,30 +4,55 @@ rjw_genes_gender - 20 + 21 - rjw_genes_genitalia - - 16 + rjw_genes_genitalia_type + + 19 + + + + rjw_genes_genitalia_extras + + 17 + + + + rjw_genes_genitalia_size + + 15 rjw_genes_breeding - 15 + 13 rjw_genes_cum - 14 + 12 + + + + rjw_damage + + 11 \ No newline at end of file diff --git a/Common/Defs/Genes/GeneDefs_Breeding.xml b/Common/Defs/Genes/GeneDefs_Breeding.xml index 14b1be7..793492f 100644 --- a/Common/Defs/Genes/GeneDefs_Breeding.xml +++ b/Common/Defs/Genes/GeneDefs_Breeding.xml @@ -26,7 +26,21 @@ Pawns with this gene are able to fertilize eggs with any fertile penis. World/WorldObjects/Expanding/Mechanoids 53 - rjw_genes_breeding + rjw_genes_breeding + + rjw_genes_zoophile + + rjw_genes_breeding + Xenotypes with this Gene are Zoophile. + Genes/Icons/Placeholder + 54 + +
  • + Zoophile +
  • +
    +
    + \ No newline at end of file diff --git a/Common/Defs/Genes/GeneDefs_Cum.xml b/Common/Defs/Genes/GeneDefs_Cum.xml index 0100d33..89334fe 100644 --- a/Common/Defs/Genes/GeneDefs_Cum.xml +++ b/Common/Defs/Genes/GeneDefs_Cum.xml @@ -58,8 +58,6 @@ - - + + + + rjw_genes_generous_donor + + rjw_genes_cum + When this Xenotype transfers nutrition via cumshot, the giver will not get hungry. (Licentia Configuration for Transfer Nutrition must be enabled). + Genes/Icons/Placeholder + 538 + \ No newline at end of file diff --git a/Common/Defs/Genes/GeneDefs_Damage.xml b/Common/Defs/Genes/GeneDefs_Damage.xml new file mode 100644 index 0000000..c44e937 --- /dev/null +++ b/Common/Defs/Genes/GeneDefs_Damage.xml @@ -0,0 +1,14 @@ + + + + + rjw_genes_elasticity + + rjw_damage + This Xenotype cannot get stretched by huge penetrators. + Genes/Icons/Placeholder + RJW_Genes.Gene_Elasticity + 1 + + + \ No newline at end of file diff --git a/Common/Defs/Genes/GeneDefs_ExtraGenitaliaEndogenes.xml b/Common/Defs/Genes/GeneDefs_ExtraGenitalia.xml similarity index 98% rename from Common/Defs/Genes/GeneDefs_ExtraGenitaliaEndogenes.xml rename to Common/Defs/Genes/GeneDefs_ExtraGenitalia.xml index 703d8db..3459de5 100644 --- a/Common/Defs/Genes/GeneDefs_ExtraGenitaliaEndogenes.xml +++ b/Common/Defs/Genes/GeneDefs_ExtraGenitalia.xml @@ -1,7 +1,7 @@ - rjw_genes_genitalia + rjw_genes_genitalia_extras diff --git a/Common/Defs/Genes/GeneDefs_GenitaliaSizes.xml b/Common/Defs/Genes/GeneDefs_GenitaliaSizes.xml index 41dac59..72d2c53 100644 --- a/Common/Defs/Genes/GeneDefs_GenitaliaSizes.xml +++ b/Common/Defs/Genes/GeneDefs_GenitaliaSizes.xml @@ -1,7 +1,7 @@ - rjw_genes_genitalia + rjw_genes_genitalia_size diff --git a/Common/Defs/Genes/GeneDefs_GenitaliaTypeEndogenes.xml b/Common/Defs/Genes/GeneDefs_GenitaliaTypes.xml similarity index 97% rename from Common/Defs/Genes/GeneDefs_GenitaliaTypeEndogenes.xml rename to Common/Defs/Genes/GeneDefs_GenitaliaTypes.xml index 39f7f64..b646058 100644 --- a/Common/Defs/Genes/GeneDefs_GenitaliaTypeEndogenes.xml +++ b/Common/Defs/Genes/GeneDefs_GenitaliaTypes.xml @@ -2,7 +2,7 @@ - rjw_genes_genitalia + rjw_genes_genitalia_type
  • GenitalType
  • diff --git a/Common/Defs/Genes/GeneDefs_Reproduction.xml b/Common/Defs/Genes/GeneDefs_Reproduction.xml index ad27692..3599418 100644 --- a/Common/Defs/Genes/GeneDefs_Reproduction.xml +++ b/Common/Defs/Genes/GeneDefs_Reproduction.xml @@ -15,4 +15,17 @@
    + + rjw_genes_rapist + + Reproduction + Xenotypes with this Gene are Rapists. + Genes/Icons/Placeholder + 2 + +
  • + Rapist +
  • +
    +
    \ No newline at end of file diff --git a/KNOWN_BUGS.md b/KNOWN_BUGS.md index c190e10..d1153c0 100644 --- a/KNOWN_BUGS.md +++ b/KNOWN_BUGS.md @@ -25,4 +25,35 @@ Error: I added all "no-XXX" genes but my pawn has genitalia on map! Reason: If you go with Full-No-Genitals (No Penis, No Anus, No Breasts, No Vagina) then the pawn spawns without any Genitalia on the map, however then the RJW base-logic runs the sexualizer. -**Workaround**: Have atleast 1 genitalia enabled with Genes, I recommend the anus. \ No newline at end of file +**Workaround**: Have atleast 1 genitalia enabled with Genes, I recommend the anus. + +## Log Pops up for Xenotypes with Female/Male Only Gene + +Error: + +When using a Xenotype with the Female only gene, upon refresh it can open the log with the following (red) statement: + +``` +[RJW] ChangeSex error (PAWNNAME) faction (FACTION). Probably tried to change sex at world gen for royalty implant, skipping +UnityEngine.StackTraceUtility:ExtractStackTrace () +Verse.Log:Error (string) +rjw.ModLog:Error (string) +rjw.GenderHelper:ChangeSex (Verse.Pawn,rjw.GenderHelper/Sex,rjw.GenderHelper/Sex) +rjw.GenderHelper:ChangeSex (Verse.Pawn,System.Action) +RJW_Genes.Gene_FemaleOnly:AdjustPawnToFemale () +RJW_Genes.Gene_FemaleOnly:PostMake () +RimWorld.GeneMaker:MakeGene (Verse.GeneDef,Verse.Pawn) +[... some more ...] +``` + +Reason: + +RJW covers some corner cases when the pawn is changed before creation. + +Current Solution: + +Ignore this. The pawns seem to have the right sex and genitalia, I cannot "catch" the exception as it is only a Log Error. I would need to do harmony patching and ... that seems to be too much. + +Aimed Solution: + +Patch ChangeSex to skip for pawns with the two genes producing this. \ No newline at end of file diff --git a/README.md b/README.md index cc00f1b..c5dc677 100644 --- a/README.md +++ b/README.md @@ -9,8 +9,8 @@ This is my first Mod I started from scratch so any feedback is very welcome. - Different Genitalia Types - Genitalia Size Scaling - Extra Genitalia (and a Futa Attempt) -- Some Traits -- Cum-Amount Changes +- Some Traits, Cumflation Immunity, Elasticity +- Cum-Amount Changes, Transfer Nutrition - Mech Breeding / Insect Breeding Support See [planned things](TODOS.md) and feel free to contribute. @@ -23,5 +23,5 @@ Please consider looking at [the known bugs](./KNOWN_BUGS.md) ## Genes vs. Races -I currently don't use Genes after Biotech was introduced. +I currently don't use Races after Biotech was introduced. One of the main motivations was to have genes being added to the xenotypes that other mods and the base game add, e.g. adding demonic penis for impids. \ No newline at end of file diff --git a/Source/GeneDefOf.cs b/Source/GeneDefOf.cs index 2c0b42e..88cf099 100644 --- a/Source/GeneDefOf.cs +++ b/Source/GeneDefOf.cs @@ -6,8 +6,10 @@ namespace RJW_Genes [DefOf] public static class GeneDefOf { - public static readonly GeneCategoryDef rjw_genes_genitalia; + public static readonly GeneCategoryDef rjw_genes_genitalia_type; + public static readonly GeneCategoryDef rjw_genes_genitalia_size; public static readonly GeneCategoryDef rjw_genes_gender; + public static readonly GeneCategoryDef rjw_genes_breeding; // Base Genitalia Types public static readonly GeneDef rjw_genes_human_genitalia; @@ -53,14 +55,20 @@ namespace RJW_Genes public static readonly GeneDef rjw_genes_insectincubator; public static readonly GeneDef rjw_genes_insectbreeder; - //Cum + // Cum public static readonly GeneDef rjw_genes_no_cum; public static readonly GeneDef rjw_genes_much_cum; public static readonly GeneDef rjw_genes_very_much_cum; [MayRequire("LustLicentia.RJWLabs")] public static readonly GeneDef rjw_genes_likes_cumflation; - //[MayRequire("LustLicentia.RJWLabs")] public static readonly GeneDef rjw_genes_cumflation_immunity; //Does currently not work like this - - //Reproduction + [MayRequire("LustLicentia.RJWLabs")] public static readonly GeneDef rjw_genes_cumflation_immunity; + [MayRequire("LustLicentia.RJWLabs")] public static readonly GeneDef rjw_genes_generous_donor; + + // Reproduction public static readonly GeneDef rjw_genes_hypersexual; + public static readonly GeneDef rjw_genes_rapist; + public static readonly GeneDef rjw_genes_zoophile; + + // Damage & Side Effects + [MayRequire("LustLicentia.RJWLabs")] public static readonly GeneDef rjw_genes_elasticity; } } diff --git a/Source/Genes/Breeding/PatchPawnExtensions.cs b/Source/Genes/Breeding/PatchPawnExtensions.cs index f3df7a8..be2e2dc 100644 --- a/Source/Genes/Breeding/PatchPawnExtensions.cs +++ b/Source/Genes/Breeding/PatchPawnExtensions.cs @@ -17,7 +17,7 @@ namespace RJW_Genes { if (!__result) { - __result = GeneUtility.isInsectBreeder(pawn); + __result = GeneUtility.IsInsectBreeder(pawn); } } } diff --git a/Source/Genes/Cum/Patch_Cumflation.cs b/Source/Genes/Cum/Patch_Cumflation.cs new file mode 100644 index 0000000..9e26a26 --- /dev/null +++ b/Source/Genes/Cum/Patch_Cumflation.cs @@ -0,0 +1,39 @@ +using System; +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; +using LicentiaLabs; + +namespace RJW_Genes +{ + /// + /// Changes LicentiaLabs (if Present) to not cumflate pawns that are cumflation immune. + /// This code is exercised / loaded in the HarmonyInit. + /// Patched File: https://gitgud.io/John-the-Anabaptist/licentia-labs/-/blob/master/Source/LicentiaLabs/LicentiaLabs/Cumflation.cs + /// + /// + class Patch_Cumflation + { + // This patch does not need the normal Harmony Targetting, + // as it needs to be added only on demand (See HarmonyInit.cs) + public static bool Prefix(SexProps props) + { + // Harmony Logic skips the original Method after Prefix when "false" is returned + // See https://harmony.pardeike.net/articles/execution.html + + // We skip the whole Cumflation Logic when the Partner is Cumflation Immune + if (props != null && props.partner != null && GeneUtility.IsCumflationImmune(props.partner)) + { + return false; + } + return true; + } + } +} \ No newline at end of file diff --git a/Source/Genes/Cum/Patch_TransferNutrition.cs b/Source/Genes/Cum/Patch_TransferNutrition.cs new file mode 100644 index 0000000..cf8d92d --- /dev/null +++ b/Source/Genes/Cum/Patch_TransferNutrition.cs @@ -0,0 +1,41 @@ +using System; +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; +using LicentiaLabs; + +namespace RJW_Genes +{ + /// + /// Changes LicentiaLabs (if Present) to alter the TransferNutrition for rjw_genes_generous_donor. + /// This code is exercised / loaded in the HarmonyInit. + /// Patched File: https://gitgud.io/John-the-Anabaptist/licentia-labs/-/blob/master/Source/LicentiaLabs/LicentiaLabs/Cumflation.cs + /// + /// + class Patch_TransferNutrition + { + // This patch does not need the normal Harmony Targetting, + // as it needs to be added only on demand (See HarmonyInit.cs) + public static void Postfix(Pawn giver, Pawn receiver, float cumAmount) + { + // Design decision: + // I could have done some transpiler stuff, but that is scary and might need to be adjusted quite a lot + // Hence, I simply re-book the nutrition back to the giver in the Postfix. That should be robust and easy. + + if (GeneUtility.IsGenerousDonor(giver)) { + float donatedNutrition = CumflationHelper.CalculateNutritionAmount(giver, cumAmount); + // TODO: In theory, there could be something weird happening if the donor has food less than X and the "IgnoreThermodynamics" is set on. + // Then it can happen that the donor ends up with more food than he had before cumshot, but I think that is somewhat funny given that you have ignore Thermodynamics on. + Need_Food inflatorFood = giver.needs.TryGetNeed(); + inflatorFood.CurLevel += donatedNutrition; + } + } + } +} \ No newline at end of file diff --git a/Source/Genes/Damage/Gene_Elasticity.cs b/Source/Genes/Damage/Gene_Elasticity.cs new file mode 100644 index 0000000..603a18d --- /dev/null +++ b/Source/Genes/Damage/Gene_Elasticity.cs @@ -0,0 +1,56 @@ +using LicentiaLabs; +using Verse; + +namespace RJW_Genes +{ + /// + /// This Gene adds Licentia-Labs Elasticised Hediff to a Pawn. + /// Note: I had a HarmonyPatch first, similar to skipping cumflation, but the Stretching Logic is called quite a lot and for both pawns actually. + /// Hence, I think choosing the Elasticiced Hediff was good as then everything is covered by "Licentia-Logic". + /// + public class Gene_Elasticity : Gene + { + + private int ticksToReset = RESET_INTERVAL; + private const int RESET_INTERVAL = 60000; // 60k should be 1 day + + public override void PostAdd() + { + base.PostAdd(); + // Doing it like this will add the hediff with a severity of ~0.5, but it will decay. + // Hence we check with the Ticks to update. + this.pawn.health.AddHediff(Licentia.HediffDefs.Elasticised); + ResetSeverity(); + } + + public override void Tick() + { + base.Tick(); + --this.ticksToReset; + if (this.ticksToReset > 0) + return; + this.ticksToReset = RESET_INTERVAL; + ResetSeverity(); + } + + public override void PostRemove() + { + Hediff candidate = pawn.health.hediffSet.GetFirstHediffOfDef(Licentia.HediffDefs.Elasticised); + if (candidate != null) + { + pawn.health.RemoveHediff(candidate); + } + base.PostRemove(); + } + + + private void ResetSeverity(float severity = 0.7f) + { + Hediff candidate = pawn.health.hediffSet.GetFirstHediffOfDef(Licentia.HediffDefs.Elasticised); + if (candidate != null) + { + candidate.Severity = severity; + } + } + } +} diff --git a/Source/Genes/GeneUtility.cs b/Source/Genes/GeneUtility.cs index 5144aad..ce022ba 100644 --- a/Source/Genes/GeneUtility.cs +++ b/Source/Genes/GeneUtility.cs @@ -1,4 +1,5 @@ -using Verse; +using System; +using Verse; namespace RJW_Genes { @@ -22,7 +23,7 @@ namespace RJW_Genes return pawn.genes.HasGene(GeneDefOf.rjw_genes_insectincubator); } - public static bool isInsectBreeder(Pawn pawn) + public static bool IsInsectBreeder(Pawn pawn) { if (pawn.genes == null) { @@ -40,5 +41,31 @@ namespace RJW_Genes } return MaxEggSize; } + + internal static bool IsElastic(Pawn pawn) + { + if (pawn.genes == null) + { + return false; + } + return pawn.genes.HasGene(GeneDefOf.rjw_genes_elasticity); + } + + public static bool IsCumflationImmune(Pawn pawn) + { + if (pawn.genes == null) + { + return false; + } + return pawn.genes.HasGene(GeneDefOf.rjw_genes_cumflation_immunity); + } + public static bool IsGenerousDonor(Pawn pawn) + { + if (pawn.genes == null) + { + return false; + } + return pawn.genes.HasGene(GeneDefOf.rjw_genes_generous_donor); + } } } \ No newline at end of file diff --git a/Source/HarmonyInit.cs b/Source/HarmonyInit.cs index c2f288e..35ffb2e 100644 --- a/Source/HarmonyInit.cs +++ b/Source/HarmonyInit.cs @@ -1,6 +1,6 @@ using Verse; using HarmonyLib; - +using System; namespace RJW_Genes { @@ -11,6 +11,28 @@ namespace RJW_Genes { Harmony harmony = new Harmony("rjw_genes"); harmony.PatchAll(); + + // Patch Licentia, if Licentia exists + // Logic & Explanation taken from https://rimworldwiki.com/wiki/Modding_Tutorials/Compatibility_with_DLLs + // Adjusted to use ModsConfig (which makes it work, the example above does not run out of the box) + try + { + ((Action)(() => + { + if (ModsConfig.IsActive("LustLicentia.RJWLabs")) + { + // Gene: Cumflation Immunity [Prefix Patch] + harmony.Patch(AccessTools.Method(typeof(LicentiaLabs.CumflationHelper), nameof(LicentiaLabs.CumflationHelper.Cumflation)), + prefix: new HarmonyMethod(typeof(Patch_Cumflation), nameof(Patch_Cumflation.Prefix))); + // Gene: Generous Donor [Postfix Patch] + harmony.Patch(AccessTools.Method(typeof(LicentiaLabs.CumflationHelper), nameof(LicentiaLabs.CumflationHelper.TransferNutrition)), + postfix: new HarmonyMethod(typeof(Patch_TransferNutrition), nameof(Patch_TransferNutrition.Postfix))); + } + }))(); + } + catch (TypeLoadException ex) { + // To be expected for people without Licentia Labs + } } } } \ No newline at end of file diff --git a/Source/Rjw-Genes.csproj b/Source/Rjw-Genes.csproj index befe2c2..67da2c6 100644 --- a/Source/Rjw-Genes.csproj +++ b/Source/Rjw-Genes.csproj @@ -29,6 +29,10 @@ ..\..\..\RimWorldWin64_Data\Managed\Assembly-CSharp.dll False + + ..\..\licentia-labs\Assemblies\LicentiaLabs.dll + False + ..\..\rjw\1.4\Assemblies\RJW.dll False @@ -60,6 +64,9 @@ + + + diff --git a/TODOS.md b/TODOS.md index 5cd5bed..5bf70df 100644 --- a/TODOS.md +++ b/TODOS.md @@ -8,10 +8,6 @@ So any help is very appreciated, even if it is just pointing me to existing simi **Sanguophage like Cumwhores** adding Hemogen and refilling it by getting semen. Showstopper here is the amount of code required, and that I need to understand a bit better of harmony to run the AfterSexUtility and modulate SexChances. -**Immunity to Soreness / Ignoring Cumflation Mali** - -**LicentiaLabs TransferNutrition _Generous Donor_** pawns that get head do not loose nutrition or only part of what they fire. - **Adjustable Cock-Size** like e.g. artificial genitalia have ## Animal Gene Inheritance