Ejemplo n.º 1
0
        // ProjectJedi
        public static void DrawEquipment_PostFix(HumanBipedDrawer __instance, Vector3 rootLoc, bool portrait)
        {
            Pawn pawn = __instance.Pawn;

            if (pawn.health?.hediffSet?.hediffs == null || pawn.health.hediffSet.hediffs.Count <= 0)
            {
                return;
            }

            Hediff shieldHediff =
                pawn.health.hediffSet.hediffs.FirstOrDefault(x =>
                                                             x.TryGetComp <HediffComp_Shield>() != null);

            HediffComp_Shield shield = shieldHediff?.TryGetComp <HediffComp_Shield>();

            shield?.DrawWornExtras();
        }
        // Token: 0x060011D5 RID: 4565 RVA: 0x000EC6D0 File Offset: 0x000EA8D0
        public static bool Prefix(Pawn __instance, ref DamageInfo dinfo, out bool absorbed)
        {
            Traverse traverse = Traverse.Create(__instance);
            Pawn     pawn     = (Pawn)AM_PreApplyDamage_HediffComp_Shield_Patch.pawn.GetValue(__instance);
            bool     flag     = dinfo.Def != null && pawn != null && !pawn.Downed;

            if (flag)
            {
                if (pawn.health.hediffSet.hediffs.Any(x => x.TryGetComp <HediffComp_Shield>() != null))
                {
                    List <Hediff> list = pawn.health.hediffSet.hediffs.FindAll(x => x.TryGetComp <HediffComp_Shield>() != null);
                    foreach (Hediff item in list)
                    {
                        HediffComp_Shield _Shield = item.TryGetComp <HediffComp_Shield>();
                        if (_Shield != null)
                        {
                            absorbed = _Shield.CheckPreAbsorbDamage(dinfo);
                            return(false);
                        }
                    }
                }
                if (pawn.health.hediffSet.hediffs.Any(x => x.TryGetComp <HediffComp_PhaseShifter>() != null))
                {
                    List <Hediff> list = pawn.health.hediffSet.hediffs.FindAll(x => x.TryGetComp <HediffComp_PhaseShifter>() != null);
                    foreach (Hediff item in list)
                    {
                        HediffComp_PhaseShifter _Shifter = item.TryGetComp <HediffComp_PhaseShifter>();
                        if (_Shifter != null)
                        {
                            if (dinfo.Def.isExplosive)
                            {
                                absorbed = !_Shifter.isPhasedIn;
                                return(_Shifter.isPhasedIn);
                            }
                        }
                    }
                }
            }
            absorbed = false;
            return(true);
        }