Hucow role and balancing

This commit is contained in:
c0ffee12 2021-07-28 18:45:25 -07:00
parent 47291f333c
commit e2d5daf97b
11 changed files with 143 additions and 12 deletions

View file

@ -17,6 +17,36 @@ namespace CRIALactation
public static class HarmonyPatch_Milk_HumanCompHasGatherableBodyResource
{
public static void Prefix(HumanCompHasGatherableBodyResource __instance)
{
if (!__instance.parent.IsHashIntervalTick(100))
{
return;
}
if (!(__instance.parent is Pawn)) return;
Pawn p = __instance.parent as Pawn;
if (p?.health?.hediffSet == null) return;
if (p.Ideo?.GetRole(p) != null && p.Ideo.GetRole(p).def == PreceptDefOf_Lactation.IdeoRole_Hucow)
{
if(p.health.hediffSet.HasHediff(HediffDef.Named("Lactating_Natural"), false))
{
p.health.RemoveHediff(p.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("Lactating_Natural"), false));
}
if (p.health.hediffSet.HasHediff(HediffDef.Named("Lactating_Drug"), false))
{
p.health.RemoveHediff(p.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("Lactating_Drug"), false));
}
if(!(p.health.hediffSet.HasHediff(HediffDef.Named("Lactating_Permanent"), false) ||
p.health.hediffSet.HasHediff(HediffDef.Named("Heavy_Lactating_Permanent"), false)))
{
p.health.AddHediff(HediffDef.Named("Lactating_Permanent"));
}
}
}
public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> codeInstructions)
{
@ -52,7 +82,9 @@ namespace CRIALactation
Pawn pawn = __instance.parent as Pawn;
if(pawn.Ideo.HasPrecept(PreceptDefOf_Lactation.Lactating_Essential))
{
return resourcesIntervalDays * 0.666f; //1.5x normal rate
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;
@ -60,4 +92,30 @@ namespace CRIALactation
}
}
[HarmonyPatch(typeof(CompHyperMilkableHuman), "ResourceAmount", MethodType.Getter)]
public static class HarmonyPatch_IncreaseYieldForHucowHyperMilkable
{
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 = 65;
}
}
}
[HarmonyPatch(typeof(CompMilkableHuman), "ResourceAmount", MethodType.Getter)]
public static class HarmonyPatch_IncreaseYieldForHucowMilkable
{
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;
}
}
}
}