Check comp before copying enumerable

This commit is contained in:
amevarashi 2022-06-04 13:40:40 +05:00
parent 1013113718
commit c9c96006cb
1 changed files with 7 additions and 5 deletions

View File

@ -12,17 +12,19 @@ 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;
yield return history.Gizmo;
}
}
}