mirror of
				https://github.com/vegapnk/RJW-Genes.git
				synced 2024-08-15 00:23:31 +00:00 
			
		
		
		
	Remove hediffs during Pawn Generation
Calls RemoveAllSexChangeThoughts via a notify method that we call after PawnGenerator creates genes
This commit is contained in:
		
							parent
							
								
									8c51c3fa59
								
							
						
					
					
						commit
						55554df7e2
					
				
					 5 changed files with 48 additions and 2 deletions
				
			
		| 
						 | 
					@ -4,7 +4,7 @@ using rjw;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace RJW_Genes
 | 
					namespace RJW_Genes
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    public class Gene_FemaleOnly : Gene
 | 
					    public class Gene_FemaleOnly : RJW_Gene
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        public override void PostMake()
 | 
					        public override void PostMake()
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
| 
						 | 
					@ -24,6 +24,8 @@ namespace RJW_Genes
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        private void AdjustPawnToFemale()
 | 
					        private void AdjustPawnToFemale()
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
 | 
					            Log.Message($"Gene_FemaleOnly AdjustPawnToFemale | {pawn} | {pawn.gender}");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            // Here we really use the Gender.Female and not our helper IsFemale(pawn)
 | 
					            // Here we really use the Gender.Female and not our helper IsFemale(pawn)
 | 
				
			||||||
            if (pawn.gender == Gender.Female)
 | 
					            if (pawn.gender == Gender.Female)
 | 
				
			||||||
                return;
 | 
					                return;
 | 
				
			||||||
| 
						 | 
					@ -38,5 +40,11 @@ namespace RJW_Genes
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public override void Notify_OnPawnGeneration()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            base.Notify_OnPawnGeneration();
 | 
				
			||||||
 | 
					            // If this is Pawn generation, then we can assume that the pawn was never any gender other than female, so they shouldn't have sex change thoughts.
 | 
				
			||||||
 | 
					            GenderUtility.RemoveAllSexChangeThoughts(pawn);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -4,7 +4,7 @@ using rjw;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace RJW_Genes
 | 
					namespace RJW_Genes
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    public class Gene_MaleOnly : Gene
 | 
					    public class Gene_MaleOnly : RJW_Gene
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        public override void PostMake()
 | 
					        public override void PostMake()
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
| 
						 | 
					@ -38,5 +38,11 @@ namespace RJW_Genes
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public override void Notify_OnPawnGeneration()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            base.Notify_OnPawnGeneration();
 | 
				
			||||||
 | 
					            // If this is Pawn generation, then we can assume that the pawn was never any gender other than male, so they shouldn't have sex change thoughts.
 | 
				
			||||||
 | 
					            GenderUtility.RemoveAllSexChangeThoughts(pawn);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										23
									
								
								Source/Genes/Patch_AddNotifyOnGeneration.cs
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								Source/Genes/Patch_AddNotifyOnGeneration.cs
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,23 @@
 | 
				
			||||||
 | 
					using HarmonyLib;
 | 
				
			||||||
 | 
					using System.Linq;
 | 
				
			||||||
 | 
					using Verse;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace RJW_Genes.Genes
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    [HarmonyPatch]
 | 
				
			||||||
 | 
					    public static class Patch_AddNotifyOnGeneration
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        [HarmonyPatch(typeof(PawnGenerator), "GenerateGenes")]
 | 
				
			||||||
 | 
					        [HarmonyPostfix]
 | 
				
			||||||
 | 
					        public static void PawnGenerator_GenerateGenes_Postfix(Pawn pawn)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            if (pawn.genes == null) return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            foreach(var gene in pawn.genes.GenesListForReading)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                if (gene is RJW_Gene rjwGene)
 | 
				
			||||||
 | 
					                    rjwGene.Notify_OnPawnGeneration();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -12,5 +12,13 @@ namespace RJW_Genes
 | 
				
			||||||
            if (GenitaliaUtility.PawnStillNeedsGenitalia(pawn))
 | 
					            if (GenitaliaUtility.PawnStillNeedsGenitalia(pawn))
 | 
				
			||||||
                Sexualizer.sexualize_pawn(pawn);
 | 
					                Sexualizer.sexualize_pawn(pawn);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// Executed via PawnGenerator.GenerateGenes at Pawn generation
 | 
				
			||||||
 | 
					        /// Allows for execution of code that should only happen during PawnGeneration
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        public virtual void Notify_OnPawnGeneration()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -131,6 +131,7 @@
 | 
				
			||||||
    <Compile Include="Genes\Life_Force\ThinkNodes\ThinkNode_ConditionalCritcalLifeForce.cs" />
 | 
					    <Compile Include="Genes\Life_Force\ThinkNodes\ThinkNode_ConditionalCritcalLifeForce.cs" />
 | 
				
			||||||
    <Compile Include="Genes\Life_Force\JobGivers\JobGiver_GetLifeForce.cs" />
 | 
					    <Compile Include="Genes\Life_Force\JobGivers\JobGiver_GetLifeForce.cs" />
 | 
				
			||||||
    <Compile Include="Genes\Life_Force\ThinkNodes\ThinkNode_NewFlirtTarget.cs" />
 | 
					    <Compile Include="Genes\Life_Force\ThinkNodes\ThinkNode_NewFlirtTarget.cs" />
 | 
				
			||||||
 | 
					    <Compile Include="Genes\Patch_AddNotifyOnGeneration.cs" />
 | 
				
			||||||
    <Compile Include="Genes\Special\Patch_AgeDrain.cs" />
 | 
					    <Compile Include="Genes\Special\Patch_AgeDrain.cs" />
 | 
				
			||||||
    <Compile Include="Interactions\SuccubusTailjob\CompAbility_SexInteractionRequirements.cs" />
 | 
					    <Compile Include="Interactions\SuccubusTailjob\CompAbility_SexInteractionRequirements.cs" />
 | 
				
			||||||
    <Compile Include="Genes\Life_Force\Abilities\CompAbilityEffect_PussyHeal.cs" />
 | 
					    <Compile Include="Genes\Life_Force\Abilities\CompAbilityEffect_PussyHeal.cs" />
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue