示例#1
0
            static bool CheckShieldCollision(ProjectileCE __instance, Vector2 ___origin, int ___ticksToImpact)
            {
                var current = __instance.ExactPosition;
                var last    = current - __instance.ExactMinusLastPos;

                return(!TryBlockProjectileCE(
                           __instance,
                           last,
                           current,
                           ___ticksToImpact,
                           ___origin, (shield, point) =>
                {
                    if (IsOverhead(__instance))
                    {
                        ExplosionUtility.DoSmokeExplosion(__instance, GetExplosionSound(__instance));
                        __instance.Destroy();
                    }
                    else
                    {
                        // check if it is an explosive projectile to impact
                        if (!IsExplosive(__instance) || !Impact(__instance, shield, point))
                        {
                            // this is a regular projectile, remove it
                            __instance.Destroy();
                        }
                    }
                }));
            }
示例#2
0
            static bool CheckShieldCollision(ProjectileCE __instance, bool __result, Vector2 ___origin, int ___ticksToImpact)
            {
                var current = __instance.ExactPosition;
                var last    = current - __instance.ExactMinusLastPos;

                var shouldBlock = TryBlockProjectileCE(
                    __instance,
                    last,
                    current,
                    ___ticksToImpact,
                    ___origin);

                if (shouldBlock)
                {
                    if (ShouldImpact(__instance))
                    {
                        __instance.ExactPosition = last;
                        impactMethod.Invoke(__instance, new object[] { null });
                    }
                    else
                    {
                        __instance.Destroy();
                    }
                }
                return(!shouldBlock);
            }
示例#3
0
            static bool BlockMortarImpacts(ProjectileCE __instance, int ___ticksToImpact, Vector2 ___origin)
            {
                if (!__instance.def.projectile.flyOverhead)
                {
                    return(true);
                }

                var shouldBlock = TryBlockOverheadProjectileCE(__instance, __instance.ExactPosition, ___ticksToImpact, ___origin);

                if (shouldBlock)
                {
                    __instance.Destroy();
                }
                return(!shouldBlock);
            }
        private static void Impact(ProjectileCE __instance, Thing launcher, ThingDef equipmentDef, Thing hitThing, IntVec3 OriginIV3, Vector2 origin, Vector2 Destination, int StartingTicksToImpact, int ticksToImpact, int IntTicksToImpact, ref float suppressionAmount)
        {
            List <Thing> list = new List <Thing>();

            if (__instance.Position.IsValid && __instance.def.projectile.preExplosionSpawnChance > 0f && __instance.def.projectile.preExplosionSpawnThingDef != null && (Controller.settings.EnableAmmoSystem || !(__instance.def.projectile.preExplosionSpawnThingDef is AmmoDef)) && Rand.Value < __instance.def.projectile.preExplosionSpawnChance)
            {
                ThingDef preExplosionSpawnThingDef = __instance.def.projectile.preExplosionSpawnThingDef;
                if (preExplosionSpawnThingDef.IsFilth && __instance.Position.Walkable(__instance.Map))
                {
                    FilthMaker.TryMakeFilth(__instance.Position, __instance.Map, preExplosionSpawnThingDef, 1, FilthSourceFlags.None);
                }
                else
                {
                    bool reuseNeolithicProjectiles = Controller.settings.ReuseNeolithicProjectiles;
                    if (reuseNeolithicProjectiles)
                    {
                        Thing thing = ThingMaker.MakeThing(preExplosionSpawnThingDef, null);
                        thing.stackCount = 1;
                        thing.SetForbidden(true, false);
                        GenPlace.TryPlaceThing(thing, __instance.Position, __instance.Map, ThingPlaceMode.Near, null, null, default(Rot4));
                        LessonAutoActivator.TeachOpportunity(CE_ConceptDefOf.CE_ReusableNeolithicProjectiles, thing, OpportunityType.GoodToKnow);
                        list.Add(thing);
                    }
                }
            }
            Vector3 vector = (hitThing != null) ? hitThing.DrawPos : __instance.ExactPosition;
            bool    flag3  = !vector.ToIntVec3().IsValid;

            if (flag3)
            {
                __instance.Destroy(DestroyMode.Vanish);
            }
            else
            {
                CompExplosiveCE compExplosiveCE = __instance.TryGetCompFast <CompExplosiveCE>();
                if (compExplosiveCE == null)
                {
                    CompFragments compFragments = __instance.TryGetCompFast <CompFragments>();
                    if (compFragments != null)
                    {
                        compFragments.Throw(vector, __instance.Map, launcher, 1f);
                    }
                }
                if (compExplosiveCE != null || __instance.def.projectile.explosionRadius > 0f)
                {
                    if (hitThing is Pawn && (hitThing as Pawn).Dead)
                    {
                        list.Add((hitThing as Pawn).Corpse);
                    }
                    List <Pawn> list2     = new List <Pawn>();
                    float?      direction = new float?(origin.AngleTo(Vec2Position(__instance, origin, Destination, StartingTicksToImpact, ticksToImpact, IntTicksToImpact, -1f)));
                    bool        flag7     = __instance.def.projectile.explosionRadius > 0f;
                    if (flag7)
                    {
                        GenExplosionCE.DoExplosion(vector.ToIntVec3(), __instance.Map, __instance.def.projectile.explosionRadius, __instance.def.projectile.damageDef, launcher, __instance.def.projectile.GetDamageAmount(1f, null), GenExplosionCE.GetExplosionAP(__instance.def.projectile), __instance.def.projectile.soundExplode, equipmentDef, __instance.def, null, __instance.def.projectile.postExplosionSpawnThingDef, __instance.def.projectile.postExplosionSpawnChance, __instance.def.projectile.postExplosionSpawnThingCount, __instance.def.projectile.applyDamageToExplosionCellsNeighbors, __instance.def.projectile.preExplosionSpawnThingDef, __instance.def.projectile.preExplosionSpawnChance, __instance.def.projectile.preExplosionSpawnThingCount, __instance.def.projectile.explosionChanceToStartFire, __instance.def.projectile.explosionDamageFalloff, direction, list, vector.y, 1f, false, null);
                        bool flag8 = vector.y < 3f;
                        if (flag8)
                        {
                            list2.AddRange(from x in GenRadial.RadialDistinctThingsAround(vector.ToIntVec3(), __instance.Map, 3f + __instance.def.projectile.explosionRadius, true)
                                           where x is Pawn
                                           select x as Pawn);
                        }
                    }
                    bool flag9 = compExplosiveCE != null;
                    if (flag9)
                    {
                        compExplosiveCE.Explode(__instance, vector, __instance.Map, 1f, direction, list);
                        bool flag10 = vector.y < 3f;
                        if (flag10)
                        {
                            list2.AddRange(from x in GenRadial.RadialDistinctThingsAround(vector.ToIntVec3(), __instance.Map, 3f + (compExplosiveCE.props as CompProperties_ExplosiveCE).explosiveRadius, true)
                                           where x is Pawn
                                           select x as Pawn);
                        }
                    }
                    foreach (Pawn pawn in list2)
                    {
                        ApplySuppression(__instance, OriginIV3, pawn, launcher, ref suppressionAmount);
                    }
                }
                __instance.Destroy(DestroyMode.Vanish);
            }
        }