2022-12-25 11:38:05 +00:00
|
|
|
|
using HarmonyLib;
|
|
|
|
|
using rjw;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using Verse;
|
|
|
|
|
using RimWorld;
|
|
|
|
|
|
|
|
|
|
namespace RJW_Genes
|
|
|
|
|
{
|
|
|
|
|
public class Gene_Aphrodisiac_Pheromones : Gene
|
|
|
|
|
{
|
2022-12-27 13:54:47 +00:00
|
|
|
|
|
|
|
|
|
//Summary one every one check for all pawns nearby and in line of sight and add/renew a hediff which increases sexdrive for six hours.
|
2022-12-25 11:38:05 +00:00
|
|
|
|
public override void Tick()
|
|
|
|
|
{
|
|
|
|
|
base.Tick();
|
|
|
|
|
if (this.pawn.IsHashIntervalTick(2500))
|
|
|
|
|
{
|
2023-01-06 11:42:04 +00:00
|
|
|
|
//Only spread pheromones if sexdrive above 1
|
|
|
|
|
float sexfrequency = this.pawn.GetStatValue(StatDef.Named("SexFrequency"));
|
|
|
|
|
if(sexfrequency > 1f)
|
|
|
|
|
{
|
|
|
|
|
foreach (Pawn pawn in this.AffectedPawns(this.pawn.Position, this.pawn.Map))
|
|
|
|
|
{
|
|
|
|
|
this.InduceAphrodisiac(pawn, sexfrequency);
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-12-25 11:38:05 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-06 11:42:04 +00:00
|
|
|
|
//Creatus an IEnumerable of all pawns which are closeby and in lineofsight, self and other pawns with aphrodisiac pheromones gene are skipped.
|
2022-12-25 11:38:05 +00:00
|
|
|
|
private IEnumerable<Pawn> AffectedPawns(IntVec3 pos, Map map)
|
|
|
|
|
{
|
|
|
|
|
foreach (Pawn pawn in map.mapPawns.AllPawns)
|
|
|
|
|
{
|
2023-01-06 11:42:04 +00:00
|
|
|
|
if (this.pawn != null && pawn != this.pawn && pos.DistanceTo(pawn.Position) < 5 && GenSight.LineOfSight(pos, pawn.Position, pawn.Map) && !GeneUtility.HasGeneNullCheck(pawn, GeneDefOf.rjw_genes_aphrodisiac_pheromones))
|
2022-12-25 11:38:05 +00:00
|
|
|
|
{
|
|
|
|
|
yield return pawn;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//IEnumerator<Pawn> enumerator = null;
|
|
|
|
|
yield break;
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-27 13:54:47 +00:00
|
|
|
|
//Applies er renews a hediff which increases sexdrive for 6 hours
|
2023-01-06 11:42:04 +00:00
|
|
|
|
private void InduceAphrodisiac(Pawn pawn, float sexfrequency)
|
2022-12-25 11:38:05 +00:00
|
|
|
|
{
|
|
|
|
|
Hediff hediff = pawn.health.hediffSet.GetFirstHediffOfDef(HediffDefOf.Aphrodisiac_Pheromone);
|
2023-01-06 11:42:04 +00:00
|
|
|
|
|
2022-12-25 11:38:05 +00:00
|
|
|
|
if (hediff != null)
|
|
|
|
|
{
|
|
|
|
|
hediff.Severity = 1f;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2023-01-06 11:42:04 +00:00
|
|
|
|
Hediff aphrodisiac = HediffMaker.MakeHediff(HediffDefOf.Aphrodisiac_Pheromone, pawn);
|
|
|
|
|
foreach (StatModifier stat in aphrodisiac.CurStage.statFactors)
|
|
|
|
|
{
|
|
|
|
|
//Log.Message(pawn.Name.ToString());
|
|
|
|
|
//Log.Message(stat.stat.defName);
|
|
|
|
|
//Log.Message(stat.value.ToString());
|
|
|
|
|
if (stat.stat.defName == "SexFrequency")
|
|
|
|
|
{
|
|
|
|
|
stat.value = ModifySexfrequency(pawn, sexfrequency);
|
|
|
|
|
pawn.health.AddHediff(aphrodisiac);
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-12-25 11:38:05 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2023-01-06 11:42:04 +00:00
|
|
|
|
|
|
|
|
|
//Function to modify aphrodisiac strength, currently has no effect, but it's an easy hook for other modders.
|
|
|
|
|
public float ModifySexfrequency(Pawn pawn, float sexfrequency)
|
|
|
|
|
{
|
|
|
|
|
return sexfrequency;
|
|
|
|
|
}
|
2022-12-25 11:38:05 +00:00
|
|
|
|
}
|
|
|
|
|
}
|