protected virtual void Explode()
        {
            this.Destroy(DestroyMode.Vanish);
            ProjectilePropertiesCE propsCE     = def.projectile as ProjectilePropertiesCE;
            ThingDef preExplosionSpawnThingDef = this.def.projectile.preExplosionSpawnThingDef;
            float    explosionSpawnChance      = this.def.projectile.explosionSpawnChance;

            GenExplosion.DoExplosion(base.Position,
                                     base.Map,
                                     this.def.projectile.explosionRadius,
                                     this.def.projectile.damageDef,
                                     this.launcher,
                                     this.def.projectile.soundExplode,
                                     this.def,
                                     this.equipmentDef,
                                     this.def.projectile.postExplosionSpawnThingDef,
                                     this.def.projectile.explosionSpawnChance,
                                     1,
                                     propsCE == null ? false : propsCE.damageAdjacentTiles,
                                     preExplosionSpawnThingDef,
                                     this.def.projectile.explosionSpawnChance,
                                     1);
            CompExplosiveCE comp = this.TryGetComp <CompExplosiveCE>();

            if (comp != null)
            {
                comp.Explode(launcher, this.Position, Find.VisibleMap);
            }
        }
Пример #2
0
        protected virtual void Explode()
        {
            Map map = base.Map;

            this.Destroy(DestroyMode.Vanish);
            ProjectilePropertiesCE propsCE     = def.projectile as ProjectilePropertiesCE;
            ThingDef preExplosionSpawnThingDef = this.def.projectile.preExplosionSpawnThingDef;
            float    explosionSpawnChance      = this.def.projectile.explosionSpawnChance;

            GenExplosion.DoExplosion(base.Position,
                                     map,
                                     this.def.projectile.explosionRadius,
                                     this.def.projectile.damageDef,
                                     this.launcher,
                                     this.def.projectile.soundExplode,
                                     this.def,
                                     this.equipmentDef,
                                     this.def.projectile.postExplosionSpawnThingDef,
                                     this.def.projectile.explosionSpawnChance,
                                     1,
                                     false, // propsCE == null ? false : propsCE.damageAdjacentTiles,
                                     preExplosionSpawnThingDef,
                                     this.def.projectile.explosionSpawnChance,
                                     1);
            ThrowBigExplode(base.Position.ToVector3Shifted() + Gen.RandomHorizontalVector(def.projectile.explosionRadius * 0.5f), map, def.projectile.explosionRadius * 0.4f);
            CompExplosiveCE comp = this.TryGetComp <CompExplosiveCE>();

            if (comp != null)
            {
                comp.Explode(launcher, this.Position, Find.VisibleMap);
            }
        }
Пример #3
0
        //Unmodified
        protected virtual void Impact(Thing hitThing)
        {
            CompExplosiveCE comp = this.TryGetComp <CompExplosiveCE>();

            if (comp != null && launcher != null && this.Position.IsValid)
            {
                comp.Explode(launcher, Position, Find.VisibleMap);
            }
            Destroy(DestroyMode.Vanish);
        }
Пример #4
0
        protected virtual void Impact(Thing hitThing)
        {
            CompExplosiveCE comp = this.TryGetComp <CompExplosiveCE>();

            if (comp != null && ExactPosition.ToIntVec3().IsValid)
            {
                comp.Explode(launcher, ExactPosition, Find.CurrentMap);
            }

            //Spawn things if not an explosive but preExplosionSpawnThingDef != null
            if (Controller.settings.EnableAmmoSystem &&
                Controller.settings.ReuseNeolithicProjectiles &&
                comp == null &&
                Position.IsValid &&
                def.projectile.preExplosionSpawnChance > 0 &&
                def.projectile.preExplosionSpawnThingDef != null &&
                Rand.Value < def.projectile.preExplosionSpawnChance)
            {
                var thingDef = def.projectile.preExplosionSpawnThingDef;

                if (thingDef.IsFilth && Position.Walkable(this.Map))
                {
                    FilthMaker.MakeFilth(Position, Map, thingDef, 1);
                }
                else
                {
                    Thing reusableAmmo = ThingMaker.MakeThing(thingDef, null);
                    reusableAmmo.stackCount = 1;
                    reusableAmmo.SetForbidden(true, false);
                    GenPlace.TryPlaceThing(reusableAmmo, Position, Map, ThingPlaceMode.Near, null);
                    LessonAutoActivator.TeachOpportunity(CE_ConceptDefOf.CE_ReusableNeolithicProjectiles, reusableAmmo, OpportunityType.GoodToKnow);
                }
            }

            // Opt-out for things without explosionRadius
            if (def.projectile.explosionRadius > 0 && ExactPosition.y < SuppressionRadius)
            {
                // Apply suppression around impact area
                var suppressThings = GenRadial.RadialDistinctThingsAround(ExactPosition.ToIntVec3(), Map, SuppressionRadius + def.projectile.explosionRadius, true);
                foreach (Thing thing in suppressThings)
                {
                    Pawn pawn = thing as Pawn;
                    if (pawn != null)
                    {
                        ApplySuppression(pawn);
                    }
                }
            }

            Destroy();
        }
Пример #5
0
        private bool TryDetonate(float scale = 1)
        {
            CompExplosiveCE comp = this.TryGetComp <CompExplosiveCE>();

            if (comp != null)
            {
                if (Rand.Chance(Mathf.Clamp01(0.75f - Mathf.Pow(HitPoints / MaxHitPoints, 2))))
                {
                    comp.Explode(this, Position.ToVector3Shifted(), Map, Mathf.Pow(scale, 0.333f));
                }
                return(true);
            }
            return(false);
        }
Пример #6
0
        private bool TryDetonate(float stackCountScale = 1)
        {
            if (Find.Maps.IndexOf(Map) < 0)
            {
                return(false);
            }

            CompExplosiveCE comp     = this.TryGetComp <CompExplosiveCE>();
            var             detProps = AmmoDef?.detonateProjectile?.projectile;

            if (comp != null || detProps != null)
            {
                if (Rand.Chance(Mathf.Clamp01(0.75f - Mathf.Pow(HitPoints / MaxHitPoints, 2))))
                {
                    if (comp != null)
                    {
                        comp.Explode(this, Position.ToVector3Shifted(), Map, Mathf.Pow(stackCountScale, 0.333f), null, new List <Thing>()
                        {
                            this
                        });
                    }
                    else
                    {
                        this.TryGetComp <CompFragments>()?.Throw(Position.ToVector3Shifted(), Map, this); //Mathf.Pow(scale, 0.333f));
                    }
                    if (detProps != null)
                    {
                        GenExplosionCE.DoExplosion(Position, Map, detProps.explosionRadius, detProps.damageDef,
                                                   this, detProps.GetDamageAmount(1), GenExplosionCE.GetExplosionAP(detProps),
                                                   detProps.soundExplode,
                                                   null, def, null, detProps.postExplosionSpawnThingDef, detProps.postExplosionSpawnChance,
                                                   detProps.postExplosionSpawnThingCount, detProps.applyDamageToExplosionCellsNeighbors,
                                                   detProps.preExplosionSpawnThingDef, detProps.preExplosionSpawnChance, detProps.preExplosionSpawnThingCount,
                                                   detProps.explosionChanceToStartFire, detProps.explosionDamageFalloff, null, new List <Thing>()
                        {
                            this
                        }, 0f, Mathf.Pow(stackCountScale, 0.333f));
                    }
                }

                return(true);
            }
            return(false);
        }
Пример #7
0
        protected virtual void Impact(Thing hitThing)
        {
            CompExplosiveCE comp = this.TryGetComp <CompExplosiveCE>();

            if (comp != null && Position.IsValid)
            {
                comp.Explode(launcher, Position, Find.VisibleMap);
            }

            // Apply suppression around impact area
            var suppressThings = GenRadial.RadialDistinctThingsAround(Position, Map, SuppressionRadius + def.projectile.explosionRadius, true);

            foreach (Thing thing in suppressThings)
            {
                Pawn pawn = thing as Pawn;
                if (pawn != null)
                {
                    ApplySuppression(pawn);
                }
            }

            Destroy();
        }