Merge branch 'bugfixes' into 'main'

Bugfixes

See merge request lutepickle/rjw_menstruation!1
This commit is contained in:
lutepickle 2022-04-23 04:53:34 +00:00
commit 0e9a5fabda
7 changed files with 71 additions and 38 deletions

View file

@ -251,11 +251,27 @@ namespace RJW_Menstruation
return mixedcolor;
}
}
public Stage CurrentVisibleStage
{
get
{
if (curStage == Stage.Pregnant)
{
if (Configurations.InfoDetail == Configurations.DetailLevel.All || (PregnancyHelper.GetPregnancy(parent.pawn)?.Visible ?? false))
return Stage.Pregnant;
else
return Stage.Luteal;
}
return curStage;
}
}
public string GetCurStageLabel
{
get
{
switch (curStage)
switch (CurrentVisibleStage)
{
case Stage.Follicular:
return Translations.Stage_Follicular;
@ -268,8 +284,7 @@ namespace RJW_Menstruation
case Stage.Fertilized:
return Translations.Stage_Fertilized;
case Stage.Pregnant:
if (Configurations.InfoDetail == Configurations.DetailLevel.All || (PregnancyHelper.GetPregnancy(parent.pawn)?.Visible ?? false)) return Translations.Stage_Pregnant;
else return Translations.Stage_Luteal;
return Translations.Stage_Pregnant;
case Stage.Recover:
return Translations.Stage_Recover;
case Stage.None:
@ -483,7 +498,7 @@ namespace RJW_Menstruation
{
get
{
if (!StageTexture.TryGetValue(curStage, out Texture2D tex)) tex = TextureCache.TzeentchTexture;
if (!StageTexture.TryGetValue(CurrentVisibleStage, out Texture2D tex)) tex = TextureCache.TzeentchTexture;
return tex;
}
}

View file

@ -157,7 +157,7 @@ namespace RJW_Menstruation
}
public static Texture2D GetEggIcon(this HediffComp_Menstruation comp)
{
if (comp.parent.pawn.IsPregnant())
if (comp.parent.pawn.IsPregnant(Configurations.InfoDetail != Configurations.DetailLevel.All))
{
if (comp.parent.pawn.GetPregnancyProgress() < 0.2f) return ContentFinder<Texture2D>.Get("Eggs/Egg_Implanted00", true);
else return ContentFinder<Texture2D>.Get("Womb/Empty", true);

View file

@ -17,43 +17,27 @@ namespace RJW_Menstruation
return;
}
List<Gizmo> gizmoList = __result.ToList();
if (__instance.ShouldShowWombGizmo())
{
AddWombGizmos(__instance, ref gizmoList);
__result = AddWombGizmos(__instance, __result);
}
//if (Configurations.EnableWombIcon && __instance.gender == Gender.Female)
//{
// if (!__instance.IsAnimal())
// {
// AddWombGizmos(__instance, ref gizmoList);
// }
// else if (Configurations.EnableAnimalCycle)
// {
// AddWombGizmos(__instance, ref gizmoList);
// }
//}
__result = gizmoList;
}
private static void AddWombGizmos(Pawn __instance, ref List<Gizmo> gizmoList)
private static IEnumerable<Gizmo> AddWombGizmos(Pawn __instance, IEnumerable<Gizmo> gizmos)
{
foreach (Gizmo gizmo in gizmos)
yield return gizmo;
HediffComp_Menstruation comp = __instance.GetMenstruationComp();
if (comp != null) AddMenstruationGizmos(__instance, comp, ref gizmoList);
if (comp == null) yield break;
foreach (Gizmo gizmo in GetMenstruationGizmos(__instance, comp))
yield return gizmo;
}
private static void AddMenstruationGizmos(Pawn pawn, HediffComp_Menstruation comp, ref List<Gizmo> gizmolist)
public static List<Gizmo> GetMenstruationGizmos(Pawn pawn, HediffComp_Menstruation comp)
{
gizmolist.Add(CreateGizmo_WombStatus(pawn, comp));
return new List<Gizmo>() { CreateGizmo_WombStatus(pawn, comp) };
}

View file

@ -1,5 +1,7 @@
using HarmonyLib;
using rjw;
using rjw.Modules.Interactions.Enums;
using rjw.Modules.Interactions.Objects;
using Verse;
using UnityEngine;
@ -19,6 +21,8 @@ namespace RJW_Menstruation
if (partner.IsAnimal() && !Configurations.EnableAnimalCycle) return true;
if (!InteractionCanCausePregnancy(props)) return false;
var pawnparts = Genital_Helper.get_PartsHediffList(pawn, Genital_Helper.get_genitalsBPR(pawn));
HediffComp_Menstruation comp = partner.GetMenstruationComp();
@ -39,6 +43,36 @@ namespace RJW_Menstruation
}
/// <summary>
/// Checks if pregnancy can happen based on the interaction def
/// This is needed for futanari sex, but should work for everyone
/// </summary>
/// <param name="props"></param>
/// <returns>Interaction can result in pregnancy</returns>
private static bool InteractionCanCausePregnancy(SexProps props)
{
InteractionWithExtension interaction = rjw.Modules.Interactions.Helpers.InteractionHelper.GetWithExtension(props.dictionaryKey);
if (!interaction.HasInteractionTag(InteractionTag.Fertilization))
return false;
bool usesPawnsPenis;
bool usesPartnersVagina;
if (!props.isReceiver)
{
usesPawnsPenis = interaction.DominantHasTag(GenitalTag.CanPenetrate);
usesPartnersVagina = interaction.SubmissiveHasFamily(GenitalFamily.Vagina);
}
else
{
usesPawnsPenis = interaction.SubmissiveHasTag(GenitalTag.CanPenetrate);
usesPartnersVagina = interaction.DominantHasFamily(GenitalFamily.Vagina);
}
return usesPawnsPenis && usesPartnersVagina;
}
}
[HarmonyPatch(typeof(PregnancyHelper), "Doimpregnate")]

View file

@ -13,15 +13,15 @@ using HarmonyLib;
namespace RJW_Menstruation.Sexperience
{
[HarmonyPatch(typeof(Pawn_GetGizmos), "AddMenstruationGizmos")]
[HarmonyPatch(typeof(Pawn_GetGizmos), nameof(Pawn_GetGizmos.GetMenstruationGizmos))]
public static class GetGizmos_Patch
{
public static void Postfix(Pawn pawn, HediffComp_Menstruation comp, ref List<Gizmo> gizmolist)
public static void Postfix(Pawn pawn, HediffComp_Menstruation comp, ref List<Gizmo> __result)
{
gizmolist.Add(CreateGizmo_GatherCum(pawn, comp));
__result.Add(CreateGizmo_GatherCum(comp));
}
private static Gizmo CreateGizmo_GatherCum(Pawn pawn, HediffComp_Menstruation comp)
private static Gizmo CreateGizmo_GatherCum(HediffComp_Menstruation comp)
{
Texture2D icon = TextureCache.GatherCum_Bucket;
string label = Keyed.RS_GatherCum;

View file

@ -21,7 +21,7 @@ namespace RJW_Menstruation.Sexperience
public static bool HasJobOnThing(Pawn pawn, Thing t, bool forced, ref bool __result)
{
HediffComp_Menstruation comp = pawn.GetMenstruationComp();
if (comp != null && comp.DoCleanWomb && comp.TotalCumPercent > 0.001f)
if (comp != null && comp.DoCleanWomb && comp.TotalCumPercent > 0.001f && pawn.Map.listerBuildings.ColonistsHaveBuilding(VariousDefOf.CumBucket))
{
__result = true;
return false;

View file

@ -12,6 +12,6 @@ namespace RJW_Menstruation.Sexperience
public static readonly JobDef VaginaWashingwithBucket = DefDatabase<JobDef>.GetNamed("VaginaWashingwithBucket");
public static readonly ThingDef GatheredCumMixture = DefDatabase<ThingDef>.GetNamed("GatheredCumMixture");
public static readonly ThingDef CumBucket = DefDatabase<ThingDef>.GetNamed("CumBucket");
}
}