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()
|
|
|
|
|
{
|
2023-03-24 15:22:54 +00:00
|
|
|
|
if (SexperienceMod.Settings.EnableSexHistory)
|
2022-06-07 03:46:19 +00:00
|
|
|
|
InjectRaces();
|
2022-06-04 19:01:45 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-03-24 18:06:24 +00:00
|
|
|
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("Roslynator", "RCS1146:Use conditional access.", Justification = "race != null is needed")]
|
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
|
|
|
|
|
2023-03-24 18:06:24 +00:00
|
|
|
|
CompProperties compProperties = new CompProperties(typeof(SexHistoryComp));
|
2022-06-04 19:01:45 +00:00
|
|
|
|
foreach (ThingDef def in PawnDefs)
|
2023-03-24 18:06:24 +00:00
|
|
|
|
def.comps.Add(compProperties);
|
2021-09-24 15:14:02 +00:00
|
|
|
|
|
2022-06-05 12:11:13 +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
|
|
|
|
}
|