diff --git a/Common/Defs/GeneDefs/GeneDefs_LifeForce.xml b/Common/Defs/GeneDefs/GeneDefs_LifeForce.xml
index 67f0994..720a236 100644
--- a/Common/Defs/GeneDefs/GeneDefs_LifeForce.xml
+++ b/Common/Defs/GeneDefs/GeneDefs_LifeForce.xml
@@ -201,7 +201,7 @@
Carriers of this gene are able to temporarily increase their strength and resilience, while they are naked.
Genes/Icons/rjw_naked_prowess
rjw_genes_lifeforce
- 13
+ 14
rjw_genes_fertilin
rjw_genes_ability_naked_prowess
@@ -256,6 +256,34 @@
+
+ rjw_genes_lifeforce_empath
+ empathic lifeforce
+ RJW_Genes.Gene_LifeForce_Empath
+ Carriers of this gene generate lifeforce if nearby pawns are sexually satisfied. Be careful: Sexually frustrated pawns will make your empath loose lifeforce!
+ Genes/Icons/Hypersexual
+ rjw_genes_lifeforce
+ 3
+ rjw_genes_fertilin
+ 1
+ -1
+
+
+
+ Genes/Icons/RJW_Genes_Endogene_Background
+ Genes/Icons/RJW_Genes_Xenogene_Background
+
+
+
+ 2500
+ 25
+ 0.02
+ 0.01
+ -0.01
+
+
+
+
rjw_genes_drainer
vitality drainer
diff --git a/Source/GeneDefOf.cs b/Source/GeneDefOf.cs
index c58beab..f016e97 100644
--- a/Source/GeneDefOf.cs
+++ b/Source/GeneDefOf.cs
@@ -93,9 +93,10 @@ namespace RJW_Genes
public static readonly GeneDef rjw_genes_seduce;
public static readonly GeneDef rjw_genes_paralysingkiss;
public static readonly GeneDef rjw_genes_cockeater;
+ public static readonly GeneDef rjw_genes_lifeforce_empath;
- // Cosmetic
- public static readonly GeneDef rjw_genes_succubus_tail;
+ // Cosmetic
+ public static readonly GeneDef rjw_genes_succubus_tail;
public static readonly GeneDef rjw_genes_succubus_wings;
// Hive
diff --git a/Source/Genes/Life_Force/Defs/LifeForceEmpathExtension.cs b/Source/Genes/Life_Force/Defs/LifeForceEmpathExtension.cs
new file mode 100644
index 0000000..1c5170d
--- /dev/null
+++ b/Source/Genes/Life_Force/Defs/LifeForceEmpathExtension.cs
@@ -0,0 +1,19 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Verse;
+
+namespace RJW_Genes
+{
+ public class LifeForceEmpathExtension : DefModExtension
+ {
+ public int tickInterval;
+ public int empathDistance;
+
+ public float aheagoIncrement;
+ public float satisfactionIncrement;
+ public float frustratedDecrement;
+ }
+}
diff --git a/Source/Genes/Life_Force/Genes/Gene_LifeForce_Empath.cs b/Source/Genes/Life_Force/Genes/Gene_LifeForce_Empath.cs
new file mode 100644
index 0000000..69410ed
--- /dev/null
+++ b/Source/Genes/Life_Force/Genes/Gene_LifeForce_Empath.cs
@@ -0,0 +1,118 @@
+using System.Collections.Generic;
+using Verse;
+using RimWorld;
+
+namespace RJW_Genes
+{
+ public class Gene_LifeForce_Empath : Gene
+ {
+
+ const int EMPATH_DISTANCE_FALLBACK = 25;
+ const int TICK_INTERVAL_FALLBACK = 60000 / 48;
+
+ const float AHEAGO_FALLBACK = 0.02f, SATISFIED_FALLBACK = 0.01f, FRUSTRATED_FALLBACK = -0.01f;
+
+ int empathDistance = 25;
+ int tickInterval = 60000 / 48 ; // 60k = 1 day, we want 0.5h which is 1/48th of 1 day.
+
+ float aheagoIncrement = 0.02f;
+ float satisfiedIncrement = 0.01f;
+ float frustratedDecrement = -0.01f;
+
+
+ Gene_LifeForce_Empath() : base()
+ {
+ SetValuesFromExtension();
+ }
+
+ private void SetValuesFromExtension()
+ {
+ LifeForceEmpathExtension empathExt = GeneDefOf.rjw_genes_lifeforce_empath.GetModExtension();
+
+ tickInterval = empathExt?.tickInterval ?? TICK_INTERVAL_FALLBACK;
+ empathDistance = empathExt?.empathDistance ?? EMPATH_DISTANCE_FALLBACK;
+
+ aheagoIncrement = empathExt?.aheagoIncrement ?? AHEAGO_FALLBACK;
+ satisfiedIncrement = empathExt?.satisfactionIncrement ?? SATISFIED_FALLBACK;
+ frustratedDecrement = empathExt?.frustratedDecrement ?? FRUSTRATED_FALLBACK;
+ }
+
+ public override void Tick()
+ {
+ base.Tick();
+ if (this.pawn.IsHashIntervalTick(tickInterval) && this.pawn.Map != null)
+ {
+ foreach (Pawn pawn in this.AffectedPawns(this.pawn.Position, this.pawn.Map))
+ {
+ this.FarmLifeForce(pawn);
+ }
+
+ }
+ }
+
+ ///
+ /// Creates an IEnumerable of all pawns which are closeby and in lineofsight, self and other pawns with lifeforce gene are skipped (to prevent loops).
+ ///
+ /// The position of the empath on the map
+ /// The map the empath is on
+ /// A list of all pawns that are close enough for the empath to connect.
+ private IEnumerable AffectedPawns(IntVec3 pos, Map map)
+ {
+ foreach (Pawn pawn in map.mapPawns.AllPawns)
+ {
+ // Return for trivial errors
+ if (pawn == null || this.pawn == null || pawn == this.pawn)
+ continue;
+ // Check for position-existance
+ if (pawn.Position == null || pos == null || pawn.Map == null)
+ continue;
+ // Do nothing if pawn is carried
+ if (pawn.CarriedBy != null)
+ continue;
+ // Do nothing if Pawn is Baby or Child (#25)
+ if (!pawn.ageTracker.Adult)
+ continue;
+ // Do nothing for pawns that also have lifeforce
+ if (GeneUtility.HasGeneNullCheck(pawn, GeneDefOf.rjw_genes_lifeforce))
+ continue;
+
+ // Actual Logic:
+ // Pawn qualifies in right distance and needs line of sight.
+ if (pos.DistanceTo(pawn.Position) < empathDistance && GenSight.LineOfSight(pos, pawn.Position, pawn.Map))
+ {
+ yield return pawn;
+ }
+ }
+
+ yield break;
+ }
+
+ ///
+ /// Adjust the empaths lifeforce depending on the farmed pawns sexneed.
+ ///
+ /// The pawn affecting the empath, increasing or decreasing his lifeforce.
+ private void FarmLifeForce(Pawn farmedPawn)
+ {
+ // Short rename to make rest more obvious.
+ Pawn empath = pawn;
+
+ if (farmedPawn == null)
+ return;
+
+ var sexneed = farmedPawn.needs.TryGetNeed();
+
+ // Shortwire: do nothing on no sexneed.
+ if (sexneed == null)
+ return;
+
+ if (sexneed.CurLevel >= sexneed.thresh_ahegao())
+ GeneUtility.OffsetLifeForce(GeneUtility.GetLifeForceGene(empath), aheagoIncrement);
+ else if (sexneed.CurLevel >= sexneed.thresh_satisfied())
+ GeneUtility.OffsetLifeForce(GeneUtility.GetLifeForceGene(empath), satisfiedIncrement);
+ else if (sexneed.CurLevel <= sexneed.thresh_frustrated())
+ GeneUtility.OffsetLifeForce(GeneUtility.GetLifeForceGene(empath), frustratedDecrement);
+
+ }
+
+ }
+}
diff --git a/Source/Rjw-Genes.csproj b/Source/Rjw-Genes.csproj
index e2ecbaa..b8fa287 100644
--- a/Source/Rjw-Genes.csproj
+++ b/Source/Rjw-Genes.csproj
@@ -113,6 +113,8 @@
+
+