Use explicit types instead of var everywhere

This commit is contained in:
lutepickle 2022-07-16 07:11:58 -07:00
parent 92fab44764
commit 5a64a081c2
10 changed files with 29 additions and 29 deletions

View file

@ -10,7 +10,7 @@ namespace MilkModule
{
static First()
{
var har = new Harmony("RJW_Menstruation_MilkModule");
Harmony har = new Harmony("RJW_Menstruation_MilkModule");
har.PatchAll(Assembly.GetExecutingAssembly());
}
}

View file

@ -18,7 +18,7 @@ namespace RJW_Menstruation
public static IEnumerable<HediffComp_Menstruation> GetMenstruationComps(this Pawn pawn)
{
var hedifflist = Genital_Helper.get_PartsHediffList(pawn, Genital_Helper.get_genitalsBPR(pawn))?.FindAll((Hediff h) => h.def.defName.ToLower().Contains("vagina"));
List<Hediff> hedifflist = Genital_Helper.get_PartsHediffList(pawn, Genital_Helper.get_genitalsBPR(pawn))?.FindAll((Hediff h) => h.def.defName.ToLower().Contains("vagina"));
foreach (Hediff hediff in hedifflist)
{
HediffComp_Menstruation result = hediff.TryGetComp<HediffComp_Menstruation>();
@ -58,7 +58,7 @@ namespace RJW_Menstruation
public static HediffComp_Anus GetAnusComp(this Pawn pawn)
{
var hedifflist = Genital_Helper.get_PartsHediffList(pawn, Genital_Helper.get_genitalsBPR(pawn))?.FindAll((Hediff h) => h.def.defName.ToLower().Contains("anus"));
List<Hediff> hedifflist = Genital_Helper.get_PartsHediffList(pawn, Genital_Helper.get_genitalsBPR(pawn))?.FindAll((Hediff h) => h.def.defName.ToLower().Contains("anus"));
HediffComp_Anus result;
if (!hedifflist.NullOrEmpty())
{
@ -219,7 +219,7 @@ namespace RJW_Menstruation
public static Texture2D GetGenitalIcon(this Pawn pawn, HediffComp_Menstruation comp, bool drawOrigin = false)
{
var hediff = Genital_Helper.get_PartsHediffList(pawn, Genital_Helper.get_genitalsBPR(pawn))?.Find((Hediff h) => h.def.defName.ToLower().Contains("vagina"));
Hediff hediff = Genital_Helper.get_PartsHediffList(pawn, Genital_Helper.get_genitalsBPR(pawn))?.Find((Hediff h) => h.def.defName.ToLower().Contains("vagina"));
if (hediff == null) return ContentFinder<Texture2D>.Get("Genitals/Vagina00", true);
//HediffComp_Menstruation comp = hediff.GetMenstruationComp();
string icon;
@ -247,7 +247,7 @@ namespace RJW_Menstruation
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"));
Hediff hediff = Genital_Helper.get_PartsHediffList(pawn, Genital_Helper.get_anusBPR(pawn)).FirstOrDefault((Hediff h) => h.def.defName.ToLower().Contains("anus"));
if (hediff == null) return ContentFinder<Texture2D>.Get(("Genitals/Anal00"), true);
string icon;

View file

@ -78,7 +78,7 @@ namespace RJW_Menstruation
string res = "";
var babiesdistinct = babies.Distinct(new RaceComparer());
IEnumerable<Pawn> babiesdistinct = babies.Distinct(new RaceComparer());
int iteration = 0;
foreach (Pawn baby in babiesdistinct)
{
@ -101,7 +101,7 @@ namespace RJW_Menstruation
if (!is_parent_known && Configurations.InfoDetail != Configurations.DetailLevel.All)
return res + Translations.Dialog_FatherUnknown;
var babiesdistinct = babies.Distinct(new FatherComparer(pawn));
IEnumerable<Pawn> babiesdistinct = babies.Distinct(new FatherComparer(pawn));
int iteration = 0;
foreach (Pawn baby in babiesdistinct)
{
@ -121,7 +121,7 @@ namespace RJW_Menstruation
PawnUtility.TrySpawnHatchedOrBornPawn(baby, mother);
var sex_need = mother.needs?.TryGetNeed<Need_Sex>();
Need_Sex sex_need = mother.needs?.TryGetNeed<Need_Sex>();
if (mother.Faction != null && !(mother.Faction?.IsPlayer ?? false) && sex_need != null)
{
sex_need.CurLevel = 1.0f;
@ -519,11 +519,11 @@ namespace RJW_Menstruation
if (!Configurations.UseHybridExtention || spawn_kind_def == null)
{
spawn_kind_def = non_hybrid_kind_def;
var groups = DefDatabase<RaceGroupDef>.AllDefs.Where(x => !(x.hybridRaceParents.NullOrEmpty() || x.hybridChildKindDef.NullOrEmpty()));
IEnumerable<RaceGroupDef> groups = DefDatabase<RaceGroupDef>.AllDefs.Where(x => !(x.hybridRaceParents.NullOrEmpty() || x.hybridChildKindDef.NullOrEmpty()));
//ModLog.Message(" found custom RaceGroupDefs " + groups.Count());
foreach (var t in groups)
foreach (RaceGroupDef t in groups)
{
if ((t.hybridRaceParents.Contains(MotherRaceName) && t.hybridRaceParents.Contains(FatherRaceName))
|| (t.hybridRaceParents.Contains("Any") && (t.hybridRaceParents.Contains(MotherRaceName) || t.hybridRaceParents.Contains(FatherRaceName))))
@ -536,7 +536,7 @@ namespace RJW_Menstruation
else
{
//ModLog.Message(" trying hybridChildKindDef " + t.defName);
var child_kind_def_list = new List<PawnKindDef>();
List<PawnKindDef> child_kind_def_list = new List<PawnKindDef>();
child_kind_def_list.AddRange(DefDatabase<PawnKindDef>.AllDefs.Where(x => t.hybridChildKindDef.Contains(x.defName)));
//ModLog.Message(" found custom hybridChildKindDefs " + t.hybridChildKindDef.Count);
@ -556,7 +556,7 @@ namespace RJW_Menstruation
if (spawn_kind_def.defName.Contains("Nymph"))
{
//child is nymph, try to find other PawnKindDef
var spawn_kind_def_list = new List<PawnKindDef>();
List<PawnKindDef> spawn_kind_def_list = new List<PawnKindDef>();
spawn_kind_def_list.AddRange(DefDatabase<PawnKindDef>.AllDefs.Where(x => x.race == spawn_kind_def.race && !x.defName.Contains("Nymph")));
//no other PawnKindDef found try mother
if (spawn_kind_def_list.NullOrEmpty())
@ -643,12 +643,12 @@ namespace RJW_Menstruation
numberInherited = 0;
//Game suggested traits.
var forcedTraits = personalTraitPool
IEnumerable<Trait> forcedTraits = personalTraitPool
.Where(x => x.ScenForced)
.Distinct(new TraitComparer(ignoreDegree: true)); // result can be a mess, because game allows this mess to be created in scenario editor
List<Trait> selectedTraits = new List<Trait>();
var comparer = new TraitComparer(); // trait comparision implementation, because without game compares traits *by reference*, makeing them all unique.
TraitComparer comparer = new TraitComparer(); // trait comparision implementation, because without game compares traits *by reference*, makeing them all unique.
selectedTraits.AddRange(forcedTraits); // enforcing scenario forced traits
for (int i = 0; i < numberInherited; i++) // add parent traits first
{
@ -663,7 +663,7 @@ namespace RJW_Menstruation
while (selectedTraits.Count < traitLimit && personalTraitPool.Count > 0)
{
int index = Rand.Range(0, personalTraitPool.Count); // getting trait and removing from the pull
var trait = personalTraitPool[index];
Trait trait = personalTraitPool[index];
personalTraitPool.RemoveAt(index);
if (!selectedTraits.Any(x => comparer.Equals(x, trait) || // skipping traits conflicting with already added

View file

@ -14,14 +14,14 @@ namespace RJW_Menstruation
{
static First()
{
var har = new Harmony("RJW_Menstruation");
Harmony har = new Harmony("RJW_Menstruation");
har.PatchAll(Assembly.GetExecutingAssembly());
InjectIntoRjwInteractionServices();
}
private static void InjectIntoRjwInteractionServices()
{
var log = LogManager.GetLogger("StaticConstructorOnStartup");
ILog log = LogManager.GetLogger("StaticConstructorOnStartup");
List<IPartPreferenceRule> partKindUsageRules = Unprivater.GetProtectedValue<List<IPartPreferenceRule>>("_partKindUsageRules", typeof(PartPreferenceDetectorService));
partKindUsageRules.Add(new Interactions.EstrusPartKindUsageRule());

View file

@ -34,7 +34,7 @@ namespace RJW_Menstruation
{
public static void Postfix(Vector3 clickPos, Pawn pawn, List<FloatMenuOption> opts)
{
var selftargets = GenUI.TargetsAt(clickPos, TargetingParameters.ForSelf(pawn));
IEnumerable<LocalTargetInfo> selftargets = GenUI.TargetsAt(clickPos, TargetingParameters.ForSelf(pawn));
foreach (LocalTargetInfo t in selftargets)
{

View file

@ -30,7 +30,7 @@ namespace RJW_Menstruation
if (!InteractionCanCausePregnancy(props)) return false;
var pawnparts = Genital_Helper.get_PartsHediffList(pawn, Genital_Helper.get_genitalsBPR(pawn));
List<Hediff> pawnparts = Genital_Helper.get_PartsHediffList(pawn, Genital_Helper.get_genitalsBPR(pawn));
HediffComp_Menstruation comp;
if (pawn.Has(Quirk.ImpregnationFetish) || partner.Has(Quirk.ImpregnationFetish) || partner.IsInEstrus())

View file

@ -113,7 +113,7 @@ namespace RJW_Menstruation
buttonRect.x -= 100;
if (Widgets.ButtonText(buttonRect, "Undo"))
{
var element = removeList.Last();
HybridInformations element = removeList.Last();
Configurations.HybridOverride.Add(element);
Configurations.HybridOverride.SortBy(x => x.GetDef?.label ?? "Undefined");
removeList.Remove(element);
@ -310,7 +310,7 @@ namespace RJW_Menstruation
buttonRect.x -= 100;
if (Widgets.ButtonText(buttonRect, "Undo"))
{
var element = removeList.Last();
HybridExtensionExposable element = removeList.Last();
info.hybridExtension.Add(element);
removeList.Remove(element);
}

View file

@ -92,7 +92,7 @@ namespace RJW_Menstruation
public static HediffComp_Breast GetBreastComp(this Pawn pawn)
{
var hedifflist = Genital_Helper.get_PartsHediffList(pawn, Genital_Helper.get_breastsBPR(pawn))?.FindAll((Hediff h) => h is Hediff_PartBaseNatural || h is Hediff_PartBaseArtifical);
List<Hediff> 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;
if (hedifflist.NullOrEmpty()) return null;
foreach (Hediff h in hedifflist)
@ -120,7 +120,7 @@ namespace RJW_Menstruation
public static bool HasMenstruationComp(this Pawn pawn)
{
var hedifflist = Genital_Helper.get_PartsHediffList(pawn, Genital_Helper.get_genitalsBPR(pawn))?.FindAll((Hediff h) => h.def.defName.ToLower().Contains("vagina"));
List<Hediff> 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 false;
foreach (Hediff h in hedifflist)
@ -164,7 +164,7 @@ namespace RJW_Menstruation
public static void DrawBreastIcon(this Pawn pawn, Rect rect, bool drawOrigin = false)
{
var hediff = Genital_Helper.get_PartsHediffList(pawn, Genital_Helper.get_breastsBPR(pawn)).FirstOrDefault((Hediff h) => h.def.defName.ToLower().Contains("breast"));
Hediff hediff = Genital_Helper.get_PartsHediffList(pawn, Genital_Helper.get_breastsBPR(pawn)).FirstOrDefault((Hediff h) => h.def.defName.ToLower().Contains("breast"));
Texture2D breast, nipple, areola;
if (hediff != null)
{
@ -336,18 +336,18 @@ namespace RJW_Menstruation
public static string GetVaginaLabel(this Pawn pawn)
{
var hediff = Genital_Helper.get_PartsHediffList(pawn, Genital_Helper.get_genitalsBPR(pawn)).Find((Hediff h) => h.def.defName.ToLower().Contains("vagina"));
Hediff hediff = Genital_Helper.get_PartsHediffList(pawn, Genital_Helper.get_genitalsBPR(pawn)).Find((Hediff h) => h.def.defName.ToLower().Contains("vagina"));
return hediff.LabelBase.CapitalizeFirst() + "\n(" + hediff.LabelInBrackets + ")" + "\n" + xxx.CountOfSex.LabelCap.CapitalizeFirst() + ": " + pawn.records.GetAsInt(xxx.CountOfSex);
}
public static string GetAnusLabel(this Pawn pawn)
{
var hediff = Genital_Helper.get_PartsHediffList(pawn, Genital_Helper.get_anusBPR(pawn)).FirstOrDefault((Hediff h) => h.def.defName.ToLower().Contains("anus"));
Hediff hediff = Genital_Helper.get_PartsHediffList(pawn, Genital_Helper.get_anusBPR(pawn)).FirstOrDefault((Hediff h) => h.def.defName.ToLower().Contains("anus"));
if (hediff != null) return hediff.LabelBase.CapitalizeFirst() + "\n(" + hediff.LabelInBrackets + ")";
else return "";
}
public static string GetBreastLabel(this Pawn pawn)
{
var hediff = Genital_Helper.get_PartsHediffList(pawn, Genital_Helper.get_breastsBPR(pawn)).FirstOrDefault((Hediff h) => h.def.defName.ToLower().Contains("breast"));
Hediff hediff = Genital_Helper.get_PartsHediffList(pawn, Genital_Helper.get_breastsBPR(pawn)).FirstOrDefault((Hediff h) => h.def.defName.ToLower().Contains("breast"));
if (hediff != null) return hediff.LabelBase.CapitalizeFirst() + "\n(" + hediff.LabelInBrackets + ")";
else return "";
}

View file

@ -9,7 +9,7 @@ namespace RJW_Menstruation.Sexperience
{
static First()
{
var har = new Harmony("RJW_Menstruation.Sexperience");
Harmony har = new Harmony("RJW_Menstruation.Sexperience");
har.PatchAll(Assembly.GetExecutingAssembly());
}
}

View file

@ -13,7 +13,7 @@ namespace RJW_Menstruation.Sexperience
{
public static void Postfix(Vector3 clickPos, Pawn pawn, List<FloatMenuOption> opts)
{
var targets = GenUI.TargetsAt(clickPos, TargetingParameters.ForBuilding());
IEnumerable<LocalTargetInfo> targets = GenUI.TargetsAt(clickPos, TargetingParameters.ForBuilding());
if (pawn.GetMenstruationComps().Any(comp => comp.TotalCumPercent > 0.001f))
foreach (LocalTargetInfo t in targets)