changed initialize method

This commit is contained in:
moreoreganostodump 2021-02-03 14:20:03 +09:00
parent 3201cc7328
commit 82570419a2
9 changed files with 109 additions and 20 deletions

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Manifest> <Manifest>
<identifier>RJW Menstruation</identifier> <identifier>RJW Menstruation</identifier>
<version>1.0.0.1</version> <version>1.0.0.3</version>
<dependencies> <dependencies>
</dependencies> </dependencies>
<incompatibleWith /> <incompatibleWith />

Binary file not shown.

View file

@ -27,6 +27,48 @@
</value> </value>
</Operation> </Operation>
<Operation Class="PatchOperationAdd">
<xpath>Defs/rjw.HediffDef_PartBase[defName="DragonVagina"]</xpath>
<value>
<comps>
<li Class="RJW_Menstruation.CompProperties_Menstruation">
<maxCumCapacity>500</maxCumCapacity>
<baseImplantationChanceFactor>0.5</baseImplantationChanceFactor>
<basefertilizationChanceFactor>0.2</basefertilizationChanceFactor>
<deviationFactor>0.05</deviationFactor>
<folicularIntervalDays>30</folicularIntervalDays>
<lutealIntervalDays>30</lutealIntervalDays>
<bleedingIntervalDays>0</bleedingIntervalDays>
<recoveryIntervalDays>10</recoveryIntervalDays>
<eggLifespanDays>30</eggLifespanDays>
<wombTex>Womb/Womb</wombTex>
<vagTex>Genitals/Vagina</vagTex>
</li>
</comps>
</value>
</Operation>
<Operation Class="PatchOperationAdd">
<xpath>Defs/rjw.HediffDef_PartBase[defName="GenericVagina"]</xpath>
<value>
<comps>
<li Class="RJW_Menstruation.CompProperties_Menstruation">
<maxCumCapacity>500</maxCumCapacity>
<baseImplantationChanceFactor>1.0</baseImplantationChanceFactor>
<basefertilizationChanceFactor>1.0</basefertilizationChanceFactor>
<deviationFactor>0.05</deviationFactor>
<folicularIntervalDays>14</folicularIntervalDays>
<lutealIntervalDays>14</lutealIntervalDays>
<bleedingIntervalDays>6</bleedingIntervalDays>
<recoveryIntervalDays>10</recoveryIntervalDays>
<eggLifespanDays>3</eggLifespanDays>
<wombTex>Womb/Womb</wombTex>
<vagTex>Genitals/Vagina</vagTex>
</li>
</comps>
</value>
</Operation>
<Operation Class="PatchOperationAdd"> <Operation Class="PatchOperationAdd">
<xpath>Defs/rjw.HediffDef_PartBase[defName="HydraulicVagina"]</xpath> <xpath>Defs/rjw.HediffDef_PartBase[defName="HydraulicVagina"]</xpath>
<value> <value>

View file

@ -35,7 +35,6 @@ namespace RJW_Menstruation
{ {
AddWombGizmos(__instance, ref gizmoList); AddWombGizmos(__instance, ref gizmoList);
} }
} }
@ -47,7 +46,6 @@ namespace RJW_Menstruation
private static void AddWombGizmos(Pawn __instance, ref List<Gizmo> gizmoList) private static void AddWombGizmos(Pawn __instance, ref List<Gizmo> gizmoList)
{ {
//HediffComp_Menstruation comp = __instance.health.hediffSet.GetFirstHediffOfDef(Genital_Helper.average_vagina).TryGetComp<HediffComp_Menstruation>();
HediffComp_Menstruation comp = Utility.GetMenstruationComp(__instance); HediffComp_Menstruation comp = Utility.GetMenstruationComp(__instance);
if (comp != null) gizmoList.Add(CreateGizmo_WombStatus(__instance, comp)); if (comp != null) gizmoList.Add(CreateGizmo_WombStatus(__instance, comp));

View file

@ -33,6 +33,7 @@ namespace RJW_Menstruation
} }
} }
public class CompProperties_Anus : HediffCompProperties public class CompProperties_Anus : HediffCompProperties
{ {
public string analTex = "Genitals/Anal"; public string analTex = "Genitals/Anal";
@ -45,10 +46,10 @@ namespace RJW_Menstruation
public class HediffComp_Menstruation : HediffComp public class HediffComp_Menstruation : HediffComp
{ {
const float minmakefilthvalue = 1.0f; const float minmakefilthvalue = 1.0f;
@ -57,7 +58,9 @@ namespace RJW_Menstruation
public CompProperties_Menstruation Props; public CompProperties_Menstruation Props;
public Stage curStage = Stage.Follicular; public Stage curStage = Stage.Follicular;
public int curStageHrs = 0; public int curStageHrs = 0;
public Action actionref;
public bool loaded = false;
public enum Stage public enum Stage
{ {
Follicular, Follicular,
@ -71,13 +74,11 @@ namespace RJW_Menstruation
} }
private List<Cum> cums; private List<Cum> cums;
private bool loaded = false;
private List<Egg> eggs; private List<Egg> eggs;
private int follicularIntervalhours = -1; private int follicularIntervalhours = -1;
private int lutealIntervalhours = -1; private int lutealIntervalhours = -1;
private int bleedingIntervalhours = -1; private int bleedingIntervalhours = -1;
private int recoveryIntervalhours = -1; private int recoveryIntervalhours = -1;
private Action actionref;
public float TotalCum public float TotalCum
{ {
@ -267,22 +268,26 @@ namespace RJW_Menstruation
} }
public override void CompPostPostAdd(DamageInfo? dinfo) public override void CompPostPostAdd(DamageInfo? dinfo)
{ {
Initialize(); //initializer moved to SpawnSetup
//Initialize();
} }
public override void CompPostTick(ref float severityAdjustment) public override void CompPostTick(ref float severityAdjustment)
{ {
if (!loaded) //initializer moved to SpawnSetup
{ //if (!loaded)
Initialize(); //{
} // Initialize();
//}
} }
public override void CompPostPostRemoved() public override void CompPostPostRemoved()
{ {
HugsLibController.Instance.TickDelayScheduler.TryUnscheduleCallback(actionref); HugsLibController.Instance.TickDelayScheduler.TryUnscheduleCallback(actionref);
ModLog.Message(parent.pawn.Label + "tick scheduler removed"); ModLog.Message(parent.pawn.Label + "tick scheduler removed");
base.CompPostPostRemoved(); base.CompPostPostRemoved();
@ -481,7 +486,7 @@ namespace RJW_Menstruation
else return false; else return false;
} }
private void Initialize() public void Initialize()
{ {
Props = (CompProperties_Menstruation)props; Props = (CompProperties_Menstruation)props;
@ -511,6 +516,7 @@ namespace RJW_Menstruation
curStage = Stage.None; curStage = Stage.None;
HugsLibController.Instance.TickDelayScheduler.ScheduleCallback(PeriodSimulator(curStage), tickInterval, parent.pawn, false); HugsLibController.Instance.TickDelayScheduler.ScheduleCallback(PeriodSimulator(curStage), tickInterval, parent.pawn, false);
} }
Log.Message(parent.pawn.Label + " - Initialized menstruation comp");
loaded = true; loaded = true;
} }
@ -741,7 +747,7 @@ namespace RJW_Menstruation
}; };
actionref = action; actionref = action;
return action; return actionref;
void GoNextStage(Stage nextstage, float factor = 1.0f) void GoNextStage(Stage nextstage, float factor = 1.0f)
{ {
@ -843,4 +849,11 @@ namespace RJW_Menstruation
} }
} }
} }

View file

@ -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();
}
}
}
}

View file

@ -64,6 +64,7 @@
<Compile Include="Gizmo_Womb.cs" /> <Compile Include="Gizmo_Womb.cs" />
<Compile Include="Harmony.cs" /> <Compile Include="Harmony.cs" />
<Compile Include="HediffComp_Menstruation.cs" /> <Compile Include="HediffComp_Menstruation.cs" />
<Compile Include="Pawn_Patch.cs" />
<Compile Include="RJW_Patch.cs" /> <Compile Include="RJW_Patch.cs" />
<Compile Include="Translations.cs" /> <Compile Include="Translations.cs" />
<Compile Include="Utility.cs" /> <Compile Include="Utility.cs" />

View file

@ -25,6 +25,7 @@ namespace RJW_Menstruation
if (Genital_Helper.has_vagina(partner, partnerparts)) if (Genital_Helper.has_vagina(partner, partnerparts))
{ {
if (partner.IsAnimal() && !Configurations.EnableAnimalCycle) return true;
HediffComp_Menstruation comp = Utility.GetMenstruationComp(partner); HediffComp_Menstruation comp = Utility.GetMenstruationComp(partner);
if (comp != null) if (comp != null)
{ {
@ -38,6 +39,7 @@ namespace RJW_Menstruation
} }
else if (Genital_Helper.has_vagina(pawn, pawnparts)) else if (Genital_Helper.has_vagina(pawn, pawnparts))
{ {
if (pawn.IsAnimal() && !Configurations.EnableAnimalCycle) return true;
HediffComp_Menstruation comp = Utility.GetMenstruationComp(pawn); HediffComp_Menstruation comp = Utility.GetMenstruationComp(pawn);
if (comp != null) if (comp != null)
{ {
@ -61,6 +63,7 @@ namespace RJW_Menstruation
{ {
public static bool Prefix(Pawn pawn, Pawn partner) // partner has vagina public static bool Prefix(Pawn pawn, Pawn partner) // partner has vagina
{ {
if (partner.IsAnimal() && !Configurations.EnableAnimalCycle) return true;
HediffComp_Menstruation comp = Utility.GetMenstruationComp(partner); HediffComp_Menstruation comp = Utility.GetMenstruationComp(partner);
if (comp != null) if (comp != null)
{ {

View file

@ -21,17 +21,17 @@ namespace RJW_Menstruation
public static float GetCumVolume(Pawn pawn) 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<rjw.CompHediffBodyPart>(); CompHediffBodyPart part = Genital_Helper.get_PartsHediffList(pawn, Genital_Helper.get_genitalsBPR(pawn))?.FindAll((Hediff hed) => hed.def.defName.ToLower().Contains("penis")).InRandomOrder().FirstOrDefault().TryGetComp<rjw.CompHediffBodyPart>();
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<rjw.CompHediffBodyPart>(); 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<rjw.CompHediffBodyPart>();
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<rjw.CompHediffBodyPart>(); 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<rjw.CompHediffBodyPart>();
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<rjw.CompHediffBodyPart>(); 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<rjw.CompHediffBodyPart>();
return part?.FluidAmmount * part.FluidModifier * Rand.Range(0.8f, 1.2f) ?? 0.0f; return part?.FluidAmmount * part.FluidModifier * Rand.Range(0.8f, 1.2f) ?? 0.0f;
} }
public static HediffComp_Menstruation GetMenstruationComp(Pawn pawn) 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; HediffComp_Menstruation result;
if (hedifflist.NullOrEmpty()) return null; if (hedifflist.NullOrEmpty()) return null;
else else