Skip to content
Snippets Groups Projects
Commit c0caf057 authored by Ed86's avatar Ed86
Browse files

added fix for pregnancy last name generation with non humans

parent 0e387748
No related branches found
No related tags found
No related merge requests found
......@@ -355,6 +355,30 @@ namespace rjw
}
[HarmonyPatch(typeof(PregnancyUtility), "RandomLastName")]
static class Patch_PregnancyUtility_RandomLastName
{
public static bool Prefix(ref Pawn geneticMother, ref Pawn birthingMother, ref Pawn father)
{
if (geneticMother != null)
if (geneticMother.Name == null || !xxx.is_human(geneticMother))
{
geneticMother = null;
}
if (father != null)
if (father.Name == null || !xxx.is_human(father))
{
father = null;
}
if (birthingMother != null)
if (birthingMother.Name == null || !xxx.is_human(birthingMother))
{
birthingMother = null;
}
return true;
}
}
// Fixes CompEggLayer and mating for humanlikes.
// Note that this involves skipping over a check for the Biotech DLC, but as of build 1.4.3534 this doesn't unlock
// any Biotech-only features or anything like that.
......@@ -464,49 +488,47 @@ namespace rjw
}
}
[HarmonyPatch(typeof(PawnColumnWorker_Pregnant), "GetIconFor")]
public class PawnColumnWorker_Patch_Icon
{
public static void Postfix(Pawn pawn, ref Texture2D __result)
{
if (pawn.IsVisiblyPregnant()) __result = ContentFinder<Texture2D>.Get("UI/Icons/Animal/Pregnant", true);
}
}
[HarmonyPatch(typeof(PawnColumnWorker_Pregnant), "GetTooltipText")]
public class PawnColumnWorker_Patch_Tooltip
{
public static bool Prefix(Pawn pawn, ref string __result)
{
float gestationProgress = PregnancyHelper.GetPregnancy(pawn).Severity; // no multipregnancy support
int num = (int)(pawn.RaceProps.gestationPeriodDays * GenDate.TicksPerDay);
int numTicks = (int)(gestationProgress * (float)num);
__result = "PregnantIconDesc".Translate(numTicks.ToStringTicksToDays("F0"), num.ToStringTicksToDays("F0"));
return false;
}
}
[HarmonyPatch(typeof(TransferableUIUtility), "DoExtraIcons")]
public class TransferableUIUtility_Patch_Icon
{
//private static readonly Texture2D PregnantIcon = ContentFinder<Texture2D>.Get("UI/Icons/Animal/Pregnant", true);
public static void Postfix(Transferable trad, Rect rect, ref float curX, Texture2D ___PregnantIcon)
{
Pawn pawn = trad.AnyThing as Pawn;
if (pawn?.health?.hediffSet != null && pawn.IsVisiblyPregnant())
{
Rect rect3 = new Rect(curX - 24f, (rect.height - 24f) / 2f, 24f, 24f);
curX -= 24f;
if (Mouse.IsOver(rect3))
{
TooltipHandler.TipRegion(rect3, PawnColumnWorker_Pregnant.GetTooltipText(pawn));
}
GUI.DrawTexture(rect3, ___PregnantIcon);
}
}
}
[HarmonyPatch(typeof(PawnColumnWorker_Pregnant), "GetIconFor")]
public class PawnColumnWorker_Patch_Icon
{
public static void Postfix(Pawn pawn, ref Texture2D __result)
{
if (pawn.IsVisiblyPregnant()) __result = ContentFinder<Texture2D>.Get("UI/Icons/Animal/Pregnant", true);
}
}
[HarmonyPatch(typeof(PawnColumnWorker_Pregnant), "GetTooltipText")]
public class PawnColumnWorker_Patch_Tooltip
{
public static bool Prefix(Pawn pawn, ref string __result)
{
float gestationProgress = PregnancyHelper.GetPregnancy(pawn).Severity; // no multipregnancy support
int num = (int)(pawn.RaceProps.gestationPeriodDays * GenDate.TicksPerDay);
int numTicks = (int)(gestationProgress * (float)num);
__result = "PregnantIconDesc".Translate(numTicks.ToStringTicksToDays("F0"), num.ToStringTicksToDays("F0"));
return false;
}
}
[HarmonyPatch(typeof(TransferableUIUtility), "DoExtraIcons")]
public class TransferableUIUtility_Patch_Icon
{
//private static readonly Texture2D PregnantIcon = ContentFinder<Texture2D>.Get("UI/Icons/Animal/Pregnant", true);
public static void Postfix(Transferable trad, Rect rect, ref float curX, Texture2D ___PregnantIcon)
{
Pawn pawn = trad.AnyThing as Pawn;
if (pawn?.health?.hediffSet != null && pawn.IsVisiblyPregnant())
{
Rect rect3 = new Rect(curX - 24f, (rect.height - 24f) / 2f, 24f, 24f);
curX -= 24f;
if (Mouse.IsOver(rect3))
{
TooltipHandler.TipRegion(rect3, PawnColumnWorker_Pregnant.GetTooltipText(pawn));
}
GUI.DrawTexture(rect3, ___PregnantIcon);
}
}
}
//[HarmonyPatch(typeof(AutoSlaughterManager))]
//public class AutoSlaughterManager_AnimalsToSlaughter_rjw_preg
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment