mirror of
				https://github.com/vegapnk/RJW-Genes.git
				synced 2024-08-15 00:23:31 +00:00 
			
		
		
		
	Moved the GenderFluid Logic to be more generic
This commit is contained in:
		
							parent
							
								
									38f2470b90
								
							
						
					
					
						commit
						b56c0105a6
					
				
					 7 changed files with 28 additions and 31 deletions
				
			
		| 
						 | 
				
			
			@ -65,10 +65,10 @@
 | 
			
		|||
        <backgroundPathEndogenes>Genes/Icons/RJW_Genes_Endogene_Background</backgroundPathEndogenes>
 | 
			
		||||
        <backgroundPathXenogenes>Genes/Icons/RJW_Genes_Xenogene_Background</backgroundPathXenogenes>
 | 
			
		||||
      </li>
 | 
			
		||||
      <li Class="RJW_Genes.GenderFluidExtension">
 | 
			
		||||
      <li Class="RJW_Genes.TickBasedChanceExtension">
 | 
			
		||||
        <!-- 120k = 2 days -->
 | 
			
		||||
        <changeInterval>120000</changeInterval>
 | 
			
		||||
        <changeChance>0.25</changeChance>
 | 
			
		||||
        <tickInterval>120000</tickInterval>
 | 
			
		||||
        <eventChance>0.25</eventChance>
 | 
			
		||||
      </li>
 | 
			
		||||
    </modExtensions>
 | 
			
		||||
  </GeneDef>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										18
									
								
								Source/Common/Defs/TickBasedChanceExtension.cs
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								Source/Common/Defs/TickBasedChanceExtension.cs
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,18 @@
 | 
			
		|||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Text;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
using Verse;
 | 
			
		||||
 | 
			
		||||
namespace RJW_Genes
 | 
			
		||||
{
 | 
			
		||||
    public class TickBasedChanceExtension : TickIntervalExtension
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Set to 1 for "always", set to 0 for "never". 
 | 
			
		||||
        /// Everything else is a bit statistics, but e.g. when set to .5 the chances grow per day from [50%, 75%, 82.25%, ...]
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public float eventChance;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,20 +0,0 @@
 | 
			
		|||
using Verse;
 | 
			
		||||
 | 
			
		||||
namespace RJW_Genes
 | 
			
		||||
{
 | 
			
		||||
    public class GenderFluidExtension : DefModExtension
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Number of ticks until the change can be triggered.
 | 
			
		||||
        /// Just being "triggered" does not mean changing, see the changeChance below. 
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public int changeInterval;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// How high is the chance to change gender?
 | 
			
		||||
        /// Set to 1 for "always", set to 0 for "never". 
 | 
			
		||||
        /// Everything else is a bit statistics, but e.g. when set to .5 the chances grow per day from [50%, 75%, 82.25%, ...]
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public float changeChance;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -39,9 +39,9 @@ namespace RJW_Genes
 | 
			
		|||
        private bool sexChangeWasBlocked = false;
 | 
			
		||||
 | 
			
		||||
        public Gene_GenderFluid() : base() {
 | 
			
		||||
            GenderFluidExtension genderFluidExt = GeneDefOf.rjw_genes_gender_fluid.GetModExtension<GenderFluidExtension>();
 | 
			
		||||
            change_interval = genderFluidExt?.changeInterval ?? CHANGE_INTERVAL_FALLBACK;
 | 
			
		||||
            switch_chance = genderFluidExt?.changeChance ?? SWITCH_CHANCE_FALLBACK;
 | 
			
		||||
            TickBasedChanceExtension tickbasedChanceExt = GeneDefOf.rjw_genes_gender_fluid.GetModExtension<TickBasedChanceExtension>();
 | 
			
		||||
            change_interval = tickbasedChanceExt?.tickInterval ?? CHANGE_INTERVAL_FALLBACK;
 | 
			
		||||
            switch_chance = tickbasedChanceExt?.eventChance ?? SWITCH_CHANCE_FALLBACK;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public override void Tick()
 | 
			
		||||
| 
						 | 
				
			
			@ -58,6 +58,7 @@
 | 
			
		|||
    <Compile Include="Animal_Inheritance\Defs\BestialityGeneInheritanceDef.cs" />
 | 
			
		||||
    <Compile Include="Common\Defs\DistanceExtension.cs" />
 | 
			
		||||
    <Compile Include="Common\Defs\ModExtensionHelper.cs" />
 | 
			
		||||
    <Compile Include="Common\Defs\TickBasedChanceExtension.cs" />
 | 
			
		||||
    <Compile Include="Common\Either.cs" />
 | 
			
		||||
    <Compile Include="Common\Helpers\LaborState.cs" />
 | 
			
		||||
    <Compile Include="Common\Helpers\MapUtility.cs" />
 | 
			
		||||
| 
						 | 
				
			
			@ -88,8 +89,7 @@
 | 
			
		|||
    <Compile Include="Genes\Breeding\Patches\PatchMechBirth.cs" />
 | 
			
		||||
    <Compile Include="Genes\ExtraGenitalia\Gene_Femboy.cs" />
 | 
			
		||||
    <Compile Include="Genes\ExtraGenitalia\Gene_UdderBreasts.cs" />
 | 
			
		||||
    <Compile Include="Genes\Gender\Defs\GenderFluidExtension.cs" />
 | 
			
		||||
    <Compile Include="Genes\Gender\Gene_GenderFluid.cs" />
 | 
			
		||||
    <Compile Include="Genes\Gender\Genes\Gene_GenderFluid.cs" />
 | 
			
		||||
    <Compile Include="Genes\GenitaliaSize\Gene_EvergrowingGenitalia.cs" />
 | 
			
		||||
    <Compile Include="Genes\Cum\CumUtility.cs" />
 | 
			
		||||
    <Compile Include="Genes\Cum\Gene_VeryMuchCum.cs" />
 | 
			
		||||
| 
						 | 
				
			
			@ -109,8 +109,8 @@
 | 
			
		|||
    <Compile Include="Genes\ExtraGenitalia\Gene_NoPenis.cs" />
 | 
			
		||||
    <Compile Include="Genes\ExtraGenitalia\Gene_ExtraPenis.cs" />
 | 
			
		||||
    <Compile Include="Genes\Gender\GenderUtility.cs" />
 | 
			
		||||
    <Compile Include="Genes\Gender\Gene_FemaleOnly.cs" />
 | 
			
		||||
    <Compile Include="Genes\Gender\Gene_MaleOnly.cs" />
 | 
			
		||||
    <Compile Include="Genes\Gender\Genes\Gene_FemaleOnly.cs" />
 | 
			
		||||
    <Compile Include="Genes\Gender\Genes\Gene_MaleOnly.cs" />
 | 
			
		||||
    <Compile Include="Genes\GeneUtility.cs" />
 | 
			
		||||
    <Compile Include="Genes\GenitaliaSize\Gene_BigBreasts.cs" />
 | 
			
		||||
    <Compile Include="Genes\GenitaliaSize\Gene_GenitaliaResizingGene.cs" />
 | 
			
		||||
| 
						 | 
				
			
			@ -241,7 +241,6 @@
 | 
			
		|||
  </ItemGroup>
 | 
			
		||||
  <ItemGroup>
 | 
			
		||||
    <Folder Include="Genes\Diseases\Genes\" />
 | 
			
		||||
    <Folder Include="Genes\Gender\Patches\" />
 | 
			
		||||
  </ItemGroup>
 | 
			
		||||
  <ItemGroup>
 | 
			
		||||
    <WCFMetadata Include="Connected Services\" />
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue