Just eliminate GetHARComp instead of messing with casting

This commit is contained in:
lutepickle 2022-08-18 08:41:05 -07:00
parent 1cbe557621
commit 5e788df794

View file

@ -14,16 +14,10 @@ namespace RJW_Menstruation
return pawn?.def is ThingDef_AlienRace;
}
// Can't have it be a AlienPartGenerator.AlienComp due to the way the dev actions look for functions
public static ThingComp GetHARComp(this Pawn pawn)
{
return pawn?.TryGetComp<AlienPartGenerator.AlienComp>();
}
public static void CopyHARProperties(Pawn baby, Pawn original)
{
AlienPartGenerator.AlienComp babyHARComp = (AlienPartGenerator.AlienComp)baby.GetHARComp();
AlienPartGenerator.AlienComp originalHARComp = (AlienPartGenerator.AlienComp)original.GetHARComp();
AlienPartGenerator.AlienComp babyHARComp = baby?.TryGetComp<AlienPartGenerator.AlienComp>();
AlienPartGenerator.AlienComp originalHARComp = original?.TryGetComp<AlienPartGenerator.AlienComp>();
if (babyHARComp == null || originalHARComp == null) return;
babyHARComp.crownType = originalHARComp.crownType;
@ -38,8 +32,8 @@ namespace RJW_Menstruation
// HAR doesn't populate variants until the graphics are called for, so this has to happen late
public static void CopyHARPropertiesPostBirth(Pawn baby, Pawn original)
{
AlienPartGenerator.AlienComp babyHARComp = (AlienPartGenerator.AlienComp)baby.GetHARComp();
AlienPartGenerator.AlienComp originalHARComp = (AlienPartGenerator.AlienComp)original.GetHARComp();
AlienPartGenerator.AlienComp babyHARComp = baby?.TryGetComp<AlienPartGenerator.AlienComp>();
AlienPartGenerator.AlienComp originalHARComp = original?.TryGetComp<AlienPartGenerator.AlienComp>();
if (babyHARComp == null || originalHARComp == null) return;
if (originalHARComp.addonVariants != null) // Testing has shown that the addons are valid by this point, but it's better to be safe
babyHARComp.addonVariants = new List<int>(originalHARComp.addonVariants);