A whole mess of suggested code refactorings

This commit is contained in:
lutepickle 2022-03-18 07:31:17 -07:00
parent 9e8441ca2e
commit 3ae66bd4a6
22 changed files with 123 additions and 141 deletions

Binary file not shown.

View File

@ -47,7 +47,7 @@ namespace MilkModule
public static HumanCompHasGatherableBodyResource GetMilkComp(Pawn pawn)
{
HumanCompHasGatherableBodyResource result = null;
HumanCompHasGatherableBodyResource result;
if (pawn.health.hediffSet.HasHediff(VariousDefOf.Hediff_Heavy_Lactating_Permanent))
{
result = pawn.TryGetComp<CompHyperMilkableHuman>();

View File

@ -26,9 +26,8 @@ namespace MilkModule
{
public static void Postfix(Pawn doer, HumanCompHasGatherableBodyResource __instance)
{
Pawn pawn = __instance.parent as Pawn;
HediffComp_Breast comp = null;
if (pawn != null) comp = pawn.GetBreastComp();
if (__instance.parent is Pawn pawn) comp = pawn.GetBreastComp();
if (comp != null)
{
comp.AdjustAreolaSize(Rand.Range(0.0f, 0.01f * Configurations.NipplePermanentTransitionVariance));

View File

@ -142,7 +142,7 @@ namespace RJW_Menstruation
foreach(HybridInformations o in HybridOverride)
{
if (o.IsNull) removeList.Add(o);
if (o.defName == def.defName) return true;
if (o.DefName == def.defName) return true;
}
if (!removeList.NullOrEmpty())
{
@ -216,7 +216,6 @@ namespace RJW_Menstruation
public class RJW_Menstruation : Mod
{
private readonly Configurations config;
private static Vector2 scroll;
@ -234,7 +233,6 @@ namespace RJW_Menstruation
{
get
{
int days = VariousDefOf.VaginaCompProperties.bleedingIntervalDays;
return 0.03f * Configurations.BleedingAmount * Configurations.CycleAcceleration;
}
}
@ -242,7 +240,7 @@ namespace RJW_Menstruation
public RJW_Menstruation(ModContentPack content) : base(content)
{
config = GetSettings<Configurations>();
GetSettings<Configurations>();
Configurations.HARActivated = ModLister.HasActiveModWithName("Humanoid Alien Races 2.0");
Configurations.LLActivated = ModLister.HasActiveModWithName("RimJobWorld - Licentia Labs");
}
@ -259,8 +257,10 @@ namespace RJW_Menstruation
Rect outRect = new Rect(0f, 30f, inRect.width, inRect.height - 30f);
Rect mainRect = new Rect(0f, 0f, inRect.width - 30f, inRect.height + 596f);
int Adjust;
Listing_Standard listmain = new Listing_Standard();
listmain.maxOneColumn = true;
Listing_Standard listmain = new Listing_Standard
{
maxOneColumn = true
};
Widgets.BeginScrollView(outRect, ref scroll, mainRect);
listmain.Begin(mainRect);
listmain.Gap(20f);

View File

@ -44,7 +44,7 @@ namespace RJW_Menstruation
}
}
public float decayresist
public float DecayResist
{
get
{
@ -95,7 +95,7 @@ namespace RJW_Menstruation
}
}
protected ThingDef filthDef = null;
public Color color
public Color Color
{
get
{
@ -180,7 +180,7 @@ namespace RJW_Menstruation
public void MakeThinner(int speed)
{
cumthickness = cumthickness.LerpMultiple(decayresist, 0.3f, speed);
cumthickness = cumthickness.LerpMultiple(DecayResist, 0.3f, speed);
}
public void MergeWithCum(float volumein, float fertility, ThingDef updatefilthDef = null)
@ -208,8 +208,8 @@ namespace RJW_Menstruation
public float DismishNatural(float leakfactor, float antisperm = 0.0f)
{
float totalleak = volume;
volume *= Math.Max(0, (1 - (Configurations.CumDecayRatio * (1 - decayresist)) * leakfactor));
fertvolume *= Math.Max(0, 1 - (Configurations.CumFertilityDecayRatio * (1 - decayresist) + antisperm));
volume *= Math.Max(0, (1 - (Configurations.CumDecayRatio * (1 - DecayResist)) * leakfactor));
fertvolume *= Math.Max(0, 1 - (Configurations.CumFertilityDecayRatio * (1 - DecayResist) + antisperm));
CutMinor();
totalleak -= volume;
return totalleak;
@ -218,8 +218,8 @@ namespace RJW_Menstruation
public float DismishForce(float portion, float leakfactor = 1.0f)
{
float totalleak = volume;
volume *= Math.Max(0, 1 - (portion * (1 - decayresist/10)) * leakfactor);
fertvolume *= Math.Max(0, 1 - (portion * (1 - decayresist)) * leakfactor);
volume *= Math.Max(0, 1 - (portion * (1 - DecayResist/10)) * leakfactor);
fertvolume *= Math.Max(0, 1 - (portion * (1 - DecayResist)) * leakfactor);
CutMinor();
totalleak -= volume;
return totalleak;

View File

@ -95,13 +95,13 @@ namespace RJW_Menstruation
public static readonly Dictionary<Stage, Texture2D> StageTexture = new Dictionary<Stage, Texture2D>()
{
{ Stage.Follicular, TextureCache.humanTexture },
{ Stage.ClimactericFollicular, TextureCache.humanTexture },
{ Stage.Luteal, TextureCache.fertilityTexture },
{ Stage.ClimactericLuteal, TextureCache.fertilityTexture },
{ Stage.Bleeding, TextureCache.khorneTexture },
{ Stage.ClimactericBleeding, TextureCache.khorneTexture },
{ Stage.Recover, TextureCache.nurgleTexture }
{ Stage.Follicular, TextureCache.HumanTexture },
{ Stage.ClimactericFollicular, TextureCache.HumanTexture },
{ Stage.Luteal, TextureCache.FertilityTexture },
{ Stage.ClimactericLuteal, TextureCache.FertilityTexture },
{ Stage.Bleeding, TextureCache.KhorneTexture },
{ Stage.ClimactericBleeding, TextureCache.KhorneTexture },
{ Stage.Recover, TextureCache.NurgleTexture }
};
@ -122,7 +122,7 @@ namespace RJW_Menstruation
protected float antisperm = 0.0f;
protected float? originvagsize = null;
public int ovarypowerthreshold
public int OvaryPowerThreshold
{
get
{
@ -243,7 +243,7 @@ namespace RJW_Menstruation
{
if (cum.Volume > 0)
{
mixedcolor = Colors.CMYKLerp(mixedcolor, cum.color, cum.Volume / (mixedsofar + cum.Volume));
mixedcolor = Colors.CMYKLerp(mixedcolor, cum.Color, cum.Volume / (mixedsofar + cum.Volume));
mixedsofar += cum.Volume;
}
}
@ -289,7 +289,7 @@ namespace RJW_Menstruation
}
}
public string wombTex
public string WombTex
{
get
{
@ -301,7 +301,7 @@ namespace RJW_Menstruation
customwombtex = value;
}
}
public string vagTex
public string VagTex
{
get
{
@ -483,8 +483,7 @@ namespace RJW_Menstruation
{
get
{
Texture2D tex;
if (!StageTexture.TryGetValue(curStage, out tex)) tex = TextureCache.tzeentchTexture;
if (!StageTexture.TryGetValue(curStage, out Texture2D tex)) tex = TextureCache.TzeentchTexture;
return tex;
}
}
@ -745,7 +744,7 @@ namespace RJW_Menstruation
cum.CumEffects(parent.pawn);
float vd = cum.DismishNatural(leakfactor, antisperm);
cum.MakeThinner(Configurations.CycleAcceleration);
totalleak += AbsorbCum(cum, vd, absorber);
totalleak += AbsorbCum(vd, absorber);
string tmp = "FilthLabelWithSource".Translate(cum.FilthDef.label, cum.pawn?.LabelShort ?? "Unknown", 1.ToString());
filthlabels.Add(tmp.Replace(" x1", ""));
if (cum.ShouldRemove()) removecums.Add(cum);
@ -811,7 +810,6 @@ namespace RJW_Menstruation
Color color = GetCumMixtureColor;
float totalleak = 0;
List<string> cumlabels = new List<string>();
float cumd = TotalCumPercent;
List<Cum> removecums = new List<Cum>();
bool pure = true;
foreach (Cum cum in cums)
@ -876,7 +874,7 @@ namespace RJW_Menstruation
if (eggs == null) eggs = new List<Egg>();
InitOvary(parent.pawn.ageTracker.AgeBiologicalYears);
InitOvary();
Hediff_BasePregnancy pregnancy = parent.pawn.GetRJWPregnancy();
if (pregnancy != null)
@ -884,9 +882,8 @@ namespace RJW_Menstruation
Hediff hediff = PregnancyHelper.GetPregnancy(parent.pawn);
if (hediff != null)
{
if (hediff is Hediff_BasePregnancy)
if (hediff is Hediff_BasePregnancy preg)
{
Hediff_BasePregnancy preg = (Hediff_BasePregnancy)hediff;
currentIntervalhours = (int)(preg.GestationHours());
curStage = Stage.Pregnant;
}
@ -916,7 +913,7 @@ namespace RJW_Menstruation
loaded = true;
}
protected void InitOvary(int ageYear)
protected void InitOvary()
{
if (!Configurations.EnableMenopause)
{
@ -958,10 +955,10 @@ namespace RJW_Menstruation
parent.pawn.health.AddHediff(hediff, Genital_Helper.get_genitalsBPR(parent.pawn));
curStage = Stage.Young;
}
else if (ovarypower < ovarypowerthreshold)
else if (ovarypower < OvaryPowerThreshold)
{
Hediff hediff = HediffMaker.MakeHediff(VariousDefOf.Hediff_Climacteric, parent.pawn);
hediff.Severity = 0.008f * (ovarypowerthreshold - ovarypower);
hediff.Severity = 0.008f * (OvaryPowerThreshold - ovarypower);
parent.pawn.health.AddHediff(hediff, Genital_Helper.get_genitalsBPR(parent.pawn));
}
}
@ -971,7 +968,7 @@ namespace RJW_Menstruation
public void RecoverOvary(float multiply = 1.2f)
{
ovarypower = Math.Max(0, (int)(ovarypower * multiply));
if (ovarypower >= ovarypowerthreshold)
if (ovarypower >= OvaryPowerThreshold)
{
RemoveClimactericEffect();
}
@ -980,7 +977,7 @@ namespace RJW_Menstruation
protected void AfterSimulator()
{
if (Configurations.EnableMenopause && ovarypower < ovarypowerthreshold)
if (Configurations.EnableMenopause && ovarypower < OvaryPowerThreshold)
{
if (sexNeed == null) sexNeed = parent.pawn.needs.TryGetNeed(VariousDefOf.SexNeed);
else
@ -1067,9 +1064,8 @@ namespace RJW_Menstruation
{
if (Configurations.UseMultiplePregnancy && Configurations.EnableHeteroOvularTwins)
{
if (pregnancy is Hediff_MultiplePregnancy)
if (pregnancy is Hediff_MultiplePregnancy h)
{
Hediff_MultiplePregnancy h = (Hediff_MultiplePregnancy)pregnancy;
h.AddNewBaby(parent.pawn, egg.fertilizer);
}
pregnant = true;
@ -1131,7 +1127,7 @@ namespace RJW_Menstruation
{
//FilthMaker.TryMakeFilth(parent.pawn.Position, parent.pawn.Map, ThingDefOf.Filth_Blood,parent.pawn.Label);
CumIn(parent.pawn, Rand.Range(0.02f * Configurations.BleedingAmount, 0.04f * Configurations.BleedingAmount), Translations.Menstrual_Blood, -5.0f, parent.pawn.def.race?.BloodDef ?? ThingDefOf.Filth_Blood);
GetNotCum(Translations.Menstrual_Blood).color = BloodColor;
GetNotCum(Translations.Menstrual_Blood).Color = BloodColor;
}
/// <summary>
@ -1147,11 +1143,11 @@ namespace RJW_Menstruation
/// <summary>
/// Absorb cum and return leaked amount
/// </summary>
/// <param name="cum"></param>
/// <param name="amount"></param>
/// <param name="absorber"></param>
///
/// <returns></returns>
protected float AbsorbCum(Cum cum, float amount, Absorber absorber)
protected float AbsorbCum(float amount, Absorber absorber)
{
if (absorber != null)
@ -1280,7 +1276,7 @@ namespace RJW_Menstruation
ovarypower = 0;
GoNextStage(Stage.Young);
}
else if (Configurations.EnableMenopause && ovarypower < ovarypowerthreshold)
else if (Configurations.EnableMenopause && ovarypower < OvaryPowerThreshold)
{
Hediff hediff = HediffMaker.MakeHediff(VariousDefOf.Hediff_Climacteric, parent.pawn);
hediff.Severity = 0.008f * i;
@ -1486,7 +1482,7 @@ namespace RJW_Menstruation
{
if (curStageHrs >= recoveryIntervalhours)
{
if (Configurations.EnableMenopause && ovarypower < ovarypowerthreshold)
if (Configurations.EnableMenopause && ovarypower < OvaryPowerThreshold)
{
GoNextStage(Stage.ClimactericFollicular);
}
@ -1528,7 +1524,7 @@ namespace RJW_Menstruation
{
GoNextStage(Stage.Ovulatory);
}
else if (ovarypower < ovarypowerthreshold / 3 && Rand.Range(0.0f, 1.0f) < 0.2f) //skips ovulatory
else if (ovarypower < OvaryPowerThreshold / 3 && Rand.Range(0.0f, 1.0f) < 0.2f) //skips ovulatory
{
follicularIntervalhours = PeriodRandomizer(follicularIntervalhours, Props.deviationFactor * 6);
GoNextStage(Stage.ClimactericFollicular);
@ -1572,7 +1568,7 @@ namespace RJW_Menstruation
follicularIntervalhours = PeriodRandomizer(follicularIntervalhours, Props.deviationFactor * 6);
GoNextStage(Stage.ClimactericFollicular);
}
else if (ovarypower < ovarypowerthreshold / 4 || (ovarypower < ovarypowerthreshold / 3 && Rand.Range(0.0f, 1.0f) < 0.3f)) //skips bleeding
else if (ovarypower < OvaryPowerThreshold / 4 || (ovarypower < OvaryPowerThreshold / 3 && Rand.Range(0.0f, 1.0f) < 0.3f)) //skips bleeding
{
follicularIntervalhours = PeriodRandomizer(follicularIntervalhours, Props.deviationFactor * 6);
GoNextStage(Stage.ClimactericFollicular);

View File

@ -78,18 +78,16 @@ namespace RJW_Menstruation
public static Texture2D GetPregnancyIcon(this HediffComp_Menstruation comp, Hediff hediff)
{
string icon = "";
Texture2D result = null;
int babycount = 1;
if (hediff is Hediff_MechanoidPregnancy)
{
return ContentFinder<Texture2D>.Get(("Womb/Mechanoid_Fluid"), true);
}
else if (hediff is Hediff_BasePregnancy)
else if (hediff is Hediff_BasePregnancy h)
{
Hediff_BasePregnancy h = (Hediff_BasePregnancy)hediff;
babycount = h.babies.Count;
string fetustex = h.babies?.FirstOrDefault()?.def.GetModExtension<PawnDNAModExtension>()?.fetusTexPath ?? "Fetus/Fetus_Default";
if (h.GestationProgress < 0.2f) icon = comp.wombTex + "_Implanted";
if (h.GestationProgress < 0.2f) icon = comp.WombTex + "_Implanted";
else if (h.GestationProgress < 0.3f)
{
if (h.babies?.First()?.def?.race?.FleshType == FleshTypeDefOf.Insectoid) icon += "Fetus/Insects/Insect_Early00";
@ -104,7 +102,7 @@ namespace RJW_Menstruation
}
else icon = "Fetus/Slime_Abomi02";
result = TryGetTwinsIcon(icon, babycount);
Texture2D result = TryGetTwinsIcon(icon, babycount);
if (result == null) result = ContentFinder<Texture2D>.Get((icon), true);
return result;
@ -112,10 +110,9 @@ namespace RJW_Menstruation
public static Texture2D TryGetTwinsIcon(string path, int babycount)
{
Texture2D result = null;
for (int i = babycount; i > 1; i--)
{
result = ContentFinder<Texture2D>.Get((path + "_Multiplet_" + i), false);
Texture2D result = ContentFinder<Texture2D>.Get((path + "_Multiplet_" + i), false);
if (result != null) return result;
}
return null;
@ -123,7 +120,7 @@ namespace RJW_Menstruation
public static Texture2D GetCumIcon(this HediffComp_Menstruation comp)
{
string icon = comp.wombTex;
string icon = comp.WombTex;
float cumpercent = comp.TotalCumPercent;
if (cumpercent < 0.001f) return ContentFinder<Texture2D>.Get("Womb/Empty", true);
else if (cumpercent < 0.01f) icon += "_Cum_00";
@ -150,7 +147,7 @@ namespace RJW_Menstruation
public static Texture2D GetWombIcon(this HediffComp_Menstruation comp)
{
if (comp.Pawn.health.hediffSet.GetHediffs<Hediff_InsectEgg>().FirstOrDefault() != null) return ContentFinder<Texture2D>.Get(("Womb/Womb_Egged"), true);
string icon = comp.wombTex;
string icon = comp.WombTex;
HediffComp_Menstruation.Stage stage = comp.curStage;
if (stage == HediffComp_Menstruation.Stage.Bleeding) icon += "_Bleeding";
@ -197,7 +194,7 @@ namespace RJW_Menstruation
float severity;
if (drawOrigin) severity = comp.OriginVagSize;
else severity = hediff.Severity;
if (comp != null) icon = comp.vagTex;
if (comp != null) icon = comp.VagTex;
else icon = "Genitals/Vagina";
if (severity < 0.20f) icon += "00"; //micro

View File

@ -167,7 +167,7 @@ namespace RJW_Menstruation
baby.relations.AddDirectRelation(PawnRelationDefOf.Sibling, sibling);
}
siblings.Add(baby);
train(baby, mother, father);
Train(baby, mother);
PostBirth(mother, father, baby);
@ -184,7 +184,6 @@ namespace RJW_Menstruation
List<Trait> poptraits = new List<Trait>();
List<Trait> traits_to_inherit = new List<Trait>();
System.Random rd = new System.Random();
int rand_trait_index = 0;
float max_num_momtraits_inherited = RJWPregnancySettings.max_num_momtraits_inherited;
float max_num_poptraits_inherited = RJWPregnancySettings.max_num_poptraits_inherited;
float max_num_traits_inherited = max_num_momtraits_inherited + max_num_poptraits_inherited;
@ -206,6 +205,7 @@ namespace RJW_Menstruation
poptraits.Add(poptrait);
}
}
int rand_trait_index;
if (!momtraits.NullOrEmpty())
{
i = 1;
@ -278,9 +278,8 @@ namespace RJW_Menstruation
protected void train(Pawn baby, Pawn mother, Pawn father)
protected void Train(Pawn baby, Pawn mother)
{
bool _;
if (!xxx.is_human(baby) && baby.Faction == Faction.OfPlayer)
{
if (xxx.is_human(mother) && baby.Faction == Faction.OfPlayer && baby.training.CanAssignToTrain(TrainableDefOf.Obedience, out _).Accepted)
@ -424,7 +423,7 @@ namespace RJW_Menstruation
// Ensure the same inherited traits are chosen each run
// Has to happen right here so GeneratePawn up there still gets unique results
Rand.PushState(traitSeed); // With a seed just to make sure that fraternal twins *don't* get trait-duped
updateTraits(baby, parentTraits);
UpdateTraits(baby, parentTraits);
Rand.PopState();
}
else if (baby.relations != null)
@ -578,10 +577,10 @@ namespace RJW_Menstruation
if (!Configurations.HybridOverride.NullOrEmpty())
{
info = Configurations.HybridOverride.FirstOrDefault(x => x.defName == first.def?.defName && (x.hybridExtension?.Exists(y => y.defName == second.def?.defName) ?? false));
info = Configurations.HybridOverride.FirstOrDefault(x => x.DefName == first.def?.defName && (x.hybridExtension?.Exists(y => y.DefName == second.def?.defName) ?? false));
if (info == null)
{
info = Configurations.HybridOverride.FirstOrDefault(x => x.defName == second.def?.defName && (x.hybridExtension?.Exists(y => y.defName == first.def?.defName) ?? false));
info = Configurations.HybridOverride.FirstOrDefault(x => x.DefName == second.def?.defName && (x.hybridExtension?.Exists(y => y.DefName == first.def?.defName) ?? false));
opposite = first;
}
}
@ -616,7 +615,7 @@ namespace RJW_Menstruation
/// <param name="pawn"></param>
/// <param name="parentTraits"></param>
///
public void updateTraits(Pawn pawn, List<Trait> parentTraits)
public void UpdateTraits(Pawn pawn, List<Trait> parentTraits)
{
if (pawn?.story?.traits == null)
{
@ -678,8 +677,8 @@ namespace RJW_Menstruation
/// </summary>
public class TraitComparer : IEqualityComparer<Trait>
{
bool ignoreForced;
bool ignoreDegree;
readonly bool ignoreForced;
readonly bool ignoreDegree;
public TraitComparer(bool ignoreDegree = false, bool ignoreForced = true)
{
@ -719,7 +718,7 @@ namespace RJW_Menstruation
public class FatherComparer : IEqualityComparer<Pawn>
{
Pawn mother;
readonly Pawn mother;
public FatherComparer(Pawn mother)
{

View File

@ -11,16 +11,10 @@ namespace RJW_Menstruation
{
public class IngestionOutcomeDoer_GiveHediff_StackCount : IngestionOutcomeDoer_GiveHediff
{
private bool divideByBodySize = false;
protected override void DoIngestionOutcomeSpecial(Pawn pawn, Thing ingested)
{
Hediff hediff = HediffMaker.MakeHediff(hediffDef, pawn);
float effect = ((!(severity > 0f)) ? hediffDef.initialSeverity : severity) * ingested.stackCount;
if (divideByBodySize)
{
effect /= pawn.BodySize;
}
AddictionUtility.ModifyChemicalEffectForToleranceAndBodySize(pawn, toleranceChemical, ref effect);
hediff.Severity = effect;
pawn.health.AddHediff(hediff);

View File

@ -74,12 +74,14 @@ namespace RJW_Menstruation
PreMakeNewToils();
this.FailOnDespawnedNullOrForbidden(TargetIndex.A);
this.FailOnNotCasualInterruptible(TargetIndex.A);
Toil milking = new Toil();
milking.initAction = delegate ()
Toil milking = new Toil
{
pawn.pather.StopDead();
initAction = delegate ()
{
pawn.pather.StopDead();
},
tickAction = MilkingTick
};
milking.tickAction = MilkingTick;
milking.AddFinishAction(Finish);
milking.defaultCompleteMode = ToilCompleteMode.Never;
milking.WithProgressBar(TargetIndex.A, () => progress / MilkingTime);

View File

@ -69,9 +69,8 @@ namespace RJW_Menstruation
if (Utility.ShowFetusImage((Hediff_BasePregnancy)hediff))
{
icon = comp.GetPregnancyIcon(hediff);
if (hediff is Hediff_BasePregnancy)
if (hediff is Hediff_BasePregnancy h)
{
Hediff_BasePregnancy h = (Hediff_BasePregnancy)hediff;
if (h.GestationProgress < 0.2f) icon_overay = comp.GetCumIcon();
else icon_overay = ContentFinder<Texture2D>.Get(("Womb/Empty"), true);
}

View File

@ -7,7 +7,7 @@ namespace RJW_Menstruation
{
[HarmonyPatch(typeof(PregnancyHelper), "impregnate")]
public static class impregnate_Patch
public static class Impregnate_Patch
{
public static bool Prefix(SexProps props)
{
@ -114,7 +114,7 @@ namespace RJW_Menstruation
}
[HarmonyPatch(typeof(CompHediffBodyPart), "updatesize")]
public static class updatesize_Patch
public static class Updatesize_Patch
{
public static void Postfix(CompHediffBodyPart __instance)
{

View File

@ -13,7 +13,7 @@ namespace RJW_Menstruation
public static class TextureCache
{
public static Texture2D milkTexture
public static Texture2D MilkTexture
{
get
{
@ -21,7 +21,7 @@ namespace RJW_Menstruation
return milktexturecache;
}
}
public static Texture2D slaaneshTexture
public static Texture2D SlaaneshTexture
{
get
{
@ -29,7 +29,7 @@ namespace RJW_Menstruation
return slaaneshtexturecache;
}
}
public static Texture2D khorneTexture
public static Texture2D KhorneTexture
{
get
{
@ -37,7 +37,7 @@ namespace RJW_Menstruation
return khornetexturecache;
}
}
public static Texture2D tzeentchTexture
public static Texture2D TzeentchTexture
{
get
{
@ -45,7 +45,7 @@ namespace RJW_Menstruation
return tzeentchtexturecache;
}
}
public static Texture2D nurgleTexture
public static Texture2D NurgleTexture
{
get
{
@ -53,7 +53,7 @@ namespace RJW_Menstruation
return nurgletexturecache;
}
}
public static Texture2D humanTexture
public static Texture2D HumanTexture
{
get
{
@ -61,7 +61,7 @@ namespace RJW_Menstruation
return humantexturecache;
}
}
public static Texture2D animalTexture
public static Texture2D AnimalTexture
{
get
{
@ -69,7 +69,7 @@ namespace RJW_Menstruation
return animaltexturecache;
}
}
public static Texture2D fertilityTexture
public static Texture2D FertilityTexture
{
get
{
@ -77,7 +77,7 @@ namespace RJW_Menstruation
return fertilitytexturecache;
}
}
public static Texture2D ghalmarazTexture
public static Texture2D GhalmarazTexture
{
get
{

View File

@ -87,7 +87,7 @@ namespace RJW_Menstruation
private ThingDef thingDef;
private string thingDefName;
public string defName
public string DefName
{
get
{
@ -150,7 +150,7 @@ namespace RJW_Menstruation
{
private string thingDefName;
public string defName
public string DefName
{
get
{

View File

@ -15,8 +15,8 @@ namespace RJW_Menstruation
{
private static Vector2 scroll;
private const float windowMargin = 20f;
static private List<FloatMenuOption> raceList = new List<FloatMenuOption>();
static private List<HybridInformations> removeList = new List<HybridInformations>();
private static readonly List<FloatMenuOption> raceList = new List<FloatMenuOption>();
private static readonly List<HybridInformations> removeList = new List<HybridInformations>();
public Dialog_HybridCustom()
{
@ -145,11 +145,10 @@ namespace RJW_Menstruation
Widgets.BeginScrollView(outRect, ref scroll, mainRect);
listmain.Begin(mainRect);
int i = 0;
if (!Configurations.HybridOverride.NullOrEmpty())
foreach(HybridInformations extension in Configurations.HybridOverride)
{
if (extension.GetDef != null) DoRow(listmain.GetRect(24f),extension, i++);
if (extension.GetDef != null) DoRow(listmain.GetRect(24f),extension);
}
Widgets.EndScrollView();
listmain.End();
@ -157,7 +156,7 @@ namespace RJW_Menstruation
}
protected void DoRow(Rect rect, HybridInformations extension, int index)
protected void DoRow(Rect rect, HybridInformations extension)
{
Rect buttonRect = new Rect(rect.xMax - 90f, rect.y, 80f, rect.height);
Widgets.Label(rect, extension.GetDef?.label ?? "Undefined");
@ -285,7 +284,7 @@ namespace RJW_Menstruation
{
if (def.race != null)
{
if (info.hybridExtension.Exists(x => x.defName == def.defName)) continue;
if (info.hybridExtension.Exists(x => x.DefName == def.defName)) continue;
else
{
raceList.Add(new FloatMenuOption(def.label, delegate { AddHybridInfo(def); }, Widgets.GetIconFor(def), Color.white));

View File

@ -32,11 +32,11 @@ namespace RJW_Menstruation
private Texture2D anal;
private Color cumcolor;
private GUIStyle fontstylecenter = new GUIStyle() { alignment = TextAnchor.MiddleCenter };
private GUIStyle fontstyleright = new GUIStyle() { alignment = TextAnchor.MiddleRight };
private GUIStyle fontstyleleft = new GUIStyle() { alignment = TextAnchor.MiddleLeft };
private GUIStyle boxstyle = new GUIStyle(GUI.skin.textArea);
private GUIStyle buttonstyle = new GUIStyle(GUI.skin.button);
private readonly GUIStyle fontstylecenter = new GUIStyle() { alignment = TextAnchor.MiddleCenter };
private readonly GUIStyle fontstyleright = new GUIStyle() { alignment = TextAnchor.MiddleRight };
private readonly GUIStyle fontstyleleft = new GUIStyle() { alignment = TextAnchor.MiddleLeft };
private readonly GUIStyle boxstyle = new GUIStyle(GUI.skin.textArea);
private readonly GUIStyle buttonstyle = new GUIStyle(GUI.skin.button);
public Pawn Pawn
{
@ -156,16 +156,15 @@ namespace RJW_Menstruation
if (pregnant && Utility.ShowFetusImage((Hediff_BasePregnancy)hediff))
{
womb = comp.GetPregnancyIcon(hediff);
if (hediff is Hediff_MultiplePregnancy)
if (hediff is Hediff_MultiplePregnancy m)
{
Hediff_MultiplePregnancy h = (Hediff_MultiplePregnancy)hediff;
if (h.GestationProgress < 0.2f) cum = comp.GetCumIcon();
if (m.GestationProgress < 0.2f) cum = comp.GetCumIcon();
else cum = ContentFinder<Texture2D>.Get(("Womb/Empty"), true);
Pawn fetus = pawn.GetFetus();
if (fetus != null && Utility.ShowFetusInfo())
{
string feinfo = h.GetBabyInfo();
string fainfo = h.GetFatherInfo() + " ";
string feinfo = m.GetBabyInfo();
string fainfo = m.GetFatherInfo() + " ";
if (feinfo.Length + fainfo.Length > 45)
{
preginfoheight = fontheight + 2;
@ -185,10 +184,9 @@ namespace RJW_Menstruation
}
}
else if (hediff is Hediff_BasePregnancy)
else if (hediff is Hediff_BasePregnancy b)
{
Hediff_BasePregnancy h = (Hediff_BasePregnancy)hediff;
if (h.GestationProgress < 0.2f) cum = comp.GetCumIcon();
if (b.GestationProgress < 0.2f) cum = comp.GetCumIcon();
else cum = ContentFinder<Texture2D>.Get(("Womb/Empty"), true);
Pawn fetus = pawn.GetFetus();
if (fetus != null && Utility.ShowFetusInfo())
@ -200,8 +198,8 @@ namespace RJW_Menstruation
fontstyleright.alignment = TextAnchor.MiddleRight;
buttonstyle.alignment = TextAnchor.MiddleLeft;
GUI.Box(preginfo, h.babies.Count + " " + fetus.def.label + " " + Translations.Dialog_WombInfo02, buttonstyle);
GUI.Label(preginfo, Translations.Dialog_WombInfo03 + ": " + h.father.LabelShort + " ", fontstyleright);
GUI.Box(preginfo, b.babies.Count + " " + fetus.def.label + " " + Translations.Dialog_WombInfo02, buttonstyle);
GUI.Label(preginfo, Translations.Dialog_WombInfo03 + ": " + b.father.LabelShort + " ", fontstyleright);
}
}
@ -384,36 +382,36 @@ namespace RJW_Menstruation
float statvalue;
const float height = 24f;
statvalue = pawn.GetStatValue(xxx.sex_drive_stat);
FillableBarLabeled(lineRect, " " + xxx.sex_drive_stat.LabelCap.CapitalizeFirst() + " " + statvalue.ToStringPercent(), statvalue/2 ,TextureCache.slaaneshTexture,Texture2D.blackTexture, xxx.sex_drive_stat.description);
FillableBarLabeled(lineRect, " " + xxx.sex_drive_stat.LabelCap.CapitalizeFirst() + " " + statvalue.ToStringPercent(), statvalue/2 ,TextureCache.SlaaneshTexture,Texture2D.blackTexture, xxx.sex_drive_stat.description);
lineRect.y += height;
statvalue = pawn.GetStatValue(xxx.vulnerability_stat);
FillableBarLabeled(lineRect, " " + xxx.vulnerability_stat.LabelCap.CapitalizeFirst() + " " + statvalue.ToStringPercent(), statvalue/2, TextureCache.khorneTexture,Texture2D.blackTexture, xxx.vulnerability_stat.description);
FillableBarLabeled(lineRect, " " + xxx.vulnerability_stat.LabelCap.CapitalizeFirst() + " " + statvalue.ToStringPercent(), statvalue/2, TextureCache.KhorneTexture,Texture2D.blackTexture, xxx.vulnerability_stat.description);
lineRect.y += height;
statvalue = pawn.GetStatValue(xxx.sex_stat);
FillableBarLabeled(lineRect, " " + xxx.sex_stat.LabelCap.CapitalizeFirst() + " " + statvalue.ToStringPercent(), statvalue / 2, TextureCache.tzeentchTexture, Texture2D.blackTexture, xxx.sex_stat.description);
FillableBarLabeled(lineRect, " " + xxx.sex_stat.LabelCap.CapitalizeFirst() + " " + statvalue.ToStringPercent(), statvalue / 2, TextureCache.TzeentchTexture, Texture2D.blackTexture, xxx.sex_stat.description);
lineRect.y += height;
statvalue = pawn.records.GetValue(xxx.CountOfBirthHuman);
FillableBarLabeled(lineRect, " " + xxx.CountOfBirthHuman.LabelCap.CapitalizeFirst() + " " + statvalue, statvalue / 10, TextureCache.humanTexture, Texture2D.blackTexture, xxx.CountOfBirthHuman.description);
FillableBarLabeled(lineRect, " " + xxx.CountOfBirthHuman.LabelCap.CapitalizeFirst() + " " + statvalue, statvalue / 10, TextureCache.HumanTexture, Texture2D.blackTexture, xxx.CountOfBirthHuman.description);
lineRect.y += height;
statvalue = pawn.records.GetValue(xxx.CountOfBirthAnimal);
FillableBarLabeled(lineRect, " " + xxx.CountOfBirthAnimal.LabelCap.CapitalizeFirst() + " " + statvalue, statvalue / 20, TextureCache.animalTexture, Texture2D.blackTexture, xxx.CountOfBirthAnimal.description);
FillableBarLabeled(lineRect, " " + xxx.CountOfBirthAnimal.LabelCap.CapitalizeFirst() + " " + statvalue, statvalue / 20, TextureCache.AnimalTexture, Texture2D.blackTexture, xxx.CountOfBirthAnimal.description);
lineRect.y += height;
statvalue = pawn.records.GetValue(xxx.CountOfBirthEgg);
FillableBarLabeled(lineRect, " " + xxx.CountOfBirthEgg.LabelCap.CapitalizeFirst() + " " + statvalue, statvalue / 100, TextureCache.nurgleTexture, Texture2D.blackTexture, xxx.CountOfBirthEgg.description);
FillableBarLabeled(lineRect, " " + xxx.CountOfBirthEgg.LabelCap.CapitalizeFirst() + " " + statvalue, statvalue / 100, TextureCache.NurgleTexture, Texture2D.blackTexture, xxx.CountOfBirthEgg.description);
lineRect.y += height;
statvalue = pawn.records.GetValue(xxx.CountOfWhore);
if (statvalue > 0)
{
FillableBarLabeled(lineRect, " " + xxx.CountOfWhore.LabelCap.CapitalizeFirst() + " " + statvalue, statvalue / 50, TextureCache.slaaneshTexture, Texture2D.blackTexture, xxx.CountOfWhore.description);
FillableBarLabeled(lineRect, " " + xxx.CountOfWhore.LabelCap.CapitalizeFirst() + " " + statvalue, statvalue / 50, TextureCache.SlaaneshTexture, Texture2D.blackTexture, xxx.CountOfWhore.description);
statvalue = pawn.records.GetValue(xxx.EarnedMoneyByWhore);
lineRect.y += height;
FillableBarLabeled(lineRect, " " + VariousDefOf.RJW_EarnedMoneyByWhore.label.CapitalizeFirst() + " " + statvalue, statvalue / 10000, TextureCache.ghalmarazTexture, Texture2D.blackTexture);
FillableBarLabeled(lineRect, " " + VariousDefOf.RJW_EarnedMoneyByWhore.label.CapitalizeFirst() + " " + statvalue, statvalue / 10000, TextureCache.GhalmarazTexture, Texture2D.blackTexture);
lineRect.y += height;
}
@ -425,7 +423,7 @@ namespace RJW_Menstruation
statvalue = Configurations.ImplantationChance * comp.Props.baseImplantationChanceFactor * comp.ImplantFactor;
float fertchance = comp.GetFertilityChance();
FillableBarLabeled(lineRect, " " + xxx.reproduction.LabelCap.CapitalizeFirst() + " " + statvalue.ToStringPercent(), statvalue, TextureCache.fertilityTexture, Texture2D.blackTexture, Translations.FertilityDesc(String.Format("{0:0.##}", fertchance*100)));
FillableBarLabeled(lineRect, " " + xxx.reproduction.LabelCap.CapitalizeFirst() + " " + statvalue.ToStringPercent(), statvalue, TextureCache.FertilityTexture, Texture2D.blackTexture, Translations.FertilityDesc(String.Format("{0:0.##}", fertchance*100)));
Rect overayRect = new Rect(lineRect.x, lineRect.y, lineRect.width * Math.Min(1.0f, fertchance), lineRect.height);
GUI.DrawTexture(overayRect, TextureCache.FertChanceTex);
lineRect.y += height;

View File

@ -152,9 +152,8 @@ namespace RJW_Menstruation
public static float GetPregnancyProgress(this Pawn pawn)
{
Hediff hediff = PregnancyHelper.GetPregnancy(pawn);
if (hediff is Hediff_BasePregnancy)
if (hediff is Hediff_BasePregnancy h)
{
Hediff_BasePregnancy h = (Hediff_BasePregnancy)hediff;
return h.GestationProgress;
}
return -1;
@ -163,9 +162,8 @@ namespace RJW_Menstruation
public static Pawn GetFetus(this Pawn pawn)
{
Hediff hediff = PregnancyHelper.GetPregnancy(pawn);
if (hediff is Hediff_BasePregnancy)
if (hediff is Hediff_BasePregnancy h)
{
Hediff_BasePregnancy h = (Hediff_BasePregnancy)hediff;
if (!h.babies.NullOrEmpty()) return h.babies.First();
else
{
@ -303,14 +301,14 @@ namespace RJW_Menstruation
if (milkcomp != null)
{
if (milkcomp is CompMilkable)
if (milkcomp is CompMilkable milkable)
{
bool active = (bool)milkcomp.GetPropertyValue("Active");
if (active)
{
CompMilkable m = (CompMilkable)milkcomp;
CompMilkable m = milkable;
res = Math.Max(m.Fullness, res);
Widgets.FillableBar(rect, Math.Min(res, 1.0f), TextureCache.milkTexture, Texture2D.blackTexture, true);
Widgets.FillableBar(rect, Math.Min(res, 1.0f), TextureCache.MilkTexture, Texture2D.blackTexture, true);
DrawMilkBottle(rect, pawn, VariousDefOf.Job_LactateSelf, m.Fullness);
}
}
@ -321,7 +319,7 @@ namespace RJW_Menstruation
{
float fullness = (float)milkcomp.GetMemberValue("fullness");
res = Math.Max(fullness, res);
Widgets.FillableBar(rect, Math.Min(res, 1.0f), TextureCache.milkTexture, Texture2D.blackTexture, true);
Widgets.FillableBar(rect, Math.Min(res, 1.0f), TextureCache.MilkTexture, Texture2D.blackTexture, true);
DrawMilkBottle(rect, pawn, VariousDefOf.Job_LactateSelf_MC, fullness);
}
}
@ -440,7 +438,7 @@ namespace RJW_Menstruation
{
res += random.NextDouble();
}
res = res / iterations;
res /= iterations;
return (float)res*(max-min) + min;

View File

@ -31,9 +31,9 @@ namespace RJW_Menstruation.Sexperience
float amount = stackCount;
float count = ThingUtility.TryAbsorbStackNumToTake(this, other, respectStackLimit);
bool res = base.TryAbsorbStack(other, respectStackLimit);
if (res && other is GatheredCumMixture)
if (res && other is GatheredCumMixture mixture)
{
GatheredCumMixture othercum = (GatheredCumMixture)other;
GatheredCumMixture othercum = mixture;
cumColor = Colors.CMYKLerp(cumColor,othercum.cumColor,count/(amount+count));
if (!othercum.ingredients.NullOrEmpty()) for (int i=0; i<othercum.ingredients.Count; i++)
{
@ -57,7 +57,7 @@ namespace RJW_Menstruation.Sexperience
public void InitwithCum(CumMixture cum)
{
ingredients.AddRange(cum.Getingredients);
cumColor = cum.color;
cumColor = cum.Color;
}
}

View File

@ -58,9 +58,11 @@ namespace RJW_Menstruation.Sexperience
}
};
Toil cleaning = new Toil();
cleaning.initAction = CleaningInit;
cleaning.tickAction = CleaningTick;
Toil cleaning = new Toil
{
initAction = CleaningInit,
tickAction = CleaningTick
};
cleaning.AddFinishAction(Finish);
cleaning.defaultCompleteMode = ToilCompleteMode.Never;
cleaning.WithProgressBar(TargetIndex.A, () => progress / CleaningTime);

View File

@ -23,8 +23,7 @@ namespace RJW_Menstruation.Sexperience
if (comp != null && comp.TotalCumPercent > 0.001f)
foreach (LocalTargetInfo t in targets)
{
Building building = t.Thing as Building;
if (building != null)
if (t.Thing is Building building)
{
if (building is Building_CumBucket)
{