diff --git a/About/Manifest.xml b/About/Manifest.xml index 1f531db..4079dc0 100644 --- a/About/Manifest.xml +++ b/About/Manifest.xml @@ -1,7 +1,7 @@ RJW Menstruation - 1.0.0.1 + 1.0.0.3 diff --git a/Assemblies/RJW_Menstruation.dll b/Assemblies/RJW_Menstruation.dll index 95ec13e..1e632c7 100644 Binary files a/Assemblies/RJW_Menstruation.dll and b/Assemblies/RJW_Menstruation.dll differ diff --git a/Patches/Hediffs_PrivateParts.xml b/Patches/Hediffs_PrivateParts.xml index d71c2aa..edc2fcb 100644 --- a/Patches/Hediffs_PrivateParts.xml +++ b/Patches/Hediffs_PrivateParts.xml @@ -27,6 +27,48 @@ + + Defs/rjw.HediffDef_PartBase[defName="DragonVagina"] + + +
  • + 500 + 0.5 + 0.2 + 0.05 + 30 + 30 + 0 + 10 + 30 + Womb/Womb + Genitals/Vagina +
  • +
    +
    +
    + + + Defs/rjw.HediffDef_PartBase[defName="GenericVagina"] + + +
  • + 500 + 1.0 + 1.0 + 0.05 + 14 + 14 + 6 + 10 + 3 + Womb/Womb + Genitals/Vagina +
  • +
    +
    +
    + Defs/rjw.HediffDef_PartBase[defName="HydraulicVagina"] diff --git a/source/RJW_Menstruation/RJW_Menstruation/GetGizmos.cs b/source/RJW_Menstruation/RJW_Menstruation/GetGizmos.cs index efd3ad3..387942d 100644 --- a/source/RJW_Menstruation/RJW_Menstruation/GetGizmos.cs +++ b/source/RJW_Menstruation/RJW_Menstruation/GetGizmos.cs @@ -35,7 +35,6 @@ namespace RJW_Menstruation { AddWombGizmos(__instance, ref gizmoList); } - } @@ -47,7 +46,6 @@ namespace RJW_Menstruation private static void AddWombGizmos(Pawn __instance, ref List gizmoList) { - //HediffComp_Menstruation comp = __instance.health.hediffSet.GetFirstHediffOfDef(Genital_Helper.average_vagina).TryGetComp(); HediffComp_Menstruation comp = Utility.GetMenstruationComp(__instance); if (comp != null) gizmoList.Add(CreateGizmo_WombStatus(__instance, comp)); diff --git a/source/RJW_Menstruation/RJW_Menstruation/HediffComp_Menstruation.cs b/source/RJW_Menstruation/RJW_Menstruation/HediffComp_Menstruation.cs index 33f1d7a..03ca96f 100644 --- a/source/RJW_Menstruation/RJW_Menstruation/HediffComp_Menstruation.cs +++ b/source/RJW_Menstruation/RJW_Menstruation/HediffComp_Menstruation.cs @@ -33,6 +33,7 @@ namespace RJW_Menstruation } } + public class CompProperties_Anus : HediffCompProperties { public string analTex = "Genitals/Anal"; @@ -45,10 +46,10 @@ namespace RJW_Menstruation + - - + public class HediffComp_Menstruation : HediffComp { const float minmakefilthvalue = 1.0f; @@ -57,7 +58,9 @@ namespace RJW_Menstruation public CompProperties_Menstruation Props; public Stage curStage = Stage.Follicular; public int curStageHrs = 0; - + public Action actionref; + public bool loaded = false; + public enum Stage { Follicular, @@ -71,13 +74,11 @@ namespace RJW_Menstruation } private List cums; - private bool loaded = false; private List eggs; private int follicularIntervalhours = -1; private int lutealIntervalhours = -1; private int bleedingIntervalhours = -1; private int recoveryIntervalhours = -1; - private Action actionref; public float TotalCum { @@ -267,22 +268,26 @@ namespace RJW_Menstruation } + public override void CompPostPostAdd(DamageInfo? dinfo) { - Initialize(); + //initializer moved to SpawnSetup + //Initialize(); } public override void CompPostTick(ref float severityAdjustment) { - if (!loaded) - { - Initialize(); - } + //initializer moved to SpawnSetup + //if (!loaded) + //{ + // Initialize(); + //} } public override void CompPostPostRemoved() { + HugsLibController.Instance.TickDelayScheduler.TryUnscheduleCallback(actionref); ModLog.Message(parent.pawn.Label + "tick scheduler removed"); base.CompPostPostRemoved(); @@ -481,7 +486,7 @@ namespace RJW_Menstruation else return false; } - private void Initialize() + public void Initialize() { Props = (CompProperties_Menstruation)props; @@ -511,6 +516,7 @@ namespace RJW_Menstruation curStage = Stage.None; HugsLibController.Instance.TickDelayScheduler.ScheduleCallback(PeriodSimulator(curStage), tickInterval, parent.pawn, false); } + Log.Message(parent.pawn.Label + " - Initialized menstruation comp"); loaded = true; } @@ -741,7 +747,7 @@ namespace RJW_Menstruation }; actionref = action; - return action; + return actionref; void GoNextStage(Stage nextstage, float factor = 1.0f) { @@ -843,4 +849,11 @@ namespace RJW_Menstruation } } + + + + + + + } diff --git a/source/RJW_Menstruation/RJW_Menstruation/Pawn_Patch.cs b/source/RJW_Menstruation/RJW_Menstruation/Pawn_Patch.cs new file mode 100644 index 0000000..2c57493 --- /dev/null +++ b/source/RJW_Menstruation/RJW_Menstruation/Pawn_Patch.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using RimWorld; +using Verse; +using HarmonyLib; +using HugsLib; + + +namespace RJW_Menstruation +{ + + [HarmonyPatch(typeof(Pawn), "SpawnSetup")] + public class Pawn_Patch + { + public static void Postfix(Map map, bool respawningAfterLoad, Pawn __instance) + { + Log.Message("Initialize on spawnsetup"); + HediffComp_Menstruation comp = Utility.GetMenstruationComp(__instance); + if (comp != null) + { + HugsLibController.Instance.TickDelayScheduler.TryUnscheduleCallback(comp.actionref); + comp.Initialize(); + } + } + + + + } +} diff --git a/source/RJW_Menstruation/RJW_Menstruation/RJW_Menstruation.csproj b/source/RJW_Menstruation/RJW_Menstruation/RJW_Menstruation.csproj index 342257d..15845c7 100644 --- a/source/RJW_Menstruation/RJW_Menstruation/RJW_Menstruation.csproj +++ b/source/RJW_Menstruation/RJW_Menstruation/RJW_Menstruation.csproj @@ -64,6 +64,7 @@ + diff --git a/source/RJW_Menstruation/RJW_Menstruation/RJW_Patch.cs b/source/RJW_Menstruation/RJW_Menstruation/RJW_Patch.cs index 894f3ae..5863ac9 100644 --- a/source/RJW_Menstruation/RJW_Menstruation/RJW_Patch.cs +++ b/source/RJW_Menstruation/RJW_Menstruation/RJW_Patch.cs @@ -25,6 +25,7 @@ namespace RJW_Menstruation if (Genital_Helper.has_vagina(partner, partnerparts)) { + if (partner.IsAnimal() && !Configurations.EnableAnimalCycle) return true; HediffComp_Menstruation comp = Utility.GetMenstruationComp(partner); if (comp != null) { @@ -38,6 +39,7 @@ namespace RJW_Menstruation } else if (Genital_Helper.has_vagina(pawn, pawnparts)) { + if (pawn.IsAnimal() && !Configurations.EnableAnimalCycle) return true; HediffComp_Menstruation comp = Utility.GetMenstruationComp(pawn); if (comp != null) { @@ -61,6 +63,7 @@ namespace RJW_Menstruation { public static bool Prefix(Pawn pawn, Pawn partner) // partner has vagina { + if (partner.IsAnimal() && !Configurations.EnableAnimalCycle) return true; HediffComp_Menstruation comp = Utility.GetMenstruationComp(partner); if (comp != null) { diff --git a/source/RJW_Menstruation/RJW_Menstruation/Utility.cs b/source/RJW_Menstruation/RJW_Menstruation/Utility.cs index d246825..d9009bb 100644 --- a/source/RJW_Menstruation/RJW_Menstruation/Utility.cs +++ b/source/RJW_Menstruation/RJW_Menstruation/Utility.cs @@ -21,17 +21,17 @@ namespace RJW_Menstruation public static float GetCumVolume(Pawn pawn) { - CompHediffBodyPart part = Genital_Helper.get_PartsHediffList(pawn, Genital_Helper.get_genitalsBPR(pawn)).FindAll((Hediff hed) => hed.def.defName.ToLower().Contains("penis")).InRandomOrder().FirstOrDefault().TryGetComp(); - if (part == null) part = Genital_Helper.get_PartsHediffList(pawn, Genital_Helper.get_genitalsBPR(pawn)).FindAll((Hediff hed) => hed.def.defName.ToLower().Contains("ovipositorf")).InRandomOrder().FirstOrDefault().TryGetComp(); - if (part == null) part = Genital_Helper.get_PartsHediffList(pawn, Genital_Helper.get_genitalsBPR(pawn)).FindAll((Hediff hed) => hed.def.defName.ToLower().Contains("ovipositorm")).InRandomOrder().FirstOrDefault().TryGetComp(); - if (part == null) part = Genital_Helper.get_PartsHediffList(pawn, Genital_Helper.get_genitalsBPR(pawn)).FindAll((Hediff hed) => hed.def.defName.ToLower().Contains("tentacle")).InRandomOrder().FirstOrDefault().TryGetComp(); + CompHediffBodyPart part = Genital_Helper.get_PartsHediffList(pawn, Genital_Helper.get_genitalsBPR(pawn))?.FindAll((Hediff hed) => hed.def.defName.ToLower().Contains("penis")).InRandomOrder().FirstOrDefault().TryGetComp(); + if (part == null) part = Genital_Helper.get_PartsHediffList(pawn, Genital_Helper.get_genitalsBPR(pawn))?.FindAll((Hediff hed) => hed.def.defName.ToLower().Contains("ovipositorf")).InRandomOrder().FirstOrDefault().TryGetComp(); + if (part == null) part = Genital_Helper.get_PartsHediffList(pawn, Genital_Helper.get_genitalsBPR(pawn))?.FindAll((Hediff hed) => hed.def.defName.ToLower().Contains("ovipositorm")).InRandomOrder().FirstOrDefault().TryGetComp(); + if (part == null) part = Genital_Helper.get_PartsHediffList(pawn, Genital_Helper.get_genitalsBPR(pawn))?.FindAll((Hediff hed) => hed.def.defName.ToLower().Contains("tentacle")).InRandomOrder().FirstOrDefault().TryGetComp(); return part?.FluidAmmount * part.FluidModifier * Rand.Range(0.8f, 1.2f) ?? 0.0f; } public static HediffComp_Menstruation GetMenstruationComp(Pawn pawn) { - var hedifflist = Genital_Helper.get_PartsHediffList(pawn, Genital_Helper.get_genitalsBPR(pawn)).FindAll((Hediff h) => h.def.defName.ToLower().Contains("vagina")); + var hedifflist = Genital_Helper.get_PartsHediffList(pawn, Genital_Helper.get_genitalsBPR(pawn))?.FindAll((Hediff h) => h.def.defName.ToLower().Contains("vagina")); HediffComp_Menstruation result; if (hedifflist.NullOrEmpty()) return null; else