Check comp before copying enumerable

This commit is contained in:
amevarashi 2022-06-04 13:40:40 +05:00
parent 1013113718
commit c9c96006cb

View file

@ -12,16 +12,18 @@ namespace RJWSexperience
if (Find.Selector.NumSelected > 1)
return;
__result = AddHistoryGizmo(__instance, __result);
SexHistoryComp history = __instance.TryGetComp<SexHistoryComp>();
if (history == null)
return;
__result = AddHistoryGizmo(history, __result);
}
private static IEnumerable<Gizmo> AddHistoryGizmo(Pawn pawn, IEnumerable<Gizmo> gizmos)
private static IEnumerable<Gizmo> AddHistoryGizmo(SexHistoryComp history, IEnumerable<Gizmo> gizmos)
{
foreach (Gizmo gizmo in gizmos)
yield return gizmo;
SexHistoryComp history = pawn.TryGetComp<SexHistoryComp>();
if (history != null)
yield return history.Gizmo;
}
}