Minor Comments and Refactoring - Letter for Mytosis Birth

This commit is contained in:
Vegapnk 2024-06-05 11:50:25 +02:00
parent 8139991123
commit 63564a2761
9 changed files with 31 additions and 31 deletions

View file

@ -13,19 +13,26 @@ using RJW_Genes;
namespace RJW_BGS namespace RJW_BGS
{ {
[HarmonyPatch(typeof(PregnancyHelper))] [HarmonyPatch(typeof(PregnancyHelper))]
public class PregnancyHelperPatcher public class Patch_RJW_PregnancyHelper_VanillaExpandedGenetics
{ {
/// <summary>
/// This Patch changes the pregnancy logic to check for possible hybridization.
/// Iff the hybrdiization applies, this prefix skips the normal AddPregnancyHediff (by returning false).
///
/// Small Note: Below we use `Hediff_BasePregnancy.Create<Hediff_BestialPregnancy>(mother, father, DnaGivingParent.Mother);`
/// This completely creates the pregnancy, it does not need to be assigned to anything or added to some hediffs.
/// </summary>
[HarmonyPrefix] [HarmonyPrefix]
[HarmonyPatch("AddPregnancyHediff")] [HarmonyPatch("AddPregnancyHediff")]
public static bool AddPregnancyHediffPrefix(Pawn mother, Pawn father) public static bool AddPregnancyHediffPrefix(Pawn mother, Pawn father)
{ {
if (!RJW_BGSSettings.rjw_bgs_VE_genetics) return true; if (!RJW_BGSSettings.rjw_bgs_VE_genetics) return true;
if (mother == null || father == null) return true; if (mother == null || father == null) return true;
bool humanMotherAndSupportedAnimal = mother.IsHuman() && BasePregnancyPatcher.supportedInitialAnimalRaces.Contains(father.kindDef.race.defName); bool humanMotherAndSupportedAnimal = mother.IsHuman() && Patch_RJW_BasePregnancy_VanillaExpandedGenetics.supportedInitialAnimalRaces.Contains(father.kindDef.race.defName);
bool humanMotherAndSupportedHybrid = mother.IsHuman() && BasePregnancyPatcher.supportedHybridRaces.Contains(father.kindDef.race.defName); bool humanMotherAndSupportedHybrid = mother.IsHuman() && Patch_RJW_BasePregnancy_VanillaExpandedGenetics.supportedHybridRaces.Contains(father.kindDef.race.defName);
bool humanFatherAndSupportedAnimal = father.IsHuman() && BasePregnancyPatcher.supportedInitialAnimalRaces.Contains(mother.kindDef.race.defName); bool humanFatherAndSupportedAnimal = father.IsHuman() && Patch_RJW_BasePregnancy_VanillaExpandedGenetics.supportedInitialAnimalRaces.Contains(mother.kindDef.race.defName);
bool humanFatherAndSupportedHybrid = father.IsHuman() && BasePregnancyPatcher.supportedHybridRaces.Contains(mother.kindDef.race.defName); bool humanFatherAndSupportedHybrid = father.IsHuman() && Patch_RJW_BasePregnancy_VanillaExpandedGenetics.supportedHybridRaces.Contains(mother.kindDef.race.defName);
if (!(humanMotherAndSupportedAnimal || humanMotherAndSupportedHybrid||humanFatherAndSupportedAnimal|| humanFatherAndSupportedHybrid)) return true; if (!(humanMotherAndSupportedAnimal || humanMotherAndSupportedHybrid||humanFatherAndSupportedAnimal|| humanFatherAndSupportedHybrid)) return true;
if (humanMotherAndSupportedAnimal) if (humanMotherAndSupportedAnimal)

View file

@ -10,10 +10,13 @@ using rjw;
namespace RJW_Genes namespace RJW_Genes
{ {
/// <summary>
/// This Patch handles the changes to Fathers / Mothers when dealing with Femboys and Male/Male Pregnancies.
/// </summary>
[HarmonyPatch(typeof(ParentRelationUtility))] [HarmonyPatch(typeof(ParentRelationUtility))]
public class PatchGetParents public class Patch_ParentRelationUtility_GetParents
{ {
// Token: 0x0600000F RID: 15
[HarmonyPostfix] [HarmonyPostfix]
[HarmonyPatch("GetFather")] [HarmonyPatch("GetFather")]
private static void FatherPostfix(ref Pawn __result, Pawn pawn) private static void FatherPostfix(ref Pawn __result, Pawn pawn)
@ -38,7 +41,6 @@ namespace RJW_Genes
} }
} }
// Token: 0x06000010 RID: 16
[HarmonyPostfix] [HarmonyPostfix]
[HarmonyPatch("GetMother")] [HarmonyPatch("GetMother")]
private static void MotherPostfix(ref Pawn __result, Pawn pawn) private static void MotherPostfix(ref Pawn __result, Pawn pawn)
@ -58,7 +60,7 @@ namespace RJW_Genes
} }
} }
// Token: 0x0600001F RID: 31
[HarmonyPostfix] [HarmonyPostfix]
[HarmonyPatch("HasSameFather")] [HarmonyPatch("HasSameFather")]
private static void HasSameFatherPostfix(ref bool __result, Pawn pawn, Pawn other) private static void HasSameFatherPostfix(ref bool __result, Pawn pawn, Pawn other)
@ -92,7 +94,7 @@ namespace RJW_Genes
} }
} }
// Token: 0x06000020 RID: 32
[HarmonyPostfix] [HarmonyPostfix]
[HarmonyPatch("HasSameMother")] [HarmonyPatch("HasSameMother")]
private static void HasSameMotherPostfix(ref bool __result, Pawn pawn, Pawn other) private static void HasSameMotherPostfix(ref bool __result, Pawn pawn, Pawn other)

View file

@ -16,7 +16,6 @@ namespace RJW_Genes
public class CompAbilityEffect_MatingCall : CompAbilityEffect public class CompAbilityEffect_MatingCall : CompAbilityEffect
{ {
bool fired = false;
private new CompProperties_AbilityMatingCall Props private new CompProperties_AbilityMatingCall Props
{ {
get get

View file

@ -12,7 +12,6 @@ namespace RJW_Genes
{ {
public class CompAbilityEffect_PheromoneSpit : CompAbilityEffect public class CompAbilityEffect_PheromoneSpit : CompAbilityEffect
{ {
bool fired = false;
private new CompProperties_AbilityPheromoneSpit Props private new CompProperties_AbilityPheromoneSpit Props
{ {
get get

View file

@ -2,8 +2,6 @@
using Verse; using Verse;
// TODO: Re-Introduce this once Licentia is 1.5
// It should be rather simple
namespace RJW_Genes namespace RJW_Genes
{ {
/// <summary> /// <summary>

View file

@ -20,8 +20,6 @@ namespace RJWLoveFeeding
[HarmonyPostfix] [HarmonyPostfix]
public static void Postfix(ref bool __result, Pawn pawn, bool mustBeVisible) public static void Postfix(ref bool __result, Pawn pawn, bool mustBeVisible)
{ {
//Log.Message(xxx.get_pawnname(pawn) + " is in patch" + __result);
bool isPregnant = __result; bool isPregnant = __result;
if (MultiPregnancy != null) if (MultiPregnancy != null)
{ {
@ -31,7 +29,6 @@ namespace RJWLoveFeeding
try try
{ {
isPregnant = MultiplePregnancies.RJWMultiplePregnancy(isPregnant, pawn); isPregnant = MultiplePregnancies.RJWMultiplePregnancy(isPregnant, pawn);
//Log.Message(xxx.get_pawnname(pawn) + " is " + isPregnant);
} }
catch (Exception e) catch (Exception e)
{ {
@ -40,14 +37,11 @@ namespace RJWLoveFeeding
} }
__result = isPregnant; __result = isPregnant;
} }
} }
public static bool RJWMultiplePregnancy(bool isPregnant, Pawn fucked) public static bool RJWMultiplePregnancy(bool isPregnant, Pawn fucked)
{ {
if ((fucked != null) && !xxx.is_animal(fucked)) if ((fucked != null) && !xxx.is_animal(fucked))
{ {
@ -59,18 +53,12 @@ namespace RJWLoveFeeding
if (setNoPreggo.NullOrEmpty()) if (setNoPreggo.NullOrEmpty())
{ {
//Log.Message("No other hediffs preventing pregnancy");
Pawn_GeneTracker genes = fucked.genes; Pawn_GeneTracker genes = fucked.genes;
if (genes.HasActiveGene(RJW_Genes.GeneDefOf.RS_MultiPregnancy)) if (genes.HasActiveGene(RJW_Genes.GeneDefOf.RS_MultiPregnancy))
{ {
Log.Message(xxx.get_pawnname(fucked) + " has multipregnancy gene"); Log.Message(xxx.get_pawnname(fucked) + " has multipregnancy gene");
return false; return false;
} }
else
{
//Log.Message(xxx.get_pawnname(fucked) + " has NOT multipreg gene");
}
} }
else else
{ {

View file

@ -57,7 +57,9 @@ namespace RJW_Genes
{ {
if (RJW_Genes_Settings.rjw_genes_detailed_debug) if (RJW_Genes_Settings.rjw_genes_detailed_debug)
{ {
ModLog.Warning("Labor state for pawn " + __instance.pawn.NameShortColored + " (" + __instance.pawn.ThingID + ") is not null despite all checks passing for determining first instance of Hediff_Labor - this warning should never occur, and may indicate a bug in Hediff_LaborPushing of lingering labor state from a previous pregnancy"); ModLog.Warning("Labor state for pawn " + __instance.pawn.NameShortColored + " (" + __instance.pawn.ThingID +
") is not null despite all checks passing for determining first instance of Hediff_Labor - this warning should never occur, " +
"and may indicate a bug in Hediff_LaborPushing of lingering labor state from a previous pregnancy");
} }
return; return;
} }
@ -137,11 +139,15 @@ namespace RJW_Genes
{ {
ModLog.Message("Pawn " + __instance.pawn.NameShortColored + " (" + __instance.pawn.ThingID + ") is having random twins"); ModLog.Message("Pawn " + __instance.pawn.NameShortColored + " (" + __instance.pawn.ThingID + ") is having random twins");
} }
Find.LetterStack.ReceiveLetter("Twins!", __instance.pawn.NameShortColored + " is still in labor and is having twins!\n\nBe sure to gather your doctor and additional friends and family to ensure the other baby is also born healthy!", LetterDefOf.AnotherBaby, __instance.pawn); Find.LetterStack.ReceiveLetter("Twins!", __instance.pawn.NameShortColored + " is still in labor and is having twins!\n\n" +
"Be sure to gather your doctor and additional friends and family to ensure the other baby is also born healthy!",
LetterDefOf.AnotherBaby, __instance.pawn);
return; return;
} }
Find.LetterStack.ReceiveLetter("Another baby!", __instance.pawn.NameShortColored + " is still in labor and is having another baby!\n\nBe sure to gather your doctor and additional friends and family to ensure the next baby is also born healthy!", LetterDefOf.AnotherBaby, __instance.pawn); Find.LetterStack.ReceiveLetter("Another baby!", __instance.pawn.NameShortColored + " is still in labor and is having another baby!\n\n" +
"Be sure to gather your doctor and additional friends and family to ensure the next baby is also born healthy!",
LetterDefOf.AnotherBaby, __instance.pawn);
} }
} }
} }

View file

@ -131,8 +131,6 @@ namespace RJW_Genes
copy.equipment.DestroyAllEquipment(); copy.equipment.DestroyAllEquipment();
copy.apparel.DestroyAll(); copy.apparel.DestroyAll();
//TODO: Make a letter on birth!
PawnUtility.TrySpawnHatchedOrBornPawn(copy, toMultiply); PawnUtility.TrySpawnHatchedOrBornPawn(copy, toMultiply);
// Move the copy in front of the origin, rather than on top // Move the copy in front of the origin, rather than on top
@ -151,6 +149,9 @@ namespace RJW_Genes
copy.story = CopyStoryTracker(copy, toMultiply.story); copy.story = CopyStoryTracker(copy, toMultiply.story);
Find.LetterStack.ReceiveLetter("Orgasmic Mytosis", $"{toMultiply.NameShortColored} performed mytosis on orgasm! The pawn and its clone entered a regenerative state.",
RimWorld.LetterDefOf.NeutralEvent, copy);
return copy; return copy;
} }