2024-05-26 23:27:10 +00:00
|
|
|
|
using RimWorld;
|
|
|
|
|
using rjw;
|
|
|
|
|
using Verse;
|
|
|
|
|
using System;
|
|
|
|
|
using RimWorld.Planet;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace RJWLoveFeeding
|
|
|
|
|
{
|
|
|
|
|
static class LustFeeding
|
|
|
|
|
{
|
|
|
|
|
//[HarmonyPostfix]
|
|
|
|
|
static Def LoveFeed = DefDatabase<GeneDef>.GetNamed("RS_LoveFeed", false);
|
|
|
|
|
static Def VampireLover = DefDatabase<GeneDef>.GetNamed("VU_VampireLover", false);
|
2024-05-27 19:19:08 +00:00
|
|
|
|
static Def LovinDependency = DefDatabase<GeneDef>.GetNamed("VRE_LovinDependency", false);
|
|
|
|
|
static NeedDef VRE_Lovin = DefDatabase<NeedDef>.GetNamed("VRE_Lovin", false);
|
2024-05-26 23:27:10 +00:00
|
|
|
|
public static void Postfix(SexProps props)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
LustFeeding.RJWLustFeeding(props);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
Log.Error(e.ToString());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void RJWLustFeeding(SexProps props)
|
|
|
|
|
{
|
|
|
|
|
if((props.pawn != null) && (props.partner != null) && !xxx.is_animal(props.pawn) && !xxx.is_animal(props.partner))
|
|
|
|
|
{
|
|
|
|
|
//ModLog.Message($" Patch Worked");
|
|
|
|
|
if(!props.pawn.IsCaravanMember() && !props.partner.IsCaravanMember())
|
|
|
|
|
{
|
2024-05-27 19:19:08 +00:00
|
|
|
|
FillNeed(props.pawn);
|
|
|
|
|
FillNeed(props.partner);
|
|
|
|
|
|
|
|
|
|
RJWTryTakeBlood(props.pawn, props.partner);
|
2024-05-26 23:27:10 +00:00
|
|
|
|
RJWTryTakeBlood(props.partner, props.pawn);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-27 19:19:08 +00:00
|
|
|
|
public static void FillNeed(Pawn pawn)
|
|
|
|
|
{
|
|
|
|
|
Pawn_GeneTracker genes;
|
|
|
|
|
if (LovinDependency != null)
|
|
|
|
|
{
|
|
|
|
|
genes = pawn.genes;
|
|
|
|
|
|
|
|
|
|
if (genes == null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (pawn.genes.HasActiveGene(RJW_Genes.GeneDefOf.VRE_LovinDependency))
|
|
|
|
|
{
|
|
|
|
|
if (VRE_Lovin != null)
|
|
|
|
|
{
|
|
|
|
|
Pawn_NeedsTracker needs = pawn.needs;
|
|
|
|
|
((needs != null) ? needs.TryGetNeed(VRE_Lovin) : null).CurLevel = 1f;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-26 23:27:10 +00:00
|
|
|
|
|
2024-05-27 19:19:08 +00:00
|
|
|
|
public static bool RJWTryTakeBlood(Pawn pawn, Pawn bloodBag)
|
2024-05-26 23:27:10 +00:00
|
|
|
|
{
|
|
|
|
|
|
2024-06-04 20:38:58 +00:00
|
|
|
|
if (bloodBag == null || pawn == null) return false;
|
2024-05-26 23:27:10 +00:00
|
|
|
|
Pawn_GeneTracker genes = bloodBag.genes;
|
2024-06-04 20:51:19 +00:00
|
|
|
|
if (genes!=null)
|
2024-05-26 23:27:10 +00:00
|
|
|
|
if ((genes.GetFirstGeneOfType<Gene_Hemogen>() != null))
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
genes = pawn.genes;
|
|
|
|
|
|
|
|
|
|
if (genes == null)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool isLoveFeeder = false;
|
|
|
|
|
|
|
|
|
|
if(LoveFeed != null)
|
|
|
|
|
{
|
|
|
|
|
if (RJWSettings.DevMode) RJW_Genes.ModLog.Message("LoveFeed checks");
|
|
|
|
|
if (genes.HasActiveGene(RJW_Genes.GeneDefOf.RS_LoveFeed))
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
isLoveFeeder = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (VampireLover != null)
|
|
|
|
|
{
|
|
|
|
|
if (RJWSettings.DevMode) RJW_Genes.ModLog.Message("LoveFeed checks");
|
|
|
|
|
if (genes.HasActiveGene(RJW_Genes.GeneDefOf.VU_VampireLover))
|
|
|
|
|
{
|
|
|
|
|
isLoveFeeder = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (isLoveFeeder && (genes.GetFirstGeneOfType<Gene_Hemogen>() != null))
|
|
|
|
|
{
|
|
|
|
|
ModLog.Message($" Lovefeeder just finished loving: {xxx.get_pawnname(pawn)}");
|
|
|
|
|
|
|
|
|
|
Gene_Hemogen gene_Hemogen = genes.GetFirstGeneOfType<Gene_Hemogen>();
|
|
|
|
|
if (gene_Hemogen != null)
|
|
|
|
|
{
|
|
|
|
|
if (gene_Hemogen.Value < gene_Hemogen.targetValue)
|
|
|
|
|
{
|
|
|
|
|
Hediff bloodBagBloodLoss = bloodBag.health.hediffSet.GetFirstHediffOfDef(HediffDefOf.BloodLoss, false);
|
|
|
|
|
if (bloodBagBloodLoss != null)
|
|
|
|
|
{
|
|
|
|
|
float afterBite = bloodBagBloodLoss.Severity + 0.25f;
|
|
|
|
|
if ((afterBite > HediffDefOf.BloodLoss.lethalSeverity) || (afterBite > 0.49f))
|
|
|
|
|
{
|
|
|
|
|
//ModLog.Message($"{xxx.get_pawnname(pawn)} would have killed someone. {afterBite} > {HediffDefOf.BloodLoss.lethalSeverity}");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
SanguophageUtility.DoBite(pawn, bloodBag, 0.2f, 0.1f, 0.2f, 1f, IntRange.one, ThoughtDefOf.FedOn, ThoughtDefOf.FedOn_Social);
|
|
|
|
|
ModLog.Message($"{xxx.get_pawnname(pawn)} snacked on {xxx.get_pawnname(bloodBag)}");
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ModLog.Message($"{xxx.get_pawnname(pawn)} not hungry. {gene_Hemogen.Value} > {gene_Hemogen.targetValue}");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
return false; ;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|