diff --git a/.LICENSE.txt.swp b/.LICENSE.txt.swp new file mode 100644 index 0000000..02c6893 Binary files /dev/null and b/.LICENSE.txt.swp differ diff --git a/Common/Assemblies/Rjw-Genes.dll b/Common/Assemblies/Rjw-Genes.dll index b5b908f..6446c8d 100644 Binary files a/Common/Assemblies/Rjw-Genes.dll and b/Common/Assemblies/Rjw-Genes.dll differ diff --git a/Common/Defs/Genes/GeneDefs_ExtraGenitaliaEndogenes.xml b/Common/Defs/Genes/GeneDefs_ExtraGenitaliaEndogenes.xml new file mode 100644 index 0000000..4adc957 --- /dev/null +++ b/Common/Defs/Genes/GeneDefs_ExtraGenitaliaEndogenes.xml @@ -0,0 +1,40 @@ + + + + rjw_genes_genitalia + + + + + + rjw_genes_extra_penis + + Males of this species grow an additional penis . + Genes/Icons/Placeholder + RJW_Genes.Gene_ExtraPenis + 15 + +
  • PenisAmount
  • +
    +
    + + + + rjw_genes_no_penis + + Males of this do not have a penis. + Genes/Icons/Placeholder + RJW_Genes.Gene_NoPenis + 16 + +
  • PenisAmount
  • +
    +
    + +
    \ No newline at end of file diff --git a/Common/Defs/Genes/GeneDefs_GenitaliaEndogenes.xml b/Common/Defs/Genes/GeneDefs_GenitaliaTypeEndogenes.xml similarity index 99% rename from Common/Defs/Genes/GeneDefs_GenitaliaEndogenes.xml rename to Common/Defs/Genes/GeneDefs_GenitaliaTypeEndogenes.xml index c4f40d0..ff90a9f 100644 --- a/Common/Defs/Genes/GeneDefs_GenitaliaEndogenes.xml +++ b/Common/Defs/Genes/GeneDefs_GenitaliaTypeEndogenes.xml @@ -6,8 +6,8 @@
  • GenitalType
  • - diff --git a/Common/Patches/Xenotypes/GenitaliaUpdate.xml b/Common/Patches/Xenotypes/GenitaliaUpdate.xml index aa225d6..3d98b1a 100644 --- a/Common/Patches/Xenotypes/GenitaliaUpdate.xml +++ b/Common/Patches/Xenotypes/GenitaliaUpdate.xml @@ -101,6 +101,18 @@ + + + Always + +
  • + Defs/XenotypeDef[defName="Genie"]/genes + +
  • rjw_genes_human_genitalia
  • + + +
    +
    @@ -128,18 +140,6 @@ - - Always - -
  • - Defs/XenotypeDef[defName="Genie"]/genes - -
  • rjw_genes_slime_genitalia
  • - - -
    -
    - Always diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..6384532 --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,9 @@ +Copyright 2022 Vegapnk + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + diff --git a/Source/GeneDefOf.cs b/Source/GeneDefOf.cs index 0758245..caa43fa 100644 --- a/Source/GeneDefOf.cs +++ b/Source/GeneDefOf.cs @@ -8,6 +8,7 @@ namespace RJW_Genes { [MayRequireBiotech] public static readonly GeneCategoryDef rjw_genes_genitalia; + // Base Genitalia Types [MayRequireBiotech] public static readonly GeneDef rjw_genes_human_genitalia; [MayRequireBiotech] public static readonly GeneDef rjw_genes_equine_genitalia; [MayRequireBiotech] public static readonly GeneDef rjw_genes_demonic_genitalia; @@ -16,5 +17,9 @@ namespace RJW_Genes [MayRequireBiotech] public static readonly GeneDef rjw_genes_ovipositor_genitalia; [MayRequireBiotech] public static readonly GeneDef rjw_genes_feline_genitalia; [MayRequireBiotech] public static readonly GeneDef rjw_genes_canine_genitalia; + + // Extra Genitalia + [MayRequireBiotech] public static readonly GeneDef rjw_genes_extra_penis; + [MayRequireBiotech] public static readonly GeneDef rjw_genes_no_penis; } } diff --git a/Source/GeneDefs_GenitaliaTypeEndogenes.xml b/Source/GeneDefs_GenitaliaTypeEndogenes.xml new file mode 100644 index 0000000..ff90a9f --- /dev/null +++ b/Source/GeneDefs_GenitaliaTypeEndogenes.xml @@ -0,0 +1,87 @@ + + + + + rjw_genes_genitalia + +
  • GenitalType
  • +
    + 0 + +
    + + + rjw_genes_human_genitalia + + Carriers of this carry genitalia similar to humans. + Genes/Icons/Placeholder + RJW_Genes.Gene_HumanGenitalia + 1 + + + + rjw_genes_equine_genitalia + + Carriers of this gene develop equine genitalia. + Genes/Icons/Placeholder + RJW_Genes.Gene_EquineGenitalia + 2 + + + + rjw_genes_canine_genitalia + + Carriers of this gene develop canine genitalia. + Genes/Icons/Placeholder + RJW_Genes.Gene_CanineGenitalia + 3 + + + + rjw_genes_feline_genitalia + + Carriers of this gene develop feline genitalia. + Genes/Icons/Placeholder + RJW_Genes.Gene_FelineGenitalia + 4 + + + + rjw_genes_demonic_genitalia + + Carriers of this gene have demonic genitalia. + Genes/Icons/Placeholder + RJW_Genes.Gene_DemonicGenitalia + 5 + + + + rjw_genes_dragon_genitalia + + Carriers of this gene develop dragon genitalia. + Genes/Icons/Placeholder + RJW_Genes.Gene_DragonGenitalia + 6 + + + + rjw_genes_slime_genitalia + + Carriers of this gene have slime genitalia. + Genes/Icons/Placeholder + RJW_Genes.Gene_SlimeGenitalia + 7 + + + + rjw_genes_ovipositor_genitalia + + Carriers of this gene have ovipositors similar to insects. + Genes/Icons/Placeholder + RJW_Genes.Gene_OvipositorGenitalia + 8 + + +
    \ No newline at end of file diff --git a/Source/Genes/ExtraGenitalia/Gene_ExtraPenis.cs b/Source/Genes/ExtraGenitalia/Gene_ExtraPenis.cs new file mode 100644 index 0000000..b01e626 --- /dev/null +++ b/Source/Genes/ExtraGenitalia/Gene_ExtraPenis.cs @@ -0,0 +1,61 @@ +using Verse; +using rjw; +using RimWorld; + +namespace RJW_Genes +{ + public class Gene_ExtraPenis : Gene + { + + internal Hediff additional_penis; + + public override void PostMake() + { + base.PostMake(); + if (GenitaliaUtility.PawnStillNeedsGenitalia(pawn)) + Sexualizer.sexualize_pawn(pawn); + + // Penis are only added for male pawns! + if (pawn.gender == Gender.Male && additional_penis == null) + { + createAndAddPenis(); + } + } + + public override void PostAdd() + { + base.PostAdd(); + + // Penis are only added for male pawns! + if (pawn.gender == Gender.Male && additional_penis == null) + { + createAndAddPenis(); + } + } + + public override void PostRemove() + { + base.PostRemove(); + if(additional_penis != null) + pawn.health.RemoveHediff(additional_penis); + } + + internal void createAndAddPenis() + { + var correctGene = GenitaliaUtility.GetGenitaliaTypeGeneForPawn(pawn); + var penisDef = GenitaliaUtility.GetPenisForGene(correctGene); + var partBPR = Genital_Helper.get_genitalsBPR(pawn); + additional_penis = HediffMaker.MakeHediff(penisDef, pawn); + + var CompHediff = additional_penis.TryGetComp(); + if (CompHediff != null) + { + CompHediff.initComp(pawn); + CompHediff.updatesize(); + } + + pawn.health.AddHediff(additional_penis, partBPR); + } + + } +} diff --git a/Source/Genes/ExtraGenitalia/Gene_NoPenis.cs b/Source/Genes/ExtraGenitalia/Gene_NoPenis.cs new file mode 100644 index 0000000..8c88452 --- /dev/null +++ b/Source/Genes/ExtraGenitalia/Gene_NoPenis.cs @@ -0,0 +1,58 @@ +using Verse; +using rjw; +using RimWorld; + +namespace RJW_Genes +{ + public class Gene_NoPenis : Gene + { + + internal Hediff removed_penis; + + // TODO: This gene only works if another Gene was set specifying the genitalia. + // If it is added later, it still works, but on creation it needs a different + public override void PostMake() + { + base.PostMake(); + if (GenitaliaUtility.PawnStillNeedsGenitalia(pawn)) + Sexualizer.sexualize_pawn(pawn); + + // Penis are only added for male pawns! + if (pawn.gender == Gender.Male && removed_penis == null) + { + RemoveButStorePenis(); + } + } + + public override void PostAdd() + { + base.PostAdd(); + + // Penis are only added for male pawns! + if (pawn.gender == Gender.Male && removed_penis == null) + { + RemoveButStorePenis(); + } + } + + public override void PostRemove() + { + base.PostRemove(); + if(removed_penis != null) + pawn.health.AddHediff(removed_penis); + } + + internal void RemoveButStorePenis() + { + var partBPR = Genital_Helper.get_genitalsBPR(pawn); + Hediff penisToRemove = Genital_Helper.get_AllPartsHediffList(pawn).FindLast(x => Genital_Helper.is_penis(x)); + + if(penisToRemove != null) + { + removed_penis = penisToRemove; + pawn.health.RemoveHediff(penisToRemove); + } + } + + } +} diff --git a/Source/Genes/Genitalia/Gene_CanineGenitalia.cs b/Source/Genes/Genitalia/Gene_CanineGenitalia.cs index 5a9389d..1d37041 100644 --- a/Source/Genes/Genitalia/Gene_CanineGenitalia.cs +++ b/Source/Genes/Genitalia/Gene_CanineGenitalia.cs @@ -8,14 +8,16 @@ namespace RJW_Genes public override void PostMake() { base.PostMake(); - Sexualizer.sexualize_pawn(pawn); - GenitaliaChanger.changeGenitalia(this.pawn,Genital_Helper.canine_penis,Genital_Helper.canine_vagina,Genital_Helper.generic_anus); + if (GenitaliaUtility.PawnStillNeedsGenitalia(pawn)) + Sexualizer.sexualize_pawn(pawn); + + GenitaliaChanger.ChangeGenitalia(this.pawn,Genital_Helper.canine_penis,Genital_Helper.canine_vagina,Genital_Helper.generic_anus); } public override void PostAdd() { base.PostMake(); - GenitaliaChanger.changeGenitalia(this.pawn, Genital_Helper.canine_penis, Genital_Helper.canine_vagina, Genital_Helper.generic_anus); + GenitaliaChanger.ChangeGenitalia(this.pawn, Genital_Helper.canine_penis, Genital_Helper.canine_vagina, Genital_Helper.generic_anus); } } diff --git a/Source/Genes/Genitalia/Gene_DemonicGenitalia.cs b/Source/Genes/Genitalia/Gene_DemonicGenitalia.cs index 2f1b3a9..5d33f84 100644 --- a/Source/Genes/Genitalia/Gene_DemonicGenitalia.cs +++ b/Source/Genes/Genitalia/Gene_DemonicGenitalia.cs @@ -9,14 +9,16 @@ namespace RJW_Genes public override void PostMake() { base.PostMake(); - Sexualizer.sexualize_pawn(pawn); - GenitaliaChanger.changeGenitalia(this.pawn,Genital_Helper.demon_penis,Genital_Helper.demon_vagina,Genital_Helper.demon_anus); + if (GenitaliaUtility.PawnStillNeedsGenitalia(pawn)) + Sexualizer.sexualize_pawn(pawn); + + GenitaliaChanger.ChangeGenitalia(this.pawn,Genital_Helper.demon_penis,Genital_Helper.demon_vagina,Genital_Helper.demon_anus); } public override void PostAdd() { base.PostMake(); - GenitaliaChanger.changeGenitalia(this.pawn, Genital_Helper.demon_penis, Genital_Helper.demon_vagina, Genital_Helper.demon_anus); + GenitaliaChanger.ChangeGenitalia(this.pawn, Genital_Helper.demon_penis, Genital_Helper.demon_vagina, Genital_Helper.demon_anus); } } diff --git a/Source/Genes/Genitalia/Gene_DragonGenitalia.cs b/Source/Genes/Genitalia/Gene_DragonGenitalia.cs index 05f3aaf..4e44954 100644 --- a/Source/Genes/Genitalia/Gene_DragonGenitalia.cs +++ b/Source/Genes/Genitalia/Gene_DragonGenitalia.cs @@ -8,14 +8,16 @@ namespace RJW_Genes public override void PostMake() { base.PostMake(); - Sexualizer.sexualize_pawn(pawn); - GenitaliaChanger.changeGenitalia(this.pawn,Genital_Helper.dragon_penis,Genital_Helper.dragon_vagina,Genital_Helper.generic_anus); + if (GenitaliaUtility.PawnStillNeedsGenitalia(pawn)) + Sexualizer.sexualize_pawn(pawn); + + GenitaliaChanger.ChangeGenitalia(this.pawn,Genital_Helper.dragon_penis,Genital_Helper.dragon_vagina,Genital_Helper.generic_anus); } public override void PostAdd() { base.PostMake(); - GenitaliaChanger.changeGenitalia(this.pawn, Genital_Helper.dragon_penis, Genital_Helper.dragon_vagina, Genital_Helper.generic_anus); + GenitaliaChanger.ChangeGenitalia(this.pawn, Genital_Helper.dragon_penis, Genital_Helper.dragon_vagina, Genital_Helper.generic_anus); } } diff --git a/Source/Genes/Genitalia/Gene_EquineGenitalia.cs b/Source/Genes/Genitalia/Gene_EquineGenitalia.cs index 03aa029..47eb65a 100644 --- a/Source/Genes/Genitalia/Gene_EquineGenitalia.cs +++ b/Source/Genes/Genitalia/Gene_EquineGenitalia.cs @@ -8,14 +8,16 @@ namespace RJW_Genes public override void PostMake() { base.PostMake(); - Sexualizer.sexualize_pawn(pawn); - GenitaliaChanger.changeGenitalia(this.pawn,Genital_Helper.equine_penis,Genital_Helper.equine_vagina,Genital_Helper.generic_anus); + if (GenitaliaUtility.PawnStillNeedsGenitalia(pawn)) + Sexualizer.sexualize_pawn(pawn); + + GenitaliaChanger.ChangeGenitalia(this.pawn,Genital_Helper.equine_penis,Genital_Helper.equine_vagina,Genital_Helper.generic_anus); } public override void PostAdd() { base.PostMake(); - GenitaliaChanger.changeGenitalia(this.pawn, Genital_Helper.equine_penis, Genital_Helper.equine_vagina, Genital_Helper.generic_anus); + GenitaliaChanger.ChangeGenitalia(this.pawn, Genital_Helper.equine_penis, Genital_Helper.equine_vagina, Genital_Helper.generic_anus); } } diff --git a/Source/Genes/Genitalia/Gene_FelineGenitalia.cs b/Source/Genes/Genitalia/Gene_FelineGenitalia.cs index 910951d..506437c 100644 --- a/Source/Genes/Genitalia/Gene_FelineGenitalia.cs +++ b/Source/Genes/Genitalia/Gene_FelineGenitalia.cs @@ -8,14 +8,16 @@ namespace RJW_Genes public override void PostMake() { base.PostMake(); - Sexualizer.sexualize_pawn(pawn); - GenitaliaChanger.changeGenitalia(this.pawn,Genital_Helper.feline_penis,Genital_Helper.feline_vagina,Genital_Helper.generic_anus); + if (GenitaliaUtility.PawnStillNeedsGenitalia(pawn)) + Sexualizer.sexualize_pawn(pawn); + + GenitaliaChanger.ChangeGenitalia(this.pawn,Genital_Helper.feline_penis,Genital_Helper.feline_vagina,Genital_Helper.generic_anus); } public override void PostAdd() { base.PostMake(); - GenitaliaChanger.changeGenitalia(this.pawn, Genital_Helper.feline_penis, Genital_Helper.feline_vagina, Genital_Helper.generic_anus); + GenitaliaChanger.ChangeGenitalia(this.pawn, Genital_Helper.feline_penis, Genital_Helper.feline_vagina, Genital_Helper.generic_anus); } } diff --git a/Source/Genes/Genitalia/Gene_HumanGenitalia.cs b/Source/Genes/Genitalia/Gene_HumanGenitalia.cs index 389bf0a..cd9ee11 100644 --- a/Source/Genes/Genitalia/Gene_HumanGenitalia.cs +++ b/Source/Genes/Genitalia/Gene_HumanGenitalia.cs @@ -8,14 +8,16 @@ namespace RJW_Genes public override void PostMake() { base.PostMake(); - Sexualizer.sexualize_pawn(pawn); - GenitaliaChanger.changeGenitalia(this.pawn,Genital_Helper.average_penis,Genital_Helper.average_vagina,Genital_Helper.average_anus); + if (GenitaliaUtility.PawnStillNeedsGenitalia(pawn)) + Sexualizer.sexualize_pawn(pawn); + + GenitaliaChanger.ChangeGenitalia(this.pawn,Genital_Helper.average_penis,Genital_Helper.average_vagina,Genital_Helper.average_anus); } public override void PostAdd() { base.PostAdd(); - GenitaliaChanger.changeGenitalia(this.pawn, Genital_Helper.average_penis, Genital_Helper.average_vagina, Genital_Helper.average_anus); + GenitaliaChanger.ChangeGenitalia(this.pawn, Genital_Helper.average_penis, Genital_Helper.average_vagina, Genital_Helper.average_anus); } } diff --git a/Source/Genes/Genitalia/Gene_OvipositorGenitalia.cs b/Source/Genes/Genitalia/Gene_OvipositorGenitalia.cs index 2594737..3cab5d9 100644 --- a/Source/Genes/Genitalia/Gene_OvipositorGenitalia.cs +++ b/Source/Genes/Genitalia/Gene_OvipositorGenitalia.cs @@ -8,14 +8,16 @@ namespace RJW_Genes public override void PostMake() { base.PostMake(); - Sexualizer.sexualize_pawn(pawn); - GenitaliaChanger.changeGenitalia(this.pawn,Genital_Helper.ovipositorM,Genital_Helper.ovipositorF,Genital_Helper.insect_anus); + if (GenitaliaUtility.PawnStillNeedsGenitalia(pawn)) + Sexualizer.sexualize_pawn(pawn); + + GenitaliaChanger.ChangeGenitalia(this.pawn,Genital_Helper.ovipositorM,Genital_Helper.ovipositorF,Genital_Helper.insect_anus); } public override void PostAdd() { base.PostMake(); - GenitaliaChanger.changeGenitalia(this.pawn, Genital_Helper.ovipositorM, Genital_Helper.ovipositorF, Genital_Helper.insect_anus); + GenitaliaChanger.ChangeGenitalia(this.pawn, Genital_Helper.ovipositorM, Genital_Helper.ovipositorF, Genital_Helper.insect_anus); } } diff --git a/Source/Genes/Genitalia/Gene_SlimeGenitalia.cs b/Source/Genes/Genitalia/Gene_SlimeGenitalia.cs index 31b8556..9837271 100644 --- a/Source/Genes/Genitalia/Gene_SlimeGenitalia.cs +++ b/Source/Genes/Genitalia/Gene_SlimeGenitalia.cs @@ -8,14 +8,16 @@ namespace RJW_Genes public override void PostMake() { base.PostMake(); - Sexualizer.sexualize_pawn(pawn); - GenitaliaChanger.changeGenitalia(this.pawn,Genital_Helper.slime_penis,Genital_Helper.slime_vagina,Genital_Helper.slime_anus); + if (GenitaliaUtility.PawnStillNeedsGenitalia(pawn)) + Sexualizer.sexualize_pawn(pawn); + + GenitaliaChanger.ChangeGenitalia(this.pawn,Genital_Helper.slime_penis,Genital_Helper.slime_vagina,Genital_Helper.slime_anus); } public override void PostAdd() { base.PostMake(); - GenitaliaChanger.changeGenitalia(this.pawn, Genital_Helper.slime_penis, Genital_Helper.slime_vagina, Genital_Helper.slime_anus); + GenitaliaChanger.ChangeGenitalia(this.pawn, Genital_Helper.slime_penis, Genital_Helper.slime_vagina, Genital_Helper.slime_anus); } } diff --git a/Source/Genes/Genitalia/GenitaliaChanger.cs b/Source/Genes/Genitalia/GenitaliaChanger.cs index 6a3f02f..047beab 100644 --- a/Source/Genes/Genitalia/GenitaliaChanger.cs +++ b/Source/Genes/Genitalia/GenitaliaChanger.cs @@ -11,16 +11,15 @@ namespace RJW_Genes /// /// This method changes the pawns genitalia to the given types of genitalia. /// All genitals will be changed, e.g. pawns with 2 penises (for whatever reason) or is a futa, all genitals will be changed. - /// Anuses are currently not changed, due to a small bug. /// /// the pawn who's genitals will be changed /// the new type of penis /// the new type of vagina - /// the new type of anus (currently disabled) - public static void changeGenitalia(Pawn pawn, HediffDef penisReplacement, HediffDef vaginaReplacement, HediffDef anusReplacement) + /// the new type of anus + public static void ChangeGenitalia(Pawn pawn, HediffDef penisReplacement, HediffDef vaginaReplacement, HediffDef anusReplacement) { - var oldParts = Genital_Helper.get_AllPartsHediffList(pawn); - var partBPR = Genital_Helper.get_genitalsBPR(pawn); + var oldParts = Genital_Helper.get_AllPartsHediffList(pawn); + BodyPartRecord correctBPR; if (!oldParts.NullOrEmpty()) { @@ -31,16 +30,21 @@ namespace RJW_Genes { if (IsArtificial(existingGenital)) continue; + correctBPR = Genital_Helper.get_genitalsBPR(pawn); replacementGenital = null; CompHediff = null; - if (IsPenis(existingGenital)) - replacementGenital = HediffMaker.MakeHediff(penisReplacement, pawn, partBPR); + if (Genital_Helper.is_penis(existingGenital)) + replacementGenital = HediffMaker.MakeHediff(penisReplacement, pawn, correctBPR); - if (IsVagina(existingGenital)) - replacementGenital = HediffMaker.MakeHediff(vaginaReplacement, pawn, partBPR); + if (Genital_Helper.is_vagina(existingGenital)) + replacementGenital = HediffMaker.MakeHediff(vaginaReplacement, pawn, correctBPR); - //TODO: Adding Anus in this way had an issue by multiplying Anusses. At the moment Anus are not covered. + if (IsAnus(existingGenital)) + { + correctBPR = Genital_Helper.get_anusBPR(pawn); + replacementGenital = HediffMaker.MakeHediff(anusReplacement, pawn, correctBPR); + } if (replacementGenital != null) { @@ -53,7 +57,7 @@ namespace RJW_Genes GenderHelper.ChangeSex(pawn, () => { pawn.health.RemoveHediff(existingGenital); - pawn.health.AddHediff(replacementGenital, partBPR); + pawn.health.AddHediff(replacementGenital, correctBPR); }); } } @@ -66,21 +70,6 @@ namespace RJW_Genes } - private static bool IsPenis(Hediff candidate) - { - return - candidate.def.defName.ToLower().Contains("penis") || - candidate.def.defName.ToLower().Contains("ovipositorm") || - candidate.def.defName.ToLower().Contains("tentacle"); - } - - private static bool IsVagina(Hediff candidate) - { - return - candidate.def.defName.ToLower().Contains("vagina") || - candidate.def.defName.ToLower().Contains("ovipositorf"); - } - private static bool IsAnus(Hediff candidate) { return candidate.def.defName.ToLower().Contains("anus"); } diff --git a/Source/GenitaliaUtility.cs b/Source/GenitaliaUtility.cs new file mode 100644 index 0000000..97785dc --- /dev/null +++ b/Source/GenitaliaUtility.cs @@ -0,0 +1,93 @@ +using RimWorld; +using Verse; +using rjw; + +namespace RJW_Genes +{ + public class GenitaliaUtility + { + + /// + /// Returns the first (non) overwritten gene from the rjw_genes genitalia genes. + /// In case the pawn has none, as default the human one is returned. + /// + /// the pawn whom to find genitaliagenes for + /// The first GeneDef of the pawn related to GenitaliaTypes + public static GeneDef GetGenitaliaTypeGeneForPawn(Pawn pawn) + { + + foreach (var gene in pawn.genes.GenesListForReading) + { + if (gene.def.defName.Contains("rjw_genes") && gene.def.defName.EndsWith("_genitalia")) + if (!gene.Overridden) + return gene.def; + } + + return GeneDefOf.rjw_genes_human_genitalia; + } + + /// + /// Adds a genital created from a given Def to the pawn. + /// Does not alter/touch gender. + /// + /// The pawn whom to add the genital to, + /// The type of genital to be added + public static void AddGenitalToPawn(Pawn pawn,HediffDef genitalToAdd) + { + if (pawn == null || genitalToAdd == null) + return; + + var partBPR = Genital_Helper.get_genitalsBPR(pawn); + var additionalGenital = HediffMaker.MakeHediff(genitalToAdd, pawn); + + var CompHediff = additionalGenital.TryGetComp(); + if (CompHediff != null) + { + CompHediff.initComp(pawn); + CompHediff.updatesize(); + } + + pawn.health.AddHediff(additionalGenital, partBPR); + } + + + public static HediffDef GetPenisForGene(GeneDef gene) + { + switch (gene.defName) + { + case "rjw_genes_human_genitalia": return Genital_Helper.average_penis; + case "rjw_genes_equine_genitalia": return Genital_Helper.equine_penis; + case "rjw_genes_canine_genitalia": return Genital_Helper.canine_penis; + case "rjw_genes_feline_genitalia": return Genital_Helper.feline_penis; + case "rjw_genes_demonic_genitalia": return Genital_Helper.demon_penis; + case "rjw_genes_dragon_genitalia": return Genital_Helper.dragon_penis; + case "rjw_genes_slime_genitalia": return Genital_Helper.slime_penis; + case "rjw_genes_ovipositor_genitalia": return Genital_Helper.ovipositorM; + + default: return Genital_Helper.average_penis; + } + } + + + public static bool PawnStillNeedsGenitalia(Pawn pawn) + { + // There is the issue that the genes fire in a pseudo-random order + // Hence it can happen that the pawn still needs genitalia + // I wanted to make a simple lookup, but I think the genes are applied for all humans encountered so it could be huge + // So the heuristic is to check if the pawn has any of the 3 standard genitalia OR has all genes ticked that says "I don't want genitalia". + if (pawn == null) return false; + + bool pawn_has_any_genitalia = + Genital_Helper.has_genitals(pawn) || Genital_Helper.has_anus(pawn) || Genital_Helper.has_breasts(pawn); + + bool pawn_is_not_supposed_to_have_genitalia = + pawn.genes.GenesListForReading.Any(x => x.def.defName == "rjw_genes_no_penis"); + + if (pawn_is_not_supposed_to_have_genitalia) + return false; + else + return !pawn_has_any_genitalia; + + } + } +} diff --git a/Source/Rjw-Genes.csproj b/Source/Rjw-Genes.csproj index 580fb2f..b2a146b 100644 --- a/Source/Rjw-Genes.csproj +++ b/Source/Rjw-Genes.csproj @@ -28,6 +28,7 @@ ..\..\rjw\1.4\Assemblies\RJW.dll + False @@ -40,12 +41,16 @@ False - + + + + + @@ -55,8 +60,12 @@ + + + + \ No newline at end of file