Refactor DefInjection
This commit is contained in:
parent
d792e93fcd
commit
61bd959ba8
|
@ -1,35 +1,29 @@
|
||||||
using System;
|
using RJWSexperience.Logs;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Verse;
|
using Verse;
|
||||||
using HarmonyLib;
|
|
||||||
|
|
||||||
|
|
||||||
namespace RJWSexperience
|
namespace RJWSexperience
|
||||||
{
|
{
|
||||||
[StaticConstructorOnStartup]
|
[StaticConstructorOnStartup]
|
||||||
public static class DefInjection
|
public static class DefInjection
|
||||||
{
|
{
|
||||||
static DefInjection()
|
static DefInjection()
|
||||||
{
|
{
|
||||||
InjectRaces();
|
InjectRaces();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void InjectRaces()
|
private static void InjectRaces()
|
||||||
{
|
{
|
||||||
List<ThingDef> PawnDefs = DefDatabase<ThingDef>.AllDefs.Where(x => x.race != null && !x.race.IsMechanoid).ToList();
|
IEnumerable<ThingDef> PawnDefs = DefDatabase<ThingDef>.AllDefs.Where(x => x.race != null && !x.race.IsMechanoid);
|
||||||
InjectComp(PawnDefs);
|
if (PawnDefs.EnumerableNullOrEmpty())
|
||||||
}
|
return;
|
||||||
|
|
||||||
private static void InjectComp(List<ThingDef> PawnDefs)
|
CompProperties comp = new CompProperties(typeof(SexHistoryComp));
|
||||||
{
|
foreach (ThingDef def in PawnDefs)
|
||||||
CompProperties comp = new CompProperties(typeof(SexHistoryComp));
|
def.comps.Add(comp);
|
||||||
if (!PawnDefs.NullOrEmpty()) foreach(ThingDef def in PawnDefs)
|
|
||||||
{
|
LogManager.GetLogger("StaticConstructorOnStartup").Message($"Injected SexHistoryComp into {PawnDefs.Count()} pawn Defs");
|
||||||
def.comps.Add(comp);
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue