diff --git a/CHANGELOG.md b/CHANGELOG.md index 56e3c93..9e2272a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -84,6 +84,10 @@ but they are meant mostly to have infectors immune against their own diseases. - Faction Penalties for spreading diseases, stealing genes and aging pawns with age transfer - Patch for [Imphilee Xeno](https://steamcommunity.com/sharedfiles/filedetails/?id=2990674516) by @Bunuffin +**Changes**:: + +- Cum-Amount-Changing genes now are XML Adjustable and share a single `.cs`-class + **Fixes:** - Fixed an Issue where pawns would always get the Pheromone social boost, unless they had the pheromone (#113) diff --git a/Common/Defs/GeneDefs/GeneDefs_Cum.xml b/Common/Defs/GeneDefs/GeneDefs_Cum.xml index 32ac80c..d85294f 100644 --- a/Common/Defs/GeneDefs/GeneDefs_Cum.xml +++ b/Common/Defs/GeneDefs/GeneDefs_Cum.xml @@ -21,10 +21,15 @@ Males of these species have no fluid. Genes/Icons/No_Cum - RJW_Genes.Gene_NoCum + RJW_Genes.Gene_ChangeCumAmount 533 0 1 + +
  • + 0.0 +
  • +
    @@ -32,10 +37,15 @@ Males of this species produce a lot of fluid. Genes/Icons/Much_Cum - RJW_Genes.Gene_MuchCum + RJW_Genes.Gene_ChangeCumAmount 534 1 - -1 + 0 + +
  • + 3.0 +
  • +
    @@ -44,10 +54,15 @@ Males of this species produce a whole lot of fluid. They are like fountains basically. Genes/Icons/Very_Much_Cum - RJW_Genes.Gene_VeryMuchCum + RJW_Genes.Gene_ChangeCumAmount 535 1 - -2 + -1 + +
  • + 20.0 +
  • +
    \ No newline at end of file diff --git a/Source/Common/Defs/MultiplierExtension.cs b/Source/Common/Defs/MultiplierExtension.cs new file mode 100644 index 0000000..5be194e --- /dev/null +++ b/Source/Common/Defs/MultiplierExtension.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Verse; + +namespace RJW_Genes +{ + public class MultiplierExtension : DefModExtension + { + public float multiplier; + } +} diff --git a/Source/Genes/Cum/CumUtility.cs b/Source/Genes/Cum/CumUtility.cs index b483aed..dba96b1 100644 --- a/Source/Genes/Cum/CumUtility.cs +++ b/Source/Genes/Cum/CumUtility.cs @@ -34,8 +34,23 @@ namespace RJW_Genes } - //Get total fluidamount a person has. - public static float GetTotalFluidAmount(Pawn pawn, float multiplier = 1f) + /// + /// Looks up the "MultiplierExtensions" Value for a given Gene, with a fall back. + /// Returns the fallback if there is no Extension, or if the Multiplier is smaller than 0. + /// + + public static float LookupCumMultiplier(Gene gene, float FALLBACK = 3.0f) => LookupCumMultiplier(gene.def,FALLBACK); + public static float LookupCumMultiplier(GeneDef def, float FALLBACK = 3.0f) + { + MultiplierExtension multiplier = def.GetModExtension(); + if (multiplier == null || multiplier.multiplier < 0) + return FALLBACK; + else return multiplier.multiplier; + } + + + //Get total fluidamount a person has. + public static float GetTotalFluidAmount(Pawn pawn, float multiplier = 1f) { var partBPR = Genital_Helper.get_genitalsBPR(pawn); var parts = Genital_Helper.get_PartsHediffList(pawn, partBPR); diff --git a/Source/Genes/Cum/Gene_MuchCum.cs b/Source/Genes/Cum/Gene_ChangeCumAmount.cs similarity index 51% rename from Source/Genes/Cum/Gene_MuchCum.cs rename to Source/Genes/Cum/Gene_ChangeCumAmount.cs index e88ac3f..dc10ba4 100644 --- a/Source/Genes/Cum/Gene_MuchCum.cs +++ b/Source/Genes/Cum/Gene_ChangeCumAmount.cs @@ -1,36 +1,38 @@ namespace RJW_Genes { - public class Gene_MuchCum : RJW_Gene + public class Gene_ChangeCumAmount : RJW_Gene { bool has_been_fired = false; - float multiplier_much_cum = 3f; public override void PostMake() { base.PostMake(); - CumUtility.MultiplyFluidAmountBy(pawn, multiplier_much_cum); + float multipier = CumUtility.LookupCumMultiplier(this); + CumUtility.MultiplyFluidAmountBy(pawn, multipier); has_been_fired = true; } public override void PostAdd() { base.PostAdd(); - if (!has_been_fired) { - CumUtility.MultiplyFluidAmountBy(pawn, multiplier_much_cum); + if (!has_been_fired) + { + float multipier = CumUtility.LookupCumMultiplier(this); + CumUtility.MultiplyFluidAmountBy(pawn, multipier); has_been_fired = true; } } - public override void PostRemove() { base.PostAdd(); if (has_been_fired) { - CumUtility.MultiplyFluidAmountBy(pawn, 1/multiplier_much_cum); + float multipier = CumUtility.LookupCumMultiplier(this); + CumUtility.MultiplyFluidAmountBy(pawn, 1/ multipier); has_been_fired = false; } } diff --git a/Source/Genes/Cum/Gene_NoCum.cs b/Source/Genes/Cum/Gene_NoCum.cs deleted file mode 100644 index 0c3e888..0000000 --- a/Source/Genes/Cum/Gene_NoCum.cs +++ /dev/null @@ -1,34 +0,0 @@ -namespace RJW_Genes -{ - public class Gene_NoCum : RJW_Gene - { - bool has_been_fired = false; - - - public override void PostMake() - { - base.PostMake(); - - CumUtility.MultiplyFluidAmountBy(pawn, 0f); - has_been_fired = true; - } - - public override void PostAdd() - { - base.PostAdd(); - if (!has_been_fired) { - CumUtility.MultiplyFluidAmountBy(pawn, 0f); - has_been_fired = true; - } - } - - - public override void PostRemove() - { - // Cum Removal does not do at the moment :/ I would need to safe the old cum amount but I don't want to at the moment - base.PostAdd(); - - } - - } -} diff --git a/Source/Genes/Cum/Gene_VeryMuchCum.cs b/Source/Genes/Cum/Gene_VeryMuchCum.cs deleted file mode 100644 index 21faecc..0000000 --- a/Source/Genes/Cum/Gene_VeryMuchCum.cs +++ /dev/null @@ -1,39 +0,0 @@ -namespace RJW_Genes -{ - public class Gene_VeryMuchCum : RJW_Gene - { - bool has_been_fired = false; - - float multiplier_much_cum = 10f; - - public override void PostMake() - { - base.PostMake(); - - CumUtility.MultiplyFluidAmountBy(pawn, multiplier_much_cum); - has_been_fired = true; - } - - public override void PostAdd() - { - base.PostAdd(); - if (!has_been_fired) { - CumUtility.MultiplyFluidAmountBy(pawn, multiplier_much_cum); - has_been_fired = true; - } - } - - - public override void PostRemove() - { - base.PostAdd(); - - if (has_been_fired) - { - CumUtility.MultiplyFluidAmountBy(pawn, 1/multiplier_much_cum); - has_been_fired = false; - } - } - - } -} diff --git a/Source/Rjw-Genes.csproj b/Source/Rjw-Genes.csproj index 8354632..dabb692 100644 --- a/Source/Rjw-Genes.csproj +++ b/Source/Rjw-Genes.csproj @@ -59,6 +59,7 @@ + @@ -105,9 +106,7 @@ - - - +