mirror of
				https://github.com/vegapnk/RJW-Genes.git
				synced 2024-08-15 00:23:31 +00:00 
			
		
		
		
	A fertilin alert and some label/description changes
This commit is contained in:
		
							parent
							
								
									6f2c4dc374
								
							
						
					
					
						commit
						2e1e74e0b1
					
				
					 15 changed files with 148 additions and 28 deletions
				
			
		| 
						 | 
				
			
			@ -15,21 +15,31 @@ namespace RJW_Genes
 | 
			
		|||
            return pawn.genes.HasGene(genedef);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public static void OffsetLifeForce(Pawn pawn, float offset, bool applyStatFactor = true)
 | 
			
		||||
        //Split function so I can offsetlifeforce from gene without needing to look for the gene agian (for the constant drain tick)
 | 
			
		||||
        public static Gene_LifeForce GetLifeForceGene(Pawn pawn)
 | 
			
		||||
        {
 | 
			
		||||
            if (!ModsConfig.BiotechActive)
 | 
			
		||||
            {
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
            //if (offset > 0f && applyStatFactor)
 | 
			
		||||
            //{
 | 
			
		||||
            //    offset *= pawn.GetStatValue(StatDefOf.HemogenGainFactor, true, -1);
 | 
			
		||||
            //}
 | 
			
		||||
            Pawn_GeneTracker genes2 = pawn.genes;
 | 
			
		||||
            Gene_LifeForce gene_LifeFroce = (genes2 != null) ? genes2.GetFirstGeneOfType<Gene_LifeForce>() : null;
 | 
			
		||||
            if (gene_LifeFroce != null)
 | 
			
		||||
            Gene_LifeForce gene_LifeForce = (genes2 != null) ? genes2.GetFirstGeneOfType<Gene_LifeForce>() : null;
 | 
			
		||||
            return gene_LifeForce;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public static void OffsetLifeForce(Gene_LifeForce gene_LifeForce, float offset, bool applyStatFactor = true)
 | 
			
		||||
        {
 | 
			
		||||
            if (gene_LifeForce != null)
 | 
			
		||||
            {
 | 
			
		||||
                gene_LifeFroce.Value += offset;
 | 
			
		||||
                float old_value = gene_LifeForce.Value;
 | 
			
		||||
                gene_LifeForce.Value += offset;
 | 
			
		||||
                PostOffSetLifeForce(gene_LifeForce, old_value);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public static void PostOffSetLifeForce(Gene_LifeForce gene_LifeForce, float old_value)
 | 
			
		||||
        {
 | 
			
		||||
            if (old_value > 0.15f && gene_LifeForce.Resource.Value <= 0.15f)
 | 
			
		||||
            {
 | 
			
		||||
                Pawn pawn = gene_LifeForce.Pawn;
 | 
			
		||||
                
 | 
			
		||||
                //Give thoughtdef
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										70
									
								
								Source/Genes/Life_Force/Alert_LowFertilin.cs
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										70
									
								
								Source/Genes/Life_Force/Alert_LowFertilin.cs
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,70 @@
 | 
			
		|||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Text;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
using RimWorld.Planet;
 | 
			
		||||
using Verse;
 | 
			
		||||
using RimWorld;
 | 
			
		||||
namespace RJW_Genes
 | 
			
		||||
{
 | 
			
		||||
    public class Alert_CriticalFertilin : Alert
 | 
			
		||||
    {
 | 
			
		||||
		private List<GlobalTargetInfo> Targets
 | 
			
		||||
		{
 | 
			
		||||
			get
 | 
			
		||||
			{
 | 
			
		||||
				this.CalculateTargets();
 | 
			
		||||
				return this.targets;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		public override string GetLabel()
 | 
			
		||||
		{
 | 
			
		||||
			if (this.Targets.Count == 1)
 | 
			
		||||
			{
 | 
			
		||||
				return "AlertLowFertilin".Translate() + ": " + this.targetLabels[0];
 | 
			
		||||
			}
 | 
			
		||||
			return "AlertLowFertilin".Translate();
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		private void CalculateTargets()
 | 
			
		||||
		{
 | 
			
		||||
			this.targets.Clear();
 | 
			
		||||
			this.targetLabels.Clear();
 | 
			
		||||
			if (!ModsConfig.BiotechActive)
 | 
			
		||||
			{
 | 
			
		||||
				return;
 | 
			
		||||
			}
 | 
			
		||||
			foreach (Pawn pawn in PawnsFinder.AllMapsCaravansAndTravelingTransportPods_Alive)
 | 
			
		||||
			{
 | 
			
		||||
				if (pawn.RaceProps.Humanlike && pawn.Faction == Faction.OfPlayer)
 | 
			
		||||
				{
 | 
			
		||||
					Pawn_GeneTracker genes = pawn.genes;
 | 
			
		||||
					Gene_LifeForce gene_Lifeforce = (genes != null) ? genes.GetFirstGeneOfType<Gene_LifeForce>() : null;
 | 
			
		||||
					if (gene_Lifeforce != null && gene_Lifeforce.Value < gene_Lifeforce.MinLevelForAlert)
 | 
			
		||||
					{
 | 
			
		||||
						this.targets.Add(pawn);
 | 
			
		||||
						this.targetLabels.Add(pawn.NameShortColored.Resolve());
 | 
			
		||||
					}
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		public override TaggedString GetExplanation()
 | 
			
		||||
		{
 | 
			
		||||
			return "AlertLowFertilinDesc".Translate() + ":\n" + this.targetLabels.ToLineList("  - ");
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		public override AlertReport GetReport()
 | 
			
		||||
		{
 | 
			
		||||
			return AlertReport.CulpritsAre(this.Targets);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// Token: 0x04004B5C RID: 19292
 | 
			
		||||
		private List<GlobalTargetInfo> targets = new List<GlobalTargetInfo>();
 | 
			
		||||
 | 
			
		||||
		// Token: 0x04004B5D RID: 19293
 | 
			
		||||
		private List<string> targetLabels = new List<string>();
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -39,7 +39,7 @@ namespace RJW_Genes
 | 
			
		|||
 | 
			
		||||
					if (rjw.Genital_Helper.is_penis(part))
 | 
			
		||||
					{
 | 
			
		||||
						GeneUtility.OffsetLifeForce(this.parent.pawn, part.Severity); ;
 | 
			
		||||
						GeneUtility.OffsetLifeForce(GeneUtility.GetLifeForceGene(this.parent.pawn), part.Severity); ;
 | 
			
		||||
						pawn.health.RemoveHediff(part);
 | 
			
		||||
						pawn.needs.mood.thoughts.memories.TryGainMemory(ThoughtDefOf.rjw_genes_cock_eaten, pawn, null);
 | 
			
		||||
						break; //Only one penis at the time
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -37,7 +37,7 @@ namespace RJW_Genes
 | 
			
		|||
		public override void Apply(LocalTargetInfo target, LocalTargetInfo dest)
 | 
			
		||||
		{
 | 
			
		||||
			base.Apply(target, dest);
 | 
			
		||||
			GeneUtility.OffsetLifeForce(this.parent.pawn, -this.Props.fertilinCost, true);
 | 
			
		||||
			GeneUtility.OffsetLifeForce(GeneUtility.GetLifeForceGene(this.parent.pawn), -this.Props.fertilinCost, true);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// Token: 0x06005D1B RID: 23835 RVA: 0x001FA7E0 File Offset: 0x001F89E0
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -26,8 +26,8 @@ namespace RJW_Genes
 | 
			
		|||
			Pawn pawn2 = this.parent.pawn;
 | 
			
		||||
			if (pawn != null && pawn2 != null && !pawn.Downed)
 | 
			
		||||
			{
 | 
			
		||||
				Job job = JobMaker.MakeJob(JobDefOf.rjw_genes_lifeforce_seduced, pawn2);//ChooseJob(pawn, pawn2);
 | 
			
		||||
				job.mote = MoteMaker.MakeThoughtBubble(pawn, this.parent.def.iconPath, true); //make this image of pawn or else heart
 | 
			
		||||
				Job job = JobMaker.MakeJob(JobDefOf.rjw_genes_lifeforce_seduced, pawn2);
 | 
			
		||||
				job.mote = MoteMaker.MakeThoughtBubble(pawn, this.parent.def.iconPath, true);
 | 
			
		||||
				pawn.jobs.StopAll(false, true);
 | 
			
		||||
				pawn.jobs.StartJob(job, JobCondition.InterruptForced, null, false, true, null, null, false, false, null, false, true);
 | 
			
		||||
			}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -43,7 +43,15 @@ namespace RJW_Genes
 | 
			
		|||
			//base.Tick();
 | 
			
		||||
			if (this.CanOffset && this.Resource != null)
 | 
			
		||||
            {
 | 
			
		||||
				this.Resource.Value -= this.ResourceLossPerDay / 60000;
 | 
			
		||||
				if (this.CanOffset)
 | 
			
		||||
				{
 | 
			
		||||
					if (this.Resource == null)
 | 
			
		||||
					{
 | 
			
		||||
						return;
 | 
			
		||||
					}
 | 
			
		||||
					GeneUtility.OffsetLifeForce(this, -this.ResourceLossPerDay / 60000f);
 | 
			
		||||
				}
 | 
			
		||||
				//this.Resource.Value -= this.ResourceLossPerDay / 60000;
 | 
			
		||||
				if (this.Resource.Value <= 0 && this.pawn.IsHashIntervalTick(300))
 | 
			
		||||
				{
 | 
			
		||||
					if (ModsConfig.BiotechActive && this.def.mentalBreakDef != null && 
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -15,7 +15,7 @@ namespace RJW_Genes
 | 
			
		|||
			if (GeneUtility.HasLifeForce(pawn))
 | 
			
		||||
            {
 | 
			
		||||
				float num = ingested.stackCount * this.FertilinPerUnit / 100;
 | 
			
		||||
				GeneUtility.OffsetLifeForce(pawn, num);
 | 
			
		||||
				GeneUtility.OffsetLifeForce(GeneUtility.GetLifeForceGene(pawn), num);
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		public float FertilinPerUnit = 1f;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -71,7 +71,7 @@ namespace RJW_Genes
 | 
			
		|||
				if (GeneUtility.HasGeneNullCheck(succubus, GeneDefOf.rjw_genes_drainer) && !props.pawn.health.hediffSet.HasHediff(HediffDefOf.Succubus_Drained))
 | 
			
		||||
				{
 | 
			
		||||
					props.pawn.health.AddHediff(HediffDefOf.Succubus_Drained);
 | 
			
		||||
					GeneUtility.OffsetLifeForce(succubus, 0.25f);
 | 
			
		||||
					GeneUtility.OffsetLifeForce(GeneUtility.GetLifeForceGene(succubus), 0.25f);
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
| 
						 | 
				
			
			@ -103,7 +103,7 @@ namespace RJW_Genes
 | 
			
		|||
			}
 | 
			
		||||
			//Currently taking the sum of all penises, maybe I should just consider one at random
 | 
			
		||||
			float valuechange = CumUtility.GetTotalFluidAmount(props.pawn) / 100 * absorb_factor * multiplier;
 | 
			
		||||
			GeneUtility.OffsetLifeForce(props.partner, valuechange);
 | 
			
		||||
			GeneUtility.OffsetLifeForce(GeneUtility.GetLifeForceGene(props.partner), valuechange);
 | 
			
		||||
			//gene.Resource.Value += CumUtility.GetTotalFluidAmount(props.pawn) / 100 * absorb_factor * multiplier;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue