Cut down on some indentation, remove whitespace here and there

This commit is contained in:
lutepickle 2022-07-11 08:21:42 -07:00
parent f585499871
commit 6ec27b6aba
10 changed files with 398 additions and 527 deletions

View file

@ -61,8 +61,7 @@ namespace RJW_Menstruation
{ {
get get
{ {
if (DNAcache == null) if (DNAcache != null) return DNAcache;
{
try try
{ {
DNAcache = pawn.def.GetModExtension<PawnDNAModExtension>(); DNAcache = pawn.def.GetModExtension<PawnDNAModExtension>();
@ -77,8 +76,6 @@ namespace RJW_Menstruation
} }
return DNAcache; return DNAcache;
} }
else return DNAcache;
}
} }
protected PawnDNAModExtension DNAcache = null; protected PawnDNAModExtension DNAcache = null;
public ThingDef FilthDef public ThingDef FilthDef
@ -225,8 +222,8 @@ namespace RJW_Menstruation
public void CumEffects(Pawn pawn) public void CumEffects(Pawn pawn)
{ {
if (!notcum && DNA != null && volume >= 1.0f) if (notcum || DNA == null || volume < 1.0f) return;
{
List<IngestionOutcomeDoer> doers = DNA.ingestionOutcomeDoers; List<IngestionOutcomeDoer> doers = DNA.ingestionOutcomeDoers;
if (!doers.NullOrEmpty()) for (int i = 0; i < doers.Count; i++) if (!doers.NullOrEmpty()) for (int i = 0; i < doers.Count; i++)
@ -234,14 +231,11 @@ namespace RJW_Menstruation
doers[i].DoIngestionOutcome(pawn, CumThing); doers[i].DoIngestionOutcome(pawn, CumThing);
} }
} }
}
protected void CutMinor() protected void CutMinor()
{ {
if (volume < 0.01f) volume = 0f; if (volume < 0.01f) volume = 0f;
} }
} }
public class CumMixture : Cum, IDisposable public class CumMixture : Cum, IDisposable
@ -288,10 +282,5 @@ namespace RJW_Menstruation
} }
return res; return res;
} }
} }
} }

View file

@ -94,8 +94,7 @@ namespace RJW_Menstruation
x.def == VariousDefOf.CameInsideF x.def == VariousDefOf.CameInsideF
|| x.def == VariousDefOf.CameInsideFFetish || x.def == VariousDefOf.CameInsideFFetish
|| x.def == VariousDefOf.HaterCameInsideF); || x.def == VariousDefOf.HaterCameInsideF);
if (!memories.NullOrEmpty()) if (memories.NullOrEmpty()) return;
{
foreach (Thought_Memory m in memories) foreach (Thought_Memory m in memories)
{ {
if (m.def == VariousDefOf.HaterCameInsideF) m.moodPowerFactor = 0.5f; if (m.def == VariousDefOf.HaterCameInsideF) m.moodPowerFactor = 0.5f;
@ -106,9 +105,4 @@ namespace RJW_Menstruation
else pawn.needs.mood.thoughts.memories.TryGainMemoryFast(VariousDefOf.TookContraceptivePill); else pawn.needs.mood.thoughts.memories.TryGainMemoryFast(VariousDefOf.TookContraceptivePill);
} }
} }
}
} }

View file

@ -201,12 +201,12 @@ namespace RJW_Menstruation
{ {
get get
{ {
if (!cums.NullOrEmpty()) foreach (Cum cum in cums) if (cums.NullOrEmpty()) yield return Translations.Info_noCum;
else foreach (Cum cum in cums)
{ {
if (!cum.notcum) yield return String.Format(cum.pawn?.Label + ": {0:0.##}ml", cum.Volume); if (!cum.notcum) yield return String.Format(cum.pawn?.Label + ": {0:0.##}ml", cum.Volume);
else yield return String.Format(cum.notcumLabel + ": {0:0.##}ml", cum.Volume); else yield return String.Format(cum.notcumLabel + ": {0:0.##}ml", cum.Volume);
} }
else yield return Translations.Info_noCum;
} }
} }
public Color GetCumMixtureColor public Color GetCumMixtureColor
@ -215,8 +215,8 @@ namespace RJW_Menstruation
{ {
Color mixedcolor = Color.white; Color mixedcolor = Color.white;
if (!cums.NullOrEmpty()) if (cums.NullOrEmpty()) return mixedcolor;
{
float mixedsofar = 0; float mixedsofar = 0;
foreach (Cum cum in cums) foreach (Cum cum in cums)
{ {
@ -226,7 +226,6 @@ namespace RJW_Menstruation
mixedsofar += cum.Volume; mixedsofar += cum.Volume;
} }
} }
}
return mixedcolor; return mixedcolor;
} }
} }
@ -344,9 +343,9 @@ namespace RJW_Menstruation
{ {
get get
{ {
if (eggs.NullOrEmpty()) return "";
string res = ""; string res = "";
if (!eggs.NullOrEmpty())
{
int fertilized = 0; int fertilized = 0;
foreach (Egg egg in eggs) foreach (Egg egg in eggs)
{ {
@ -362,7 +361,6 @@ namespace RJW_Menstruation
{ {
if (eggs.Count - fertilized != 0) res += eggs.Count - fertilized + " " + Translations.Dialog_WombInfo06; if (eggs.Count - fertilized != 0) res += eggs.Count - fertilized + " " + Translations.Dialog_WombInfo06;
} }
}
return res; return res;
} }
} }
@ -370,16 +368,12 @@ namespace RJW_Menstruation
{ {
get get
{ {
if (!eggs.NullOrEmpty()) if (eggs.NullOrEmpty() || cums.NullOrEmpty()) return false;
{ foreach (Cum cum in cums)
if (!cums.NullOrEmpty()) foreach (Cum cum in cums)
{ {
if (cum.FertVolume > 0) return true; if (cum.FertVolume > 0) return true;
} }
return false; return false;
}
else return false;
} }
} }
/// <summary> /// <summary>
@ -867,8 +861,7 @@ namespace RJW_Menstruation
/// <returns></returns> /// <returns></returns>
protected void FertilizationCheck() protected void FertilizationCheck()
{ {
if (!eggs.NullOrEmpty()) if (eggs.NullOrEmpty()) return;
{
foreach (Egg egg in eggs) foreach (Egg egg in eggs)
{ {
if (!egg.fertilized) egg.fertilizer = Fertilize(); if (!egg.fertilized) egg.fertilizer = Fertilize();
@ -878,14 +871,20 @@ namespace RJW_Menstruation
} }
} }
} }
}
public void Initialize() public void Initialize()
{ {
Props = (CompProperties_Menstruation)props; Props = (CompProperties_Menstruation)props;
if (!Props.infertile) if (Props.infertile)
{ {
if (cums == null) cums = new List<Cum>();
curStage = Stage.None;
HugsLibController.Instance.TickDelayScheduler.ScheduleCallback(PeriodSimulator(curStage), GetNextUpdate(), parent.pawn, false);
loaded = true;
return;
}
if (cycleSpeed < 0f) cycleSpeed = Utility.RandGaussianLike(0.8f, 1.2f); if (cycleSpeed < 0f) cycleSpeed = Utility.RandGaussianLike(0.8f, 1.2f);
if (cycleVariability < 0f) cycleVariability = MenstruationUtility.RandomVariabilityPercent(); if (cycleVariability < 0f) cycleVariability = MenstruationUtility.RandomVariabilityPercent();
if (currentIntervalHours < 0) if (currentIntervalHours < 0)
@ -933,13 +932,6 @@ namespace RJW_Menstruation
if (pregnancy == null && parent.pawn.health.capacities.GetLevel(xxx.reproduction) <= 0) HugsLibController.Instance.TickDelayScheduler.ScheduleCallback(PeriodSimulator(Stage.Young), GetNextUpdate(), parent.pawn, false); if (pregnancy == null && parent.pawn.health.capacities.GetLevel(xxx.reproduction) <= 0) HugsLibController.Instance.TickDelayScheduler.ScheduleCallback(PeriodSimulator(Stage.Young), GetNextUpdate(), parent.pawn, false);
else HugsLibController.Instance.TickDelayScheduler.ScheduleCallback(PeriodSimulator(curStage), GetNextUpdate(), parent.pawn, false); else HugsLibController.Instance.TickDelayScheduler.ScheduleCallback(PeriodSimulator(curStage), GetNextUpdate(), parent.pawn, false);
} }
}
else
{
if (cums == null) cums = new List<Cum>();
curStage = Stage.None;
HugsLibController.Instance.TickDelayScheduler.ScheduleCallback(PeriodSimulator(curStage), GetNextUpdate(), parent.pawn, false);
}
//Log.Message(parent.pawn.Label + " - Initialized menstruation comp"); //Log.Message(parent.pawn.Label + " - Initialized menstruation comp");
loaded = true; loaded = true;
} }
@ -1120,8 +1112,8 @@ namespace RJW_Menstruation
protected bool Implant() protected bool Implant()
{ {
if (!eggs.NullOrEmpty()) if (eggs.NullOrEmpty()) return false;
{
List<Egg> deadeggs = new List<Egg>(); List<Egg> deadeggs = new List<Egg>();
bool pregnant = false; bool pregnant = false;
foreach (Egg egg in eggs) foreach (Egg egg in eggs)
@ -1196,9 +1188,7 @@ namespace RJW_Menstruation
} }
deadeggs.Clear(); deadeggs.Clear();
} }
if (pregnant) return true; return pregnant;
}
return false;
} }
protected void BleedOut() protected void BleedOut()
@ -1229,12 +1219,19 @@ namespace RJW_Menstruation
protected float AbsorbCum(float amount, Absorber absorber) protected float AbsorbCum(float amount, Absorber absorber)
{ {
if (absorber != null) if (absorber == null)
{ {
//if (amount >= minmakefilthvalue) FilthMaker.TryMakeFilth(parent.pawn.Position, parent.pawn.Map, cum.FilthDef, cum.pawn.LabelShort);
return amount;
}
float absorbable = absorber.GetStatValue(VariousDefOf.MaxAbsorbable); float absorbable = absorber.GetStatValue(VariousDefOf.MaxAbsorbable);
absorber.SetColor(Colors.CMYKLerp(GetCumMixtureColor, absorber.DrawColor, 1f - amount / absorbable)); absorber.SetColor(Colors.CMYKLerp(GetCumMixtureColor, absorber.DrawColor, 1f - amount / absorbable));
if (!absorber.dirty) if (absorber.dirty)
{ {
//if (absorber.LeakAfterDirty) FilthMaker.TryMakeFilth(parent.pawn.Position, parent.pawn.Map, cum.FilthDef, cum.pawn.LabelShort);
return amount;
}
absorber.absorbedfluids += amount; absorber.absorbedfluids += amount;
if (absorber.absorbedfluids > absorbable && !parent.pawn.apparel.IsLocked(absorber)) if (absorber.absorbedfluids > absorbable && !parent.pawn.apparel.IsLocked(absorber))
{ {
@ -1242,19 +1239,6 @@ namespace RJW_Menstruation
//absorber.fluidColor = GetCumMixtureColor; //absorber.fluidColor = GetCumMixtureColor;
absorber.dirty = true; absorber.dirty = true;
} }
}
else
{
//if (absorber.LeakAfterDirty) FilthMaker.TryMakeFilth(parent.pawn.Position, parent.pawn.Map, cum.FilthDef, cum.pawn.LabelShort);
return amount;
}
}
else
{
//if (amount >= minmakefilthvalue) FilthMaker.TryMakeFilth(parent.pawn.Position, parent.pawn.Map, cum.FilthDef, cum.pawn.LabelShort);
return amount;
}
return 0; return 0;
} }
@ -1545,8 +1529,8 @@ namespace RJW_Menstruation
protected virtual void ThoughtCumInside(Pawn cummer) protected virtual void ThoughtCumInside(Pawn cummer)
{ {
if (xxx.is_human(parent.pawn) && xxx.is_human(cummer)) if (!xxx.is_human(parent.pawn) || !xxx.is_human(cummer)) return;
{
if ((cummer.Has(Quirk.Teratophile) != (parent.pawn.GetStatValue(StatDefOf.PawnBeauty) >= 0)) || if ((cummer.Has(Quirk.Teratophile) != (parent.pawn.GetStatValue(StatDefOf.PawnBeauty) >= 0)) ||
cummer.Has(Quirk.ImpregnationFetish) || cummer.Has(Quirk.ImpregnationFetish) ||
cummer.Has(Quirk.Breeder)) cummer.Has(Quirk.Breeder))
@ -1596,7 +1580,6 @@ namespace RJW_Menstruation
} }
} }
} }
}
@ -1800,14 +1783,8 @@ namespace RJW_Menstruation
return Stage.Bleeding; return Stage.Bleeding;
default: return Stage.Follicular; default: return Stage.Follicular;
} }
} }
public class Egg : IExposable public class Egg : IExposable
{ {
public bool fertilized; public bool fertilized;
@ -1871,12 +1848,4 @@ namespace RJW_Menstruation
{ {
} }
} }
} }

View file

@ -238,8 +238,8 @@ namespace RJW_Menstruation
public static Texture2D GetAnalIcon(this Pawn pawn, bool drawOrigin = false) public static Texture2D GetAnalIcon(this Pawn pawn, bool drawOrigin = false)
{ {
var hediff = Genital_Helper.get_PartsHediffList(pawn, Genital_Helper.get_anusBPR(pawn)).FirstOrDefault((Hediff h) => h.def.defName.ToLower().Contains("anus")); var hediff = Genital_Helper.get_PartsHediffList(pawn, Genital_Helper.get_anusBPR(pawn)).FirstOrDefault((Hediff h) => h.def.defName.ToLower().Contains("anus"));
if (hediff != null) if (hediff == null) return ContentFinder<Texture2D>.Get(("Genitals/Anal00"), true);
{
string icon; string icon;
float severity; float severity;
HediffComp_Anus comp = hediff.GetAnusComp(); HediffComp_Anus comp = hediff.GetAnusComp();
@ -264,11 +264,6 @@ namespace RJW_Menstruation
return ContentFinder<Texture2D>.Get((icon), true); return ContentFinder<Texture2D>.Get((icon), true);
} }
else
{
return ContentFinder<Texture2D>.Get(("Genitals/Anal00"), true);
}
}
public static float GestationHours(this Hediff_BasePregnancy hediff) public static float GestationHours(this Hediff_BasePregnancy hediff)
{ {

View file

@ -17,10 +17,12 @@ namespace RJW_Menstruation
protected void PregnancyThought() protected void PregnancyThought()
{ {
if (!is_discovered && xxx.is_human(pawn)) if (is_discovered ||
{ !xxx.is_human(pawn) ||
if (!pawn.Has(Quirk.Breeder) && pawn.relations?.DirectRelations?.Find(x => x.def.Equals(PawnRelationDefOf.Spouse) || x.def.Equals(PawnRelationDefOf.Fiance)) == null) pawn.Has(Quirk.Breeder) ||
{ (pawn.relations?.DirectRelations?.Find(x => x.def.Equals(PawnRelationDefOf.Spouse) ||
x.def.Equals(PawnRelationDefOf.Fiance))) != null)
return;
if (pawn.Has(Quirk.ImpregnationFetish) || pawn.relations?.DirectRelations?.Find(x => x.def.Equals(PawnRelationDefOf.Lover)) != null) if (pawn.Has(Quirk.ImpregnationFetish) || pawn.relations?.DirectRelations?.Find(x => x.def.Equals(PawnRelationDefOf.Lover)) != null)
{ {
pawn.needs.mood.thoughts.memories.TryGainMemory(VariousDefOf.UnwantedPregnancyMild); pawn.needs.mood.thoughts.memories.TryGainMemory(VariousDefOf.UnwantedPregnancyMild);
@ -31,9 +33,6 @@ namespace RJW_Menstruation
} }
} }
}
}
public override void GiveBirth() public override void GiveBirth()
{ {
@ -67,9 +66,11 @@ namespace RJW_Menstruation
public string GetBabyInfo() public string GetBabyInfo()
{ {
if (babies.NullOrEmpty())
return "Null";
string res = ""; string res = "";
if (!babies.NullOrEmpty())
{
var babiesdistinct = babies.Distinct(new RaceComparer()); var babiesdistinct = babies.Distinct(new RaceComparer());
int iteration = 0; int iteration = 0;
foreach (Pawn baby in babiesdistinct) foreach (Pawn baby in babiesdistinct)
@ -82,8 +83,6 @@ namespace RJW_Menstruation
res += " " + Translations.Dialog_WombInfo02; res += " " + Translations.Dialog_WombInfo02;
return res; return res;
} }
return "Null";
}
public string GetFatherInfo() public string GetFatherInfo()
{ {
@ -295,8 +294,8 @@ namespace RJW_Menstruation
protected void Train(Pawn baby, Pawn mother) protected void Train(Pawn baby, Pawn mother)
{ {
if (!xxx.is_human(baby) && baby.Faction == Faction.OfPlayer) if (xxx.is_human(baby) || baby.Faction != Faction.OfPlayer) return;
{
if (xxx.is_human(mother) && baby.Faction == Faction.OfPlayer && baby.training.CanAssignToTrain(TrainableDefOf.Obedience, out _).Accepted) if (xxx.is_human(mother) && baby.Faction == Faction.OfPlayer && baby.training.CanAssignToTrain(TrainableDefOf.Obedience, out _).Accepted)
{ {
baby.training.Train(TrainableDefOf.Obedience, mother); baby.training.Train(TrainableDefOf.Obedience, mother);
@ -306,7 +305,6 @@ namespace RJW_Menstruation
baby.training.Train(TrainableDefOf.Tameness, mother); baby.training.Train(TrainableDefOf.Tameness, mother);
} }
} }
}
public bool AddNewBaby(Pawn mother, Pawn father) public bool AddNewBaby(Pawn mother, Pawn father)
@ -421,18 +419,18 @@ namespace RJW_Menstruation
public Pawn GenerateBaby(PawnGenerationRequest request, Pawn mother, Pawn father, List<Trait> parentTraits, int traitSeed) public Pawn GenerateBaby(PawnGenerationRequest request, Pawn mother, Pawn father, List<Trait> parentTraits, int traitSeed)
{ {
Pawn baby = PawnGenerator.GeneratePawn(request); Pawn baby = PawnGenerator.GeneratePawn(request);
if (baby != null) if (baby == null)
{ {
Log.Error("Baby not generated. Request: " + request.ToString());
return null;
}
if (xxx.is_human(baby) || (baby.relations != null && !RJWSettings.Disable_bestiality_pregnancy_relations)) if (xxx.is_human(baby) || (baby.relations != null && !RJWSettings.Disable_bestiality_pregnancy_relations))
{ {
baby.SetMother(mother); baby.SetMother(mother);
if (mother != father) if (mother != father)
{ {
if (father.gender != Gender.Female) baby.SetFather(father); if (father.gender != Gender.Female) baby.SetFather(father);
else else baby.relations.AddDirectRelation(PawnRelationDefOf.Parent, father);
{
baby.relations.AddDirectRelation(PawnRelationDefOf.Parent, father);
}
} }
} }
if (xxx.is_human(baby)) if (xxx.is_human(baby))
@ -443,8 +441,6 @@ namespace RJW_Menstruation
UpdateTraits(baby, parentTraits); UpdateTraits(baby, parentTraits);
Rand.PopState(); Rand.PopState();
} }
}
else Log.Error("Baby not generated. Request: " + request.ToString());
return baby; return baby;
} }
@ -568,9 +564,6 @@ namespace RJW_Menstruation
if (!spawn_kind_def_list.NullOrEmpty()) spawn_kind_def = spawn_kind_def_list.RandomElement(); if (!spawn_kind_def_list.NullOrEmpty()) spawn_kind_def = spawn_kind_def_list.RandomElement();
} }
return spawn_kind_def; return spawn_kind_def;
} }

View file

@ -86,9 +86,12 @@ namespace RJW_Menstruation
{ {
if (partner.IsAnimal() && !Configurations.EnableAnimalCycle) return true; if (partner.IsAnimal() && !Configurations.EnableAnimalCycle) return true;
HediffComp_Menstruation comp = partner.GetMenstruationComp(); HediffComp_Menstruation comp = partner.GetMenstruationComp();
if (comp != null) if (comp == null)
{ {
if (AndroidsCompatibility.IsAndroid(pawn) && !AndroidsCompatibility.AndroidPenisFertility(pawn)) ModLog.Message("used original rjw method: Comp missing");
return true;
}
else if (AndroidsCompatibility.IsAndroid(pawn) && !AndroidsCompatibility.AndroidPenisFertility(pawn))
{ {
comp.CumIn(pawn, pawn.GetCumVolume(), 0); comp.CumIn(pawn, pawn.GetCumVolume(), 0);
return false; return false;
@ -96,9 +99,6 @@ namespace RJW_Menstruation
else comp.CumIn(pawn, pawn.GetCumVolume(), pawn.health.capacities.GetLevel(xxx.reproduction)); else comp.CumIn(pawn, pawn.GetCumVolume(), pawn.health.capacities.GetLevel(xxx.reproduction));
return false; return false;
} }
ModLog.Message("used original rjw method: Comp missing");
return true;
}
} }
[HarmonyPatch(typeof(Hediff_BasePregnancy), nameof(Hediff_BasePregnancy.PostBirth))] [HarmonyPatch(typeof(Hediff_BasePregnancy), nameof(Hediff_BasePregnancy.PostBirth))]

View file

@ -20,10 +20,7 @@ namespace RJW_Menstruation
public HybridExtension GetHybridExtension(string race) public HybridExtension GetHybridExtension(string race)
{ {
if (hybridExtension.NullOrEmpty()) return null; if (hybridExtension.NullOrEmpty()) return null;
else else return hybridExtension.Find(x => x.thingDef.defName.Equals(race));
{
return hybridExtension.Find(x => x.thingDef.defName.Equals(race));
}
} }
public PawnKindDef GetHybridWith(string race) public PawnKindDef GetHybridWith(string race)
@ -75,13 +72,7 @@ namespace RJW_Menstruation
#endif #endif
hybridInfo.Add(node.Name, ParseHelper.FromString<float>(node.InnerText)); hybridInfo.Add(node.Name, ParseHelper.FromString<float>(node.InnerText));
} }
} }
} }
public class HybridInformations : IExposable public class HybridInformations : IExposable
@ -145,9 +136,6 @@ namespace RJW_Menstruation
Scribe_Values.Look(ref thingDefName, "thingDefName"); Scribe_Values.Look(ref thingDefName, "thingDefName");
Scribe_Collections.Look(ref hybridExtension, "hybridExtension", LookMode.Deep, new object[0]); Scribe_Collections.Look(ref hybridExtension, "hybridExtension", LookMode.Deep, new object[0]);
} }
} }
public class HybridExtensionExposable : HybridExtension, IExposable public class HybridExtensionExposable : HybridExtension, IExposable
@ -197,10 +185,6 @@ namespace RJW_Menstruation
} }
} }
public class AbsorberModExtension : DefModExtension public class AbsorberModExtension : DefModExtension
{ {
public bool leakAfterDirty = false; public bool leakAfterDirty = false;
@ -222,8 +206,6 @@ namespace RJW_Menstruation
public Color fluidColor = Color.white; public Color fluidColor = Color.white;
public virtual void DirtyEffect() { } public virtual void DirtyEffect() { }
public virtual void WearEffect() public virtual void WearEffect()
@ -299,13 +281,5 @@ namespace RJW_Menstruation
color = value; color = value;
} }
} }
} }
} }

View file

@ -29,23 +29,16 @@ namespace RJW_Menstruation
if (!VariousDefOf.AllRaces.NullOrEmpty()) if (!VariousDefOf.AllRaces.NullOrEmpty())
foreach(ThingDef def in VariousDefOf.AllRaces) foreach(ThingDef def in VariousDefOf.AllRaces)
{ {
if (def.race != null) if (def.race == null || Configurations.IsOverrideExist(def)) continue;
{
if (Configurations.IsOverrideExist(def)) continue;
else
{
raceList.Add(new FloatMenuOption(def.label, delegate { AddHybridOverride(def); }, def.uiIcon, Color.white)); raceList.Add(new FloatMenuOption(def.label, delegate { AddHybridOverride(def); }, def.uiIcon, Color.white));
} }
}
}
raceList.SortBy(x => x.Label); raceList.SortBy(x => x.Label);
} }
public void AddHybridOverride(ThingDef def) public void AddHybridOverride(ThingDef def)
{ {
FloatMenuOption option = raceList.FirstOrDefault(x => x.Label.Equals(def?.label)); FloatMenuOption option = raceList.FirstOrDefault(x => x.Label.Equals(def?.label));
if (option != null) if (option == null) return;
{
raceList.Remove(option); raceList.Remove(option);
if (Configurations.HybridOverride.NullOrEmpty()) if (Configurations.HybridOverride.NullOrEmpty())
{ {
@ -53,7 +46,6 @@ namespace RJW_Menstruation
} }
Configurations.HybridOverride.Add(new HybridInformations(def)); Configurations.HybridOverride.Add(new HybridInformations(def));
Configurations.HybridOverride.SortBy(x => x.GetDef?.label ?? "Undefined"); Configurations.HybridOverride.SortBy(x => x.GetDef?.label ?? "Undefined");
}
} }
@ -279,7 +271,8 @@ namespace RJW_Menstruation
protected void BuildRaceList() protected void BuildRaceList()
{ {
raceList.Clear(); raceList.Clear();
if (!VariousDefOf.AllRaces.NullOrEmpty()) if (VariousDefOf.AllRaces.NullOrEmpty()) return;
foreach (ThingDef def in VariousDefOf.AllRaces) foreach (ThingDef def in VariousDefOf.AllRaces)
{ {
if (def.race != null) if (def.race != null)

View file

@ -97,14 +97,11 @@ namespace RJW_Menstruation
var hedifflist = Genital_Helper.get_PartsHediffList(pawn, Genital_Helper.get_breastsBPR(pawn))?.FindAll((Hediff h) => h is Hediff_PartBaseNatural || h is Hediff_PartBaseArtifical); var hedifflist = Genital_Helper.get_PartsHediffList(pawn, Genital_Helper.get_breastsBPR(pawn))?.FindAll((Hediff h) => h is Hediff_PartBaseNatural || h is Hediff_PartBaseArtifical);
HediffComp_Breast result; HediffComp_Breast result;
if (hedifflist.NullOrEmpty()) return null; if (hedifflist.NullOrEmpty()) return null;
else
{
foreach(Hediff h in hedifflist) foreach(Hediff h in hedifflist)
{ {
result = h.TryGetComp<HediffComp_Breast>(); result = h.TryGetComp<HediffComp_Breast>();
if (result != null) return result; if (result != null) return result;
} }
}
return null; return null;
} }
@ -128,24 +125,19 @@ namespace RJW_Menstruation
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 false; if (hedifflist.NullOrEmpty()) return false;
else
{
foreach (Hediff h in hedifflist) foreach (Hediff h in hedifflist)
{ {
result = h.TryGetComp<HediffComp_Menstruation>(); result = h.TryGetComp<HediffComp_Menstruation>();
if (result != null) return true; if (result != null) return true;
} }
}
return false; return false;
} }
public static bool HasMenstruationComp(this Hediff hediff) public static bool HasMenstruationComp(this Hediff hediff)
{ {
if (hediff is Hediff_PartBaseNatural || hediff is Hediff_PartBaseArtifical) if ((hediff is Hediff_PartBaseNatural || hediff is Hediff_PartBaseArtifical) && hediff.TryGetComp<HediffComp_Menstruation>() != null)
{ return true;
if (hediff.TryGetComp<HediffComp_Menstruation>() != null) return true; else return false;
}
return false;
} }
@ -299,8 +291,7 @@ namespace RJW_Menstruation
milkcomp = pawn.GetComp<CompMilkable>(); milkcomp = pawn.GetComp<CompMilkable>();
} }
if (milkcomp != null) if (milkcomp == null) return;
{
if (milkcomp is CompMilkable milkable) if (milkcomp is CompMilkable milkable)
{ {
bool active = (bool)milkcomp.GetPropertyValue("Active"); bool active = (bool)milkcomp.GetPropertyValue("Active");
@ -324,14 +315,13 @@ namespace RJW_Menstruation
} }
} }
} }
}
public static void DrawMilkBottle(Rect rect, Pawn pawn, JobDef milkjob,float fullness) public static void DrawMilkBottle(Rect rect, Pawn pawn, JobDef milkjob,float fullness)
{ {
Texture2D texture; Texture2D texture;
Rect buttonrect = new Rect(rect.x, rect.y, rect.height, rect.height); Rect buttonrect = new Rect(rect.x, rect.y, rect.height, rect.height);
if (fullness > 0.0f) if (fullness <= 0.0f) return;
{
if (fullness < 0.3f) texture = ContentFinder<Texture2D>.Get("Milk/Milkbottle_Small", false); if (fullness < 0.3f) texture = ContentFinder<Texture2D>.Get("Milk/Milkbottle_Small", false);
else if (fullness < 0.7f) texture = ContentFinder<Texture2D>.Get("Milk/Milkbottle_Medium", false); else if (fullness < 0.7f) texture = ContentFinder<Texture2D>.Get("Milk/Milkbottle_Medium", false);
else texture = ContentFinder<Texture2D>.Get("Milk/Milkbottle_Large", false); else texture = ContentFinder<Texture2D>.Get("Milk/Milkbottle_Large", false);
@ -354,7 +344,6 @@ namespace RJW_Menstruation
} }
Widgets.DrawHighlightIfMouseover(buttonrect); Widgets.DrawHighlightIfMouseover(buttonrect);
} }
}
public static string GetVaginaLabel(this Pawn pawn) public static string GetVaginaLabel(this Pawn pawn)
@ -452,20 +441,7 @@ namespace RJW_Menstruation
public static bool ShouldShowWombGizmo(this Pawn pawn) public static bool ShouldShowWombGizmo(this Pawn pawn)
{ {
return Configurations.EnableWombIcon && (!pawn.IsAnimal() || Configurations.EnableAnimalCycle);
if (Configurations.EnableWombIcon)
{
if (!pawn.IsAnimal())
{
return true;
}
else if (Configurations.EnableAnimalCycle)
{
return true;
} }
} }
return false;
}
}
} }

View file

@ -55,12 +55,10 @@ namespace RJW_Menstruation
{ {
get get
{ {
if (allraces == null) if (allraces != null) return allraces;
{
List<ThingDef> allThings = DefDatabase<ThingDef>.AllDefsListForReading; List<ThingDef> allThings = DefDatabase<ThingDef>.AllDefsListForReading;
allraces = allThings.FindAll(x => x.race != null && x.race.IsFlesh); allraces = allThings.FindAll(x => x.race != null && x.race.IsFlesh);
}
return allraces; return allraces;
} }
} }
@ -68,29 +66,19 @@ namespace RJW_Menstruation
{ {
get get
{ {
if (allkinds == null) if (allkinds != null) return allkinds;
{
List<PawnKindDef> allKinds = DefDatabase<PawnKindDef>.AllDefsListForReading; List<PawnKindDef> allKinds = DefDatabase<PawnKindDef>.AllDefsListForReading;
allkinds = allKinds.FindAll(x => x.race != null); allkinds = allKinds.FindAll(x => x.race != null);
}
return allkinds; return allkinds;
} }
} }
// Defs from Milkable Colonists // Defs from Milkable Colonists
public static readonly HediffDef Hediff_Lactating_Drug = DefDatabase<HediffDef>.GetNamedSilentFail("Lactating_Drug"); public static readonly HediffDef Hediff_Lactating_Drug = DefDatabase<HediffDef>.GetNamedSilentFail("Lactating_Drug");
public static readonly HediffDef Hediff_Lactating_Natural = DefDatabase<HediffDef>.GetNamedSilentFail("Lactating_Natural"); public static readonly HediffDef Hediff_Lactating_Natural = DefDatabase<HediffDef>.GetNamedSilentFail("Lactating_Natural");
public static readonly HediffDef Hediff_Lactating_Permanent = DefDatabase<HediffDef>.GetNamedSilentFail("Lactating_Permanent"); public static readonly HediffDef Hediff_Lactating_Permanent = DefDatabase<HediffDef>.GetNamedSilentFail("Lactating_Permanent");
public static readonly HediffDef Hediff_Heavy_Lactating_Permanent = DefDatabase<HediffDef>.GetNamedSilentFail("Heavy_Lactating_Permanent"); public static readonly HediffDef Hediff_Heavy_Lactating_Permanent = DefDatabase<HediffDef>.GetNamedSilentFail("Heavy_Lactating_Permanent");
public static readonly JobDef Job_LactateSelf_MC = DefDatabase<JobDef>.GetNamedSilentFail("LactateSelf_MC"); public static readonly JobDef Job_LactateSelf_MC = DefDatabase<JobDef>.GetNamedSilentFail("LactateSelf_MC");
} }
} }