예제 #1
0
        // Verse.Pawn_HealthTracker
        public static bool PreApplyDamage_PreFix(Pawn_HealthTracker __instance, DamageInfo dinfo, out bool absorbed)
        {
            Pawn pawn = (Pawn)AccessTools.Field(typeof(Pawn_HealthTracker), "pawn").GetValue(__instance);

            if (pawn != 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)
                        {
                            if (shield.CheckPreAbsorbDamage(dinfo))
                            {
                                absorbed = true;
                                return(false);
                            }
                        }
                    }
                }
            }
            absorbed = false;
            return(true);
        }
예제 #2
0
 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);
         }
     }
 }
        // Verse.PawnRenderer
        public static void DrawEquipment_PostFix(PawnRenderer __instance, Vector3 rootLoc)
        {
            Pawn pawn = (Pawn)AccessTools.Field(typeof(PawnRenderer), "pawn").GetValue(__instance);

            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);
                HediffComp_Shield shield = shieldHediff?.TryGetComp <HediffComp_Shield>();
                shield?.DrawWornExtras();
            }
        }
예제 #4
0
        public static IEnumerable <Gizmo> GizmoGetter(HediffComp_Shield compHediffShield)
        {
            if (compHediffShield.GetWornGizmos() == null)
            {
                yield break;
            }

            using var enumerator = compHediffShield.GetWornGizmos().GetEnumerator();
            while (enumerator.MoveNext())
            {
                var current = enumerator.Current;
                yield return(current);
            }
        }
        public static void GetGizmos_PostFix(Pawn __instance, ref IEnumerable <Gizmo> __result)
        {
            Pawn pawn = __instance;

            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);
                HediffComp_Shield shield = shieldHediff?.TryGetComp <HediffComp_Shield>();
                if (shield != null)
                {
                    __result = __result.Concat <Gizmo>(gizmoGetter(shield));
                }
            }
        }
예제 #6
0
 public static IEnumerable <Gizmo> GizmoGetter(HediffComp_Shield compHediffShield)
 {
     return(compHediffShield.GetWornGizmos() ?? Enumerable.Empty <Gizmo>());
 }