示例#1
0
 static void Postfix(ShieldBelt __instance, ref bool __result)
 {
     if (__result == false && __instance.Wearer.health != null && __instance.Wearer.health.hediffSet.HasHediff(WTH_DefOf.WTH_BeltModule) && __instance.Wearer.IsHacked() && __instance.Wearer.IsActivated())
     {
         __result = true;
     }
 }
示例#2
0
        private void ApplySuppression(Pawn pawn)
        {
            ShieldBelt shield = null;

            if (pawn.RaceProps.Humanlike)
            {
                // check for shield user

                List <Apparel> wornApparel = pawn.apparel.WornApparel;
                for (int i = 0; i < wornApparel.Count; i++)
                {
                    var personalShield = wornApparel[i] as ShieldBelt;
                    if (personalShield != null)
                    {
                        shield = personalShield;
                        break;
                    }
                }
            }
            //Add suppression
            CompSuppressable compSuppressable = pawn.TryGetComp <CompSuppressable>();

            if (compSuppressable != null &&
                pawn.Faction != launcher?.Faction &&
                (shield == null || shield?.ShieldState == ShieldState.Resetting))
            {
                suppressionAmount = def.projectile.damageAmountBase;
                var   propsCE           = def.projectile as ProjectilePropertiesCE;
                float penetrationAmount = propsCE == null ? 0f : propsCE.armorPenetration;
                suppressionAmount *= 1 - Mathf.Clamp(compSuppressable.ParentArmor - penetrationAmount, 0, 1);
                compSuppressable.AddSuppression(suppressionAmount, OriginIV3);
            }
        }
 public Stance_Warmup(int ticks, LocalTargetInfo focusTarg, Verb verb)
     : base(ticks, focusTarg, verb)
 {
     if (focusTarg.HasThing && focusTarg.Thing is Pawn)
     {
         Pawn pawn = (Pawn)focusTarg.Thing;
         this.targetStartedDowned = pawn.Downed;
         if (pawn.apparel != null)
         {
             for (int i = 0; i < pawn.apparel.WornApparelCount; i++)
             {
                 Apparel    apparel    = pawn.apparel.WornApparel[i];
                 ShieldBelt shieldBelt = apparel as ShieldBelt;
                 if (shieldBelt != null)
                 {
                     shieldBelt.KeepDisplaying();
                 }
             }
         }
     }
     if (verb != null && verb.verbProps.soundAiming != null)
     {
         SoundInfo info = SoundInfo.InMap(verb.caster, MaintenanceType.PerTick);
         if (verb.CasterIsPawn)
         {
             info.pitchFactor = (float)(1.0 / verb.CasterPawn.GetStatValue(StatDefOf.AimingDelayFactor, true));
         }
         this.sustainer = verb.verbProps.soundAiming.TrySpawnSustainer(info);
     }
 }
        private void ApplySuppression(Pawn pawn)
        {
            ShieldBelt shield = null;

            if (pawn.RaceProps.Humanlike)
            {
                // check for shield user

                var wornApparel = pawn.apparel.WornApparel;
                for (var i = 0; i < wornApparel.Count; i++)
                {
                    var personalShield = wornApparel[i] as ShieldBelt;
                    if (personalShield != null)
                    {
                        shield = personalShield;
                        break;
                    }
                }
            }
            //Add suppression
            var compSuppressable = pawn.TryGetComp <CompSuppressable>();

            if (compSuppressable != null &&
                pawn.Faction != launcher?.Faction &&
                (shield == null || shield.ShieldState == ShieldState.Resetting))
            {
                suppressionAmount = def.projectile.GetDamageAmount(1);
                var propsCE           = def.projectile as ProjectilePropertiesCE;
                var penetrationAmount = propsCE?.armorPenetrationSharp ?? 0f;
                var armorMod          = penetrationAmount <= 0 ? 0 : 1 - Mathf.Clamp(pawn.GetStatValue(CE_StatDefOf.AverageSharpArmor) * 0.5f / penetrationAmount, 0, 1);
                suppressionAmount *= armorMod;
                compSuppressable.AddSuppression(suppressionAmount, OriginIV3);
            }
        }
 internal static void Postfix(ShieldBelt __instance, ref int ___ticksToReset, int ___StartingTicksToReset)
 {
     if (__instance.Wearer?.CurJob?.def == JobDefOf.ManTurret && (__instance.Wearer?.jobs?.curDriver?.OnLastToil ?? false))
     {
         if (__instance.ShieldState == ShieldState.Active)
         {
             Traverse.Create(__instance).Method("Break").GetValue();
         }
         ___ticksToReset = ___StartingTicksToReset;
     }
 }
示例#6
0
        public static float EnergyMax(ShieldBelt shield)
        {
            Pawn  wearer = shield.Wearer;
            float result = shield.GetStatValue(StatDefOf.EnergyShieldEnergyMax, true);

            if (wearer != null)
            {
                result *= wearer.GetStatValueForPawn(BStatDefOf.EnergyShieldEnergyMaxMultiplier, wearer);
            }

            return(result);
        }
示例#7
0
        public static float EnergyGainPerTick(ShieldBelt shield)
        {
            Pawn  wearer = shield.Wearer;
            float result = shield.GetStatValue(StatDefOf.EnergyShieldRechargeRate, true) / 60f;

            if (wearer != null)
            {
                result *= wearer.GetStatValueForPawn(BStatDefOf.EnergyShieldRechargeRateMultiplier, wearer);
            }

            return(result);
        }
示例#8
0
 static void Postfix(DamageInfo dinfo, bool __result, ShieldBelt __instance)
 {
     if (__result && __instance.Wearer != null && __instance.Wearer.Map != null)
     {
         if (dinfo.Def != DamageDefOf.EMP)
         {
             var amount = dinfo.Amount * Traverse.Create(__instance).Field("EnergyLossPerDamage").GetValue <float>() * 100;
             MoteMaker.ThrowText(__instance.Wearer.DrawPos, __instance.Wearer.Map, ShieldBeltOutputString(__instance, amount), 3.65f);
         }
         if (__instance.ShieldState == ShieldState.Resetting)
         {
             MoteMaker.ThrowText(__instance.Wearer.DrawPos, __instance.Wearer.Map, "PERSONALSHIELD_BROKEN".Translate(), 3.65f);
         }
     }
 }
        private static void ApplySuppression(ProjectileCE __instance, IntVec3 OriginIV3, Pawn pawn, Thing launcher, ref float suppressionAmount)
        {
            ShieldBelt shieldBelt = null;
            bool       humanlike  = pawn.RaceProps.Humanlike;

            if (humanlike)
            {
                List <Apparel> wornApparel = pawn.apparel.WornApparel;
                for (int i = 0; i < wornApparel.Count; i++)
                {
                    ShieldBelt shieldBelt2 = wornApparel[i] as ShieldBelt;
                    bool       flag        = shieldBelt2 != null;
                    if (flag)
                    {
                        shieldBelt = shieldBelt2;
                        break;
                    }
                }
            }
            CompSuppressable compSuppressable = pawn.TryGetCompFast <CompSuppressable>();
            bool             flag2;

            if (compSuppressable != null)
            {
                Faction faction = pawn.Faction;
                Thing   thing   = launcher;
                if (faction != ((thing != null) ? thing.Faction : null))
                {
                    flag2 = (shieldBelt == null || shieldBelt.ShieldState == ShieldState.Resetting);
                    goto IL_93;
                }
            }
            flag2 = false;
IL_93:
            bool flag3 = flag2;

            if (flag3)
            {
                suppressionAmount = (float)__instance.def.projectile.GetDamageAmount(1f, null);
                ProjectilePropertiesCE projectilePropertiesCE = __instance.def.projectile as ProjectilePropertiesCE;
                float num  = (projectilePropertiesCE != null) ? projectilePropertiesCE.armorPenetrationSharp : 0f;
                float num2 = (num <= 0f) ? 0f : (1f - Mathf.Clamp(pawn.GetStatValue(CE_StatDefOf.AverageSharpArmor, true) * 0.5f / num, 0f, 1f));
                suppressionAmount *= num2;
                compSuppressable.AddSuppression(suppressionAmount, OriginIV3);
            }
        }
示例#10
0
 internal static void Postfix(ShieldBelt __instance, ref int ___ticksToReset, int ___StartingTicksToReset)
 {
     if (!Controller.settings.TurretsBreakShields)
     {
         return;
     }
     if (__instance.Wearer?.CurJob?.def == JobDefOf.ManTurret && (__instance.Wearer?.jobs?.curDriver?.OnLastToil ?? false))
     {
         if (__instance.ShieldState == ShieldState.Active)
         {
             Traverse.Create(__instance).Method("Break").GetValue();
             ___ticksToReset = SHORT_SHIELD_RECHARGE_TIME;
         }
         if (___ticksToReset < SHORT_SHIELD_RECHARGE_TIME)
         {
             ___ticksToReset = SHORT_SHIELD_RECHARGE_TIME;
         }
     }
 }
示例#11
0
        public static void PostFix(ref ShieldBelt __instance, ref bool __result, ref float ___energy, DamageInfo dinfo)
        {
            if (__instance.ShieldState != ShieldState.Active)
            {
                __result = false;
                return;
            }

            var haywire = DefDatabase <DamageDef> .GetNamed("GGHaywireEMP");

            if (dinfo.Def != haywire)
            {
                return;
            }

            ___energy = 0f;
            NonPublicMethods.ShieldBelt_Break(__instance);
            __result = false;
        }
        static bool Prefix(ShieldBelt __instance)
        {
            bool             ShouldDisplay = Traverse.Create(__instance).Property("ShouldDisplay").GetValue <bool>();
            ExtendedPawnData pawnData      = Base.Instance.GetExtendedDataStorage().GetExtendedDataFor(__instance.Wearer);
            Pawn             mount         = pawnData.mount;

            if (mount == null)
            {
                return(true);
            }

            if (__instance.ShieldState == ShieldState.Active && ShouldDisplay)
            {
                float    energy = Traverse.Create(__instance).Field("energy").GetValue <float>();
                int      lastAbsorbDamageTick = Traverse.Create(__instance).Field("lastAbsorbDamageTick").GetValue <int>();
                Vector3  impactAngleVect      = Traverse.Create(__instance).Field("impactAngleVect").GetValue <Vector3>();
                Material BubbleMat            = MaterialPool.MatFrom("Other/ShieldBubble", ShaderDatabase.Transparent);
                ;

                float   num    = Mathf.Lerp(1.2f, 1.55f, energy);
                Vector3 vector = __instance.Wearer.Drawer.DrawPos;
                vector.z += pawnData.drawOffset;
                vector.y  = Altitudes.AltitudeFor(AltitudeLayer.MoteOverhead);
                int num2 = Find.TickManager.TicksGame - lastAbsorbDamageTick;
                if (num2 < 8)
                {
                    float num3 = (float)(8 - num2) / 8f * 0.05f;
                    vector += impactAngleVect * num3;
                    num    -= num3;
                }
                float     angle  = (float)Rand.Range(0, 360);
                Vector3   s      = new Vector3(num, 1f, num);
                Matrix4x4 matrix = default(Matrix4x4);
                matrix.SetTRS(vector, Quaternion.AngleAxis(angle, Vector3.up), s);
                Graphics.DrawMesh(MeshPool.plane10, matrix, BubbleMat, 0);
            }
            return(false);
        }