public static void GetGizmos_PostFix(Pawn __instance, ref IEnumerable <Gizmo> __result) { Pawn pawn = __instance; if (pawn.health != null) { if (pawn.health.hediffSet != null) { if (pawn.health.hediffSet.hediffs != null && pawn.health.hediffSet.hediffs.Count > 0) { Hediff shieldHediff = pawn.health.hediffSet.hediffs.FirstOrDefault((Hediff x) => x.TryGetComp <HediffComp_Shield>() != null); if (shieldHediff != null) { HediffComp_Shield shield = shieldHediff.TryGetComp <HediffComp_Shield>(); if (shield != null) { __result = __result.Concat(gizmoGetter(shield)); } } } } } }
// Verse.PawnRenderer public static void DrawEquipment_PostFix(PawnRenderer __instance, Vector3 rootLoc) { Pawn pawn = (Pawn)AccessTools.Field(typeof(PawnRenderer), "pawn").GetValue(__instance); if (pawn.health != null) { if (pawn.health.hediffSet != null) { if (pawn.health.hediffSet.hediffs != null && pawn.health.hediffSet.hediffs.Count > 0) { Hediff shieldHediff = pawn.health.hediffSet.hediffs.FirstOrDefault((Hediff x) => x.TryGetComp <HediffComp_Shield>() != null); if (shieldHediff != null) { HediffComp_Shield shield = shieldHediff.TryGetComp <HediffComp_Shield>(); if (shield != null) { shield.DrawWornExtras(); } } } } } }
public static IEnumerable <Gizmo> gizmoGetter(HediffComp_Shield compHediffShield) { if (compHediffShield.GetWornGizmos() != null) { IEnumerator <Gizmo> enumerator = compHediffShield.GetWornGizmos().GetEnumerator(); while (enumerator.MoveNext()) { Gizmo current = enumerator.Current; yield return(current); } } }