mirror of
				https://github.com/vegapnk/RJW-Genes.git
				synced 2024-08-15 00:23:31 +00:00 
			
		
		
		
	Added an Unbreakable Gene
This commit is contained in:
		
							parent
							
								
									75891ca0b3
								
							
						
					
					
						commit
						8e63e69385
					
				
					 6 changed files with 136 additions and 7 deletions
				
			
		| 
						 | 
				
			
			@ -10,8 +10,6 @@ namespace RJW_Genes
 | 
			
		|||
    /// </summary>
 | 
			
		||||
    public class Gene_Elasticity : Gene
 | 
			
		||||
    {
 | 
			
		||||
        
 | 
			
		||||
        private int ticksToReset = RESET_INTERVAL; 
 | 
			
		||||
        private const int RESET_INTERVAL = 60000; // 60k should be 1 day 
 | 
			
		||||
 | 
			
		||||
        public override void PostAdd()
 | 
			
		||||
| 
						 | 
				
			
			@ -26,11 +24,8 @@ namespace RJW_Genes
 | 
			
		|||
        public override void Tick()
 | 
			
		||||
        {
 | 
			
		||||
            base.Tick();
 | 
			
		||||
            --this.ticksToReset;
 | 
			
		||||
            if (this.ticksToReset > 0)
 | 
			
		||||
                return;
 | 
			
		||||
            this.ticksToReset = RESET_INTERVAL;
 | 
			
		||||
            ResetSeverity();
 | 
			
		||||
            if (pawn.IsHashIntervalTick(RESET_INTERVAL))
 | 
			
		||||
                ResetSeverity();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public override void PostRemove()
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										41
									
								
								Source/Genes/Damage/Gene_Unbreakable.cs
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										41
									
								
								Source/Genes/Damage/Gene_Unbreakable.cs
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,41 @@
 | 
			
		|||
using LicentiaLabs;
 | 
			
		||||
using rjw;
 | 
			
		||||
using Verse;
 | 
			
		||||
 | 
			
		||||
namespace RJW_Genes
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// This Gene regularly removes the broken hediff of a pawn. 
 | 
			
		||||
    /// Blocking / Removing thoughts are done in an XML Patch.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public class Gene_Unbreakable : Gene
 | 
			
		||||
    {
 | 
			
		||||
        /// DevNote: I first tried to Harmony-Postfix the AfterSexUtility and never add it - but that failed? 
 | 
			
		||||
 | 
			
		||||
        private const int RESET_INTERVAL = 30000; // 30k should be 0.5 day 
 | 
			
		||||
        public override void PostAdd()
 | 
			
		||||
        {
 | 
			
		||||
            base.PostAdd();
 | 
			
		||||
            RemoveBrokenHediff();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public override void Tick()
 | 
			
		||||
        {
 | 
			
		||||
            base.Tick();
 | 
			
		||||
            if (pawn.IsHashIntervalTick(RESET_INTERVAL))
 | 
			
		||||
                RemoveBrokenHediff();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        private void RemoveBrokenHediff()
 | 
			
		||||
        {
 | 
			
		||||
            // Clean-Up of existing feeling brokens
 | 
			
		||||
            var maybeBrokenHediff = pawn.health.hediffSet.GetFirstHediffOfDef(xxx.feelingBroken);
 | 
			
		||||
            if (maybeBrokenHediff != null)
 | 
			
		||||
            {
 | 
			
		||||
                pawn.health.RemoveHediff(maybeBrokenHediff);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -67,5 +67,15 @@ namespace RJW_Genes
 | 
			
		|||
            }
 | 
			
		||||
            return pawn.genes.HasGene(GeneDefOf.rjw_genes_generous_donor);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public static bool IsUnbreakable(Pawn pawn)
 | 
			
		||||
        {
 | 
			
		||||
            if (pawn.genes == null)
 | 
			
		||||
            {
 | 
			
		||||
                return false;
 | 
			
		||||
            }
 | 
			
		||||
            return pawn.genes.HasGene(GeneDefOf.rjw_genes_unbreakable);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue