RJW-Sexperience/Source/RJWSexperience/Patches/DefInjection.cs

32 lines
829 B
C#
Raw Normal View History

2022-06-04 19:01:45 +00:00
using RJWSexperience.Logs;
2022-06-13 05:51:09 +00:00
using RJWSexperience.SexHistory;
2021-09-24 15:14:02 +00:00
using System.Collections.Generic;
using System.Linq;
using Verse;
namespace RJWSexperience
{
2022-06-04 19:01:45 +00:00
[StaticConstructorOnStartup]
public static class DefInjection
{
static DefInjection()
{
2022-06-07 03:46:19 +00:00
if (SexperienceMod.Settings.History.EnableSexHistory)
InjectRaces();
2022-06-04 19:01:45 +00:00
}
private static void InjectRaces()
{
IEnumerable<ThingDef> PawnDefs = DefDatabase<ThingDef>.AllDefs.Where(x => x.race != null && !x.race.IsMechanoid);
if (PawnDefs.EnumerableNullOrEmpty())
return;
2021-09-24 15:14:02 +00:00
2022-06-04 19:01:45 +00:00
CompProperties comp = new CompProperties(typeof(SexHistoryComp));
foreach (ThingDef def in PawnDefs)
def.comps.Add(comp);
2021-09-24 15:14:02 +00:00
LogManager.GetLogger<DebugLogProvider>("StaticConstructorOnStartup").Message($"Injected SexHistoryComp into {PawnDefs.Count()} pawn Defs");
2022-06-04 19:01:45 +00:00
}
}
2021-09-24 15:14:02 +00:00
}