mirror of
https://gitgud.io/c0ffeeeeeeee/coffees-rjw-ideology-addons.git
synced 2024-08-14 23:57:38 +00:00
replaced compinducelactation with hediffcomp; cleaner
todo: add abilitydef to hucow handler to begin inducing lactation; give lactation induction hediff to recipient pawn add thoughtdef w/ thoughtworker_hediff to give pawns thoughts on inducing lactation
This commit is contained in:
parent
1d6ecb3f95
commit
5b4b203d13
19 changed files with 233 additions and 70 deletions
|
@ -1,23 +0,0 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Verse;
|
||||
using RimWorld;
|
||||
using rjw;
|
||||
using Milk;
|
||||
using UnityEngine;
|
||||
|
||||
namespace CRIALactation
|
||||
{
|
||||
public class CompProperties_InduceLactation : CompProperties
|
||||
{
|
||||
public CompProperties_InduceLactation()
|
||||
{
|
||||
this.compClass = typeof(CompInduceLactation);
|
||||
}
|
||||
|
||||
public float DaysToLactating = 15;
|
||||
public float TimesMassagedADay = 2.5f;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Verse;
|
||||
using RimWorld;
|
||||
using rjw;
|
||||
using Milk;
|
||||
using UnityEngine;
|
||||
|
||||
namespace CRIALactation
|
||||
{
|
||||
public class CompProperties_Lactation : CompProperties
|
||||
{
|
||||
public CompProperties_Lactation()
|
||||
{
|
||||
this.compClass = typeof(CompLactation);
|
||||
}
|
||||
|
||||
//public float DaysToLactating = 15;
|
||||
//public float TimesMassagedADay = 2.5f;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
using RimWorld;
|
||||
using RimWorld.Planet;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Verse;
|
||||
|
||||
namespace CRIALactation
|
||||
{
|
||||
public class CompAbilityEffect_BeginInducingLactation : CompAbilityEffect
|
||||
{
|
||||
|
||||
public override bool Valid(LocalTargetInfo target, bool throwMessages = false)
|
||||
{
|
||||
Pawn pawn = target.Pawn;
|
||||
|
||||
if (pawn == null) return false;
|
||||
if (!pawn.IsColonistPlayerControlled || !pawn.IsSlaveOfColony || !pawn.IsPrisonerOfColony) return false;
|
||||
if (LactationUtility.IsLactating(pawn)) return false;
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -10,7 +10,20 @@ using UnityEngine;
|
|||
|
||||
namespace CRIALactation
|
||||
{
|
||||
public class CompInduceLactation : ThingComp
|
||||
public class CompLactation : ThingComp
|
||||
{
|
||||
public int lastHumanLactationIngestedTick = 0;
|
||||
public override void PostExposeData()
|
||||
{
|
||||
base.PostExposeData();
|
||||
Scribe_Values.Look<int>(ref this.lastHumanLactationIngestedTick, "lastHumanLactationIngestedTick", 0);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
public class CompLactation : ThingComp
|
||||
{
|
||||
private readonly int OneDayInTicks = 60000;
|
||||
private int TicksSinceLastMassage = -60000;
|
||||
|
@ -124,4 +137,6 @@ namespace CRIALactation
|
|||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
}
|
|
@ -17,8 +17,8 @@ namespace CRIALactation
|
|||
|
||||
if(__instance?.def == ThingDefOf_Milk.HumanMilk || __instance?.def == ThingDefOf_Milk.HumanoidMilk)
|
||||
{
|
||||
if (ingester.TryGetComp<CompInduceLactation>() == null) return;
|
||||
ingester.TryGetComp<CompInduceLactation>().lastHumanLactationIngestedTick = Find.TickManager.TicksGame;
|
||||
if (ingester.TryGetComp<CompLactation>() == null) return;
|
||||
ingester.TryGetComp<CompLactation>().lastHumanLactationIngestedTick = Find.TickManager.TicksGame;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -19,6 +19,9 @@ namespace CRIALactation
|
|||
public static HediffDef Lactating_Permanent;
|
||||
public static HediffDef Heavy_Lactating_Permanent;
|
||||
public static HediffDef Lactating_Natural;
|
||||
|
||||
|
||||
public static HediffDef InducingLactation;
|
||||
public static HediffDef Hucow;
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Verse;
|
||||
|
||||
namespace CRIALactation
|
||||
{
|
||||
public class HediffCompProperties_LactationInduction : HediffCompProperties
|
||||
{
|
||||
public HediffCompProperties_LactationInduction()
|
||||
{
|
||||
this.compClass = typeof(HediffComp_LactationInduction);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Verse;
|
||||
|
||||
namespace CRIALactation
|
||||
{
|
||||
public class HediffComp_LactationInduction : HediffComp
|
||||
{
|
||||
private readonly int OneDayInTicks = 60000;
|
||||
private float TimesMassagedADay = 2.5f;
|
||||
private int tickLastMassaged = 0, DaysToLactating = 15;
|
||||
|
||||
|
||||
|
||||
public void massage(Pawn massager)
|
||||
{
|
||||
|
||||
this.parent.Severity += (float)1 / (DaysToLactating * (TimesMassagedADay + Rand.Value));
|
||||
}
|
||||
|
||||
public bool canMassage()
|
||||
{
|
||||
return tickLastMassaged + OneDayInTicks / TimesMassagedADay < GenTicks.TicksGame;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public override void CompExposeData()
|
||||
{
|
||||
Scribe_Values.Look<int>(ref this.tickLastMassaged, "lastLactationInductionMassagedTick", 0);
|
||||
base.CompExposeData();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -28,6 +28,7 @@ namespace CRIALactation
|
|||
Toil massage = new Toil();
|
||||
massage.FailOnDespawnedOrNull(TargetIndex.A);
|
||||
massage.FailOnAggroMentalStateAndHostile(TargetIndex.A);
|
||||
float massageProgress = 0;
|
||||
massage.initAction = delegate
|
||||
{
|
||||
Pawn p = job.GetTarget(TargetIndex.A).Thing as Pawn;
|
||||
|
@ -46,14 +47,9 @@ namespace CRIALactation
|
|||
Pawn p = job.GetTarget(TargetIndex.A).Thing as Pawn;
|
||||
if (massageProgress >= WorkTotal)
|
||||
{
|
||||
p.TryGetComp<CompInduceLactation>().MassageBreasts();
|
||||
p.health.hediffSet.GetFirstHediffOfDef(HediffDefOf_Milk.InducingLactation).TryGetComp<HediffComp_LactationInduction>().massage(pawn);
|
||||
return JobCondition.Succeeded;
|
||||
}
|
||||
|
||||
if (!(p.TryGetComp<CompInduceLactation>().isActive && p.TryGetComp<CompInduceLactation>().CanMassage))
|
||||
{
|
||||
return JobCondition.Incompletable;
|
||||
}
|
||||
|
||||
return JobCondition.Ongoing;
|
||||
|
||||
|
@ -74,7 +70,5 @@ namespace CRIALactation
|
|||
yield break;
|
||||
|
||||
}
|
||||
|
||||
float massageProgress = 0f;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -55,13 +55,10 @@ namespace CRIALactation
|
|||
|
||||
public static bool isMassageable(Pawn p)
|
||||
{
|
||||
CompInduceLactation c = p.TryGetComp<CompInduceLactation>();
|
||||
if (c != null && c.isActive && c.CanMassage)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
Hediff lactationInductionHediff = p.health?.hediffSet?.GetFirstHediffOfDef(HediffDefOf_Milk.InducingLactation);
|
||||
if (lactationInductionHediff == null) return false;
|
||||
|
||||
return false;
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ namespace CRIALactation
|
|||
|
||||
protected override ThoughtState ShouldHaveThought(Pawn p)
|
||||
{
|
||||
int num = Mathf.Max(0, p.TryGetComp<CompInduceLactation>().lastHumanLactationIngestedTick);
|
||||
int num = Mathf.Max(0, p.TryGetComp<CompLactation>().lastHumanLactationIngestedTick);
|
||||
return Find.TickManager.TicksGame - num > 480000 && !LactationUtility.IsHucow(p);
|
||||
}
|
||||
|
||||
|
|
|
@ -36,13 +36,15 @@ namespace CRIALactation
|
|||
public override bool HasJobOnThing(Pawn p, Thing t, bool forced = false)
|
||||
{
|
||||
Pawn pawn2 = t as Pawn;
|
||||
if(pawn2?.TryGetComp<CompInduceLactation>() == null)
|
||||
if(pawn2?.health?.hediffSet.GetFirstHediffOfDef(HediffDefOf_Milk.InducingLactation) == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
CompInduceLactation c = pawn2.TryGetComp<CompInduceLactation>();
|
||||
Hediff lactationInductionHediff = pawn2?.health?.hediffSet?.GetFirstHediffOfDef(HediffDefOf_Milk.InducingLactation);
|
||||
if (lactationInductionHediff == null) return false;
|
||||
|
||||
return p != pawn2 && c.isActive && c.CanMassage && !pawn2.Downed && !pawn2.Drafted && !pawn2.InAggroMentalState && !pawn2.IsFormingCaravan() && pawn2.CanCasuallyInteractNow(false, true, false) && p.CanReserve(pawn2, 1, -1, null, forced);
|
||||
HediffComp_LactationInduction lactInductComp = lactationInductionHediff.TryGetComp<HediffComp_LactationInduction>();
|
||||
return p != pawn2 && lactInductComp.canMassage() && !pawn2.Downed && !pawn2.Drafted && !pawn2.InAggroMentalState && !pawn2.IsFormingCaravan() && pawn2.CanCasuallyInteractNow(false, true, false) && p.CanReserve(pawn2, 1, -1, null, forced);
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue