diff --git a/Common/Defs/GeneDefs/GeneDefs_Breeding.xml b/Common/Defs/GeneDefs/GeneDefs_Breeding.xml index bb6fbe4..e90dc89 100644 --- a/Common/Defs/GeneDefs/GeneDefs_Breeding.xml +++ b/Common/Defs/GeneDefs/GeneDefs_Breeding.xml @@ -115,4 +115,43 @@ -1 + + rjw_genes_hardwired_progenity + + Carriers of this gene need to procreate. They suffer negative effects if they are childless, and have increased capabilities if they reach a high amount of offsprings. + Genes/Icons/RJW_Genes_PheromoneSpit + 70 + + +
  • + + 0.7 + + + -0.5 + 1.2 + +
  • +
  • + + 1.05 + + + 0.1 + 0.1 + +
  • +
  • + + 1.1 + + + 0.25 + +
  • +
    + + 1 + 0 +
    \ No newline at end of file diff --git a/Common/Languages/English/Keyed/StatsReports.xml b/Common/Languages/English/Keyed/StatsReports.xml new file mode 100644 index 0000000..715bccb --- /dev/null +++ b/Common/Languages/English/Keyed/StatsReports.xml @@ -0,0 +1,8 @@ + + + + Pawn doesn't have any children. + Pawn has a decent amount of children. + Pawn has a lot of children. + + diff --git a/Source/GeneDefOf.cs b/Source/GeneDefOf.cs index 2e59f20..f7612cc 100644 --- a/Source/GeneDefOf.cs +++ b/Source/GeneDefOf.cs @@ -73,6 +73,7 @@ namespace RJW_Genes public static readonly GeneDef rjw_genes_fervent_ovipositor; public static readonly GeneDef rjw_genes_insectbreeder; public static readonly GeneDef rjw_genes_insectincubator; + public static readonly GeneDef rjw_genes_hardwired_progenity; // Cum public static readonly GeneDef rjw_genes_no_cum; diff --git a/Source/Genes/Breeding/ConditionalStatAffecters/ConditionalStatAffecter_ManyChildren.cs b/Source/Genes/Breeding/ConditionalStatAffecters/ConditionalStatAffecter_ManyChildren.cs new file mode 100644 index 0000000..3743889 --- /dev/null +++ b/Source/Genes/Breeding/ConditionalStatAffecters/ConditionalStatAffecter_ManyChildren.cs @@ -0,0 +1,34 @@ +using RimWorld; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Verse; + +namespace RJW_Genes +{ + public class ConditionalStatAffecter_ManyChildren : ConditionalStatAffecter + { + public override string Label => (string)"StatsReport_ManyChildren".Translate(); + + public const int THRESHOLD_FOR_CHILDREN = 3; + + public override bool Applies(StatRequest req) + { + if (req == null || req.Thing == null || !req.Thing.Spawned) return false; + + if (req.Thing is Pawn pawn) + { + if (GeneUtility.HasGeneNullCheck(pawn, GeneDefOf.rjw_genes_hardwired_progenity)) + { + // This "middle" Conditional Stat Affecter only fires if the other one does not apply + return pawn.relations.ChildrenCount >= THRESHOLD_FOR_CHILDREN + && pawn.relations.ChildrenCount < ConditionalStatAffecter_VeryManyChildren.THRESHOLD_FOR_CHILDREN; + } + } + + return false; + } + } +} diff --git a/Source/Genes/Breeding/ConditionalStatAffecters/ConditionalStatAffecter_NoChildren.cs b/Source/Genes/Breeding/ConditionalStatAffecters/ConditionalStatAffecter_NoChildren.cs new file mode 100644 index 0000000..eb63ff1 --- /dev/null +++ b/Source/Genes/Breeding/ConditionalStatAffecters/ConditionalStatAffecter_NoChildren.cs @@ -0,0 +1,39 @@ +using RimWorld; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Verse; + +namespace RJW_Genes +{ + /// + /// This conditional stat affecter "fires" if the pawn has no children. + /// + /// DevNote: I salvaged this from 1.3.3 Halamyr Conditional Stat Affecters. + /// It seems that with RW 1.5 there was a change how these work, as the req.Pawn seems to be null. + /// Now, the pawn is in req.Thing. + /// + public class ConditionalStatAffecter_NoChildren : ConditionalStatAffecter + { + public override string Label => (string)"StatsReport_NoChildren".Translate(); + + public override bool Applies(StatRequest req) + { + if (req == null || req.Thing == null || !req.Thing.Spawned) return false; + + if (req.Thing is Pawn pawn) + { + if (GeneUtility.HasGeneNullCheck(pawn, GeneDefOf.rjw_genes_hardwired_progenity)) + { + return pawn.relations.ChildrenCount == 0; + } + } + + return false; + } + + } + +} diff --git a/Source/Genes/Breeding/ConditionalStatAffecters/ConditionalStatAffecter_VeryManyChildren.cs b/Source/Genes/Breeding/ConditionalStatAffecters/ConditionalStatAffecter_VeryManyChildren.cs new file mode 100644 index 0000000..aea272b --- /dev/null +++ b/Source/Genes/Breeding/ConditionalStatAffecters/ConditionalStatAffecter_VeryManyChildren.cs @@ -0,0 +1,32 @@ +using RimWorld; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Verse; + +namespace RJW_Genes +{ + public class ConditionalStatAffecter_VeryManyChildren : ConditionalStatAffecter + { + public override string Label => (string)"StatsReport_VeryManyChildren".Translate(); + + public const int THRESHOLD_FOR_CHILDREN = 8; + + public override bool Applies(StatRequest req) + { + if (req == null || req.Thing == null || !req.Thing.Spawned) return false; + + if (req.Thing is Pawn pawn) + { + if (GeneUtility.HasGeneNullCheck(pawn, GeneDefOf.rjw_genes_hardwired_progenity)) + { + return pawn.relations.ChildrenCount >= THRESHOLD_FOR_CHILDREN; + } + } + + return false; + } + } +} diff --git a/Source/Rjw-Genes.csproj b/Source/Rjw-Genes.csproj index f42e885..728b22f 100644 --- a/Source/Rjw-Genes.csproj +++ b/Source/Rjw-Genes.csproj @@ -71,6 +71,9 @@ + + +