hucow changes

This commit is contained in:
c0ffee12 2021-08-02 11:55:46 -07:00
parent 064871641c
commit 5e807217bc
21 changed files with 373 additions and 23 deletions

View file

@ -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_AbilityConvertHucow : CompProperties_AbilityEffect
{
public CompProperties_AbilityConvertHucow()
{
this.compClass = typeof(CompAbilityEffect_ConvertHucow);
}
}
}

View file

@ -0,0 +1,35 @@
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 CompAbilityEffect_ConvertHucow : CompAbilityEffect
{
public override bool Valid(LocalTargetInfo target, bool throwMessages = false)
{
Pawn pawn = target.Pawn;
return pawn != null && AbilityUtility.ValidateMustBeHuman(pawn, throwMessages) &&
AbilityUtility.ValidateNoMentalState(pawn, throwMessages) &&
AbilityUtility.ValidateSameIdeo(this.parent.pawn, pawn, throwMessages) &&
LactationUtility.IsLactating(pawn) &&
!LactationUtility.IsHucow(pawn);
}
public override void Apply(LocalTargetInfo target, LocalTargetInfo dest)
{
base.Apply(target, dest);
Pawn pawn = target.Pawn;
LactationUtility.ExtendLactationDuration(pawn);
}
}
}

View file

@ -24,21 +24,20 @@ namespace CRIALactation
base.CompTick();
Pawn p = this.parent as Pawn;
if (!isActive)
{
return;
}
if (!p.IsHashIntervalTick(100))
{
return;
}
if (LactationUtility.IsLactating(p))
{
InductionCompletionPercent = 0.8f;
isActive = false;
return;
}
if (!isActive)
{
return;
}
if(TicksSinceLastMassage + OneDayInTicks / Props.TimesMassagedADay < GenTicks.TicksGame)
{
CanMassage = true;
@ -53,7 +52,7 @@ namespace CRIALactation
LactationUtility.StartLactating(p, true);
isActive = false;
InductionCompletionPercent = 0.6f; //start at 60% in case they ever lose lactating again
InductionCompletionPercent = 0.80f; //start at 80% in case they ever lose lactating again
}
}

View file

@ -16,7 +16,7 @@ namespace CRIALactation
[HarmonyPatch(typeof(HumanCompHasGatherableBodyResource), "CompTick")]
public static class HarmonyPatch_Milk_HumanCompHasGatherableBodyResource
{
/*
public static void Prefix(HumanCompHasGatherableBodyResource __instance)
{
if (!__instance.parent.IsHashIntervalTick(100))
@ -45,7 +45,7 @@ namespace CRIALactation
p.health.AddHediff(HediffDef.Named("Lactating_Permanent"));
}
}
}
}*/
public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> codeInstructions)
{
@ -84,7 +84,7 @@ namespace CRIALactation
{
return resourcesIntervalDays * 0.666f * ((pawn?.Ideo?.GetRole(pawn) != null && pawn.Ideo.GetRole(pawn).def == PreceptDefOf_Lactation.IdeoRole_Hucow) ? 0.5f : 1f); //1.5x normal rate
return resourcesIntervalDays * 0.666f * pawn.GetStatValue(StatDefOf_Lactation.MilkProductionSpeed); //1.5x normal rate
}
return resourcesIntervalDays;
@ -99,10 +99,7 @@ namespace CRIALactation
public static void Postfix(CompHyperMilkableHuman __instance, ref float __result)
{
Pawn p = __instance.parent as Pawn;
if (p.Ideo.GetRole(p).def == PreceptDefOf_Lactation.IdeoRole_Hucow)
{
__result = 45;
}
__result *= p.GetStatValue(StatDefOf_Lactation.MilkProductionYield);
}
}
@ -112,10 +109,7 @@ namespace CRIALactation
public static void Postfix(CompHyperMilkableHuman __instance, ref float __result)
{
Pawn p = __instance.parent as Pawn;
if (p?.Ideo?.GetRole(p) != null && p.Ideo.GetRole(p).def == PreceptDefOf_Lactation.IdeoRole_Hucow)
{
__result = 45;
}
__result *= p.GetStatValue(StatDefOf_Lactation.MilkProductionYield);
}
}
}

View file

@ -19,6 +19,7 @@ namespace CRIALactation
public static HediffDef Lactating_Permanent;
public static HediffDef Heavy_Lactating_Permanent;
public static HediffDef Lactating_Natural;
public static HediffDef Hucow;

View file

@ -0,0 +1,19 @@
using RimWorld;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Verse;
namespace CRIALactation
{
public class HediffCompProperties_StopOnceNotLactating : HediffCompProperties
{
public HediffCompProperties_StopOnceNotLactating()
{
this.compClass = typeof(HediffComp_StopOnceNotLactating);
}
}
}

View file

@ -0,0 +1,26 @@
using RimWorld;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Verse;
namespace CRIALactation
{
public class HediffComp_StopOnceNotLactating : HediffComp
{
public override void CompPostTick(ref float severityAdjustment)
{
base.CompPostTick(ref severityAdjustment);
if(!LactationUtility.IsLactating(Pawn))
{
LactationUtility.StopBeingHucow(Pawn);
}
}
}
}

View file

@ -41,6 +41,16 @@ namespace CRIALactation
p.health.AddHediff(lactating, Genital_Helper.get_breastsBPR(p));
}
public static void StopBeingHucow(Pawn p)
{
p.health.RemoveHediff(p.health.hediffSet.GetFirstHediffOfDef(HediffDefOf_Milk.Hucow, false));
}
public static bool IsHucow(Pawn p)
{
return p.health.hediffSet.HasHediff(HediffDefOf_Milk.Hucow);
}
public static bool isMassageable(Pawn p)
{
CompInduceLactation c = p.TryGetComp<CompInduceLactation>();
@ -52,5 +62,22 @@ namespace CRIALactation
return false;
}
public static void ExtendLactationDuration(Pawn p)
{
var drugLact = p.health.hediffSet.GetFirstHediffOfDef(HediffDefOf_Milk.Lactating_Drug);
if(drugLact != null)
{
drugLact.TryGetComp<HediffComp_Disappears>().ticksToDisappear = 600000;
}
var naturalLact = p.health.hediffSet.GetFirstHediffOfDef(HediffDefOf_Milk.Lactating_Natural);
if (naturalLact != null)
{
naturalLact.TryGetComp<HediffComp_Disappears>().ticksToDisappear = 600000;
}
}
}
}

View file

@ -17,7 +17,7 @@ namespace CRIALactation
}
public static PreceptDef Lactating_Essential;
public static PreceptDef IdeoRole_Hucow;
//public static PreceptDef IdeoRole_Hucow;
}
}

View file

@ -0,0 +1,24 @@
using RimWorld;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Verse;
namespace CRIALactation
{
[DefOf]
public static class StatDefOf_Lactation
{
static StatDefOf_Lactation()
{
DefOfHelper.EnsureInitializedInCtor(typeof(StatDefOf_Lactation));
}
public static StatDef MilkProductionSpeed;
public static StatDef MilkProductionYield;
}
}