2022-11-26 20:32:32 +00:00
|
|
|
|
using System;
|
2023-01-15 08:18:04 +00:00
|
|
|
|
using System.Collections.Generic;
|
2022-11-26 20:32:32 +00:00
|
|
|
|
using Verse;
|
2022-12-28 12:37:27 +00:00
|
|
|
|
using RimWorld;
|
2022-11-20 19:53:05 +00:00
|
|
|
|
namespace RJW_Genes
|
|
|
|
|
{
|
|
|
|
|
public class GeneUtility
|
|
|
|
|
{
|
2022-12-28 12:37:27 +00:00
|
|
|
|
//Instead of seperate functions this should be simpeler
|
|
|
|
|
public static bool HasGeneNullCheck(Pawn pawn, GeneDef genedef)
|
|
|
|
|
{
|
|
|
|
|
if (pawn.genes == null)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return pawn.genes.HasGene(genedef);
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-08 14:51:07 +00:00
|
|
|
|
//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)
|
2022-12-28 12:37:27 +00:00
|
|
|
|
{
|
2023-01-09 13:14:51 +00:00
|
|
|
|
Pawn_GeneTracker genes = pawn.genes;
|
|
|
|
|
Gene_LifeForce gene_LifeForce = genes.GetFirstGeneOfType<Gene_LifeForce>();
|
2023-01-08 14:51:07 +00:00
|
|
|
|
return gene_LifeForce;
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-09 13:14:51 +00:00
|
|
|
|
public static void OffsetLifeForce(IGeneResourceDrain drain, float offset)
|
|
|
|
|
{
|
|
|
|
|
float old_value = drain.Resource.Value;
|
|
|
|
|
drain.Resource.Value += offset;
|
|
|
|
|
//PostOffSetLifeForce(drain, old_value);
|
2023-01-08 14:51:07 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-01-09 13:14:51 +00:00
|
|
|
|
public static void PostOffSetLifeForce(IGeneResourceDrain drain, float old_value)
|
2023-01-08 14:51:07 +00:00
|
|
|
|
{
|
2023-01-09 13:14:51 +00:00
|
|
|
|
if (old_value > 0.2f && drain.Resource.Value <= 0.2f)
|
2022-12-28 12:37:27 +00:00
|
|
|
|
{
|
2023-01-09 13:14:51 +00:00
|
|
|
|
Pawn pawn = drain.Pawn;
|
2023-01-08 14:51:07 +00:00
|
|
|
|
|
2023-01-09 13:14:51 +00:00
|
|
|
|
//Do things
|
2022-12-28 12:37:27 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-20 19:53:05 +00:00
|
|
|
|
public static bool IsMechbreeder(Pawn pawn)
|
|
|
|
|
{
|
|
|
|
|
if (pawn.genes == null)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return pawn.genes.HasGene(GeneDefOf.rjw_genes_mechbreeder);
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-27 12:48:38 +00:00
|
|
|
|
public static bool HasLifeForce(Pawn pawn)
|
|
|
|
|
{
|
|
|
|
|
if (pawn.genes == null)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return pawn.genes.HasGene(GeneDefOf.rjw_genes_lifeforce);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static bool HasLowLifeForce(Pawn pawn)
|
|
|
|
|
{
|
|
|
|
|
if (HasLifeForce(pawn))
|
|
|
|
|
{
|
|
|
|
|
Gene_LifeForce gene = pawn.genes.GetFirstGeneOfType<Gene_LifeForce>();
|
|
|
|
|
if (gene.Resource.Value < gene.targetValue)
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static bool HasCriticalLifeForce(Pawn pawn)
|
|
|
|
|
{
|
|
|
|
|
if (HasLifeForce(pawn))
|
|
|
|
|
{
|
|
|
|
|
Gene_LifeForce gene = pawn.genes.GetFirstGeneOfType<Gene_LifeForce>();
|
|
|
|
|
if (gene.Resource.Value < gene.MinLevelForAlert)
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-20 19:53:05 +00:00
|
|
|
|
public static bool IsInsectIncubator(Pawn pawn)
|
|
|
|
|
{
|
|
|
|
|
if (pawn.genes == null)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return pawn.genes.HasGene(GeneDefOf.rjw_genes_insectincubator);
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-06 16:08:22 +00:00
|
|
|
|
public static bool IsYouthFountain(Pawn pawn)
|
|
|
|
|
{
|
|
|
|
|
if (pawn.genes == null)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return pawn.genes.HasGene(GeneDefOf.rjw_genes_youth_fountain);
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-07 15:51:34 +00:00
|
|
|
|
public static bool IsAgeDrainer(Pawn pawn)
|
2023-01-06 16:08:22 +00:00
|
|
|
|
{
|
|
|
|
|
if (pawn.genes == null)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return pawn.genes.HasGene(GeneDefOf.rjw_genes_sex_age_drain);
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-26 20:32:32 +00:00
|
|
|
|
public static bool IsInsectBreeder(Pawn pawn)
|
2022-11-20 19:53:05 +00:00
|
|
|
|
{
|
|
|
|
|
if (pawn.genes == null)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return pawn.genes.HasGene(GeneDefOf.rjw_genes_insectbreeder);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static float MaxEggSizeMul(Pawn pawn)
|
|
|
|
|
{
|
|
|
|
|
float MaxEggSize = 1;
|
|
|
|
|
if (IsInsectIncubator(pawn))
|
|
|
|
|
{
|
|
|
|
|
MaxEggSize *= 2;
|
|
|
|
|
}
|
|
|
|
|
return MaxEggSize;
|
|
|
|
|
}
|
2022-11-26 20:32:32 +00:00
|
|
|
|
|
|
|
|
|
internal static bool IsElastic(Pawn pawn)
|
|
|
|
|
{
|
|
|
|
|
if (pawn.genes == null)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return pawn.genes.HasGene(GeneDefOf.rjw_genes_elasticity);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static bool IsCumflationImmune(Pawn pawn)
|
|
|
|
|
{
|
|
|
|
|
if (pawn.genes == null)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return pawn.genes.HasGene(GeneDefOf.rjw_genes_cumflation_immunity);
|
|
|
|
|
}
|
2022-11-27 07:36:44 +00:00
|
|
|
|
public static bool IsGenerousDonor(Pawn pawn)
|
|
|
|
|
{
|
|
|
|
|
if (pawn.genes == null)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return pawn.genes.HasGene(GeneDefOf.rjw_genes_generous_donor);
|
|
|
|
|
}
|
2023-01-06 15:23:13 +00:00
|
|
|
|
|
2022-12-28 09:30:26 +00:00
|
|
|
|
public static bool isPussyHealer(Pawn pawn)
|
|
|
|
|
{
|
|
|
|
|
if (pawn.genes == null)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return pawn.genes.HasGene(GeneDefOf.rjw_genes_pussyhealer);
|
|
|
|
|
}
|
2023-01-08 13:12:58 +00:00
|
|
|
|
|
2023-01-06 15:23:13 +00:00
|
|
|
|
public static bool IsUnbreakable(Pawn pawn)
|
|
|
|
|
{
|
|
|
|
|
if (pawn.genes == null)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return pawn.genes.HasGene(GeneDefOf.rjw_genes_unbreakable);
|
|
|
|
|
}
|
2023-01-15 08:18:04 +00:00
|
|
|
|
|
2023-01-15 08:50:29 +00:00
|
|
|
|
public static List<Gene_GenitaliaResizingGene> GetGenitaliaResizingGenes(Pawn pawn)
|
2023-01-15 08:18:04 +00:00
|
|
|
|
{
|
2023-01-15 08:50:29 +00:00
|
|
|
|
var ResizingGenes = new List<Gene_GenitaliaResizingGene>();
|
2023-01-15 08:18:04 +00:00
|
|
|
|
|
|
|
|
|
// Error Handling: Issue with Pawn or Genes return empty.
|
|
|
|
|
if (pawn == null || pawn.genes == null)
|
|
|
|
|
return ResizingGenes;
|
|
|
|
|
|
2023-01-15 08:50:29 +00:00
|
|
|
|
foreach (Gene gene in pawn.genes.GenesListForReading)
|
|
|
|
|
if (gene is Gene_GenitaliaResizingGene resizing_gene)
|
|
|
|
|
ResizingGenes.Add(resizing_gene);
|
2023-01-15 08:18:04 +00:00
|
|
|
|
|
|
|
|
|
return ResizingGenes;
|
|
|
|
|
}
|
2022-11-20 19:53:05 +00:00
|
|
|
|
}
|
|
|
|
|
}
|