Exemple #1
0
        protected void Detonate(Map map, bool ignoreUnspawned = false)
        {
            if (!ignoreUnspawned && !parent.SpawnedOrAnyParentSpawned)
            {
                return;
            }
            CompProperties_Explosive props = Props;
            float num = ExplosiveRadius();

            if (props.explosiveExpandPerFuel > 0f && parent.GetComp <CompRefuelable>() != null)
            {
                parent.GetComp <CompRefuelable>().ConsumeFuel(parent.GetComp <CompRefuelable>().Fuel);
            }
            if (props.destroyThingOnExplosionSize <= num && !parent.Destroyed)
            {
                destroyedThroughDetonation = true;
                parent.Kill();
            }
            EndWickSustainer();
            wickStarted = false;
            if (map == null)
            {
                Log.Warning("Tried to detonate CompExplosive in a null map.");
                return;
            }
            if (props.explosionEffect != null)
            {
                Effecter effecter = props.explosionEffect.Spawn();
                effecter.Trigger(new TargetInfo(parent.PositionHeld, map), new TargetInfo(parent.PositionHeld, map));
                effecter.Cleanup();
            }
            GenExplosion.DoExplosion(instigator: (instigator == null || instigator.HostileTo(parent.Faction)) ? parent : instigator, center: parent.PositionHeld, map: map, radius: num, damType: props.explosiveDamageType, damAmount: props.damageAmountBase, armorPenetration: props.armorPenetrationBase, explosionSound: props.explosionSound, weapon: null, projectile: null, intendedTarget: null, postExplosionSpawnThingDef: props.postExplosionSpawnThingDef, postExplosionSpawnChance: props.postExplosionSpawnChance, postExplosionSpawnThingCount: props.postExplosionSpawnThingCount, applyDamageToExplosionCellsNeighbors: props.applyDamageToExplosionCellsNeighbors, preExplosionSpawnThingDef: props.preExplosionSpawnThingDef, preExplosionSpawnChance: props.preExplosionSpawnChance, preExplosionSpawnThingCount: props.preExplosionSpawnThingCount, chanceToStartFire: props.chanceToStartFire, damageFalloff: props.damageFalloff, direction: null, ignoredThings: thingsIgnoredByExplosion);
        }
        public override void DrawGhost(ThingDef def, IntVec3 center, Rot4 rot, Color ghostCol, Thing thing = null)
        {
            CompProperties_Explosive compProperties = def.GetCompProperties <CompProperties_Explosive>();

            if (compProperties != null)
            {
                GenDraw.DrawRadiusRing(center, compProperties.explosiveRadius);
            }
        }
Exemple #3
0
        public float ExplosiveRadius()
        {
            CompProperties_Explosive props = this.Props;
            float num = props.explosiveRadius;

            if (this.parent.stackCount > 1 && props.explosiveExpandPerStackcount > 0f)
            {
                num += Mathf.Sqrt((float)(this.parent.stackCount - 1) * props.explosiveExpandPerStackcount);
            }
            if (props.explosiveExpandPerFuel > 0f && this.parent.GetComp <CompRefuelable>() != null)
            {
                num += Mathf.Sqrt(this.parent.GetComp <CompRefuelable>().Fuel *props.explosiveExpandPerFuel);
            }
            return(num);
        }
Exemple #4
0
        protected void Detonate(Map map)
        {
            if (!this.parent.SpawnedOrAnyParentSpawned)
            {
                return;
            }
            CompProperties_Explosive props = this.Props;
            float num = this.ExplosiveRadius();

            if (props.explosiveExpandPerFuel > 0f && this.parent.GetComp <CompRefuelable>() != null)
            {
                this.parent.GetComp <CompRefuelable>().ConsumeFuel(this.parent.GetComp <CompRefuelable>().Fuel);
            }
            if (props.destroyThingOnExplosionSize <= num && !this.parent.Destroyed)
            {
                this.destroyedThroughDetonation = true;
                this.parent.Kill(null, null);
            }
            this.EndWickSustainer();
            this.wickStarted = false;
            if (map == null)
            {
                Log.Warning("Tried to detonate CompExplosive in a null map.", false);
                return;
            }
            if (props.explosionEffect != null)
            {
                Effecter effecter = props.explosionEffect.Spawn();
                effecter.Trigger(new TargetInfo(this.parent.PositionHeld, map, false), new TargetInfo(this.parent.PositionHeld, map, false));
                effecter.Cleanup();
            }
            IntVec3   positionHeld        = this.parent.PositionHeld;
            float     radius              = num;
            DamageDef explosiveDamageType = props.explosiveDamageType;
            Thing     thing                        = this.instigator ?? this.parent;
            int       damageAmountBase             = props.damageAmountBase;
            float     armorPenetrationBase         = props.armorPenetrationBase;
            SoundDef  explosionSound               = props.explosionSound;
            ThingDef  postExplosionSpawnThingDef   = props.postExplosionSpawnThingDef;
            float     postExplosionSpawnChance     = props.postExplosionSpawnChance;
            int       postExplosionSpawnThingCount = props.postExplosionSpawnThingCount;

            GenExplosion.DoExplosion(positionHeld, map, radius, explosiveDamageType, thing, damageAmountBase, armorPenetrationBase, explosionSound, null, null, null, postExplosionSpawnThingDef, postExplosionSpawnChance, postExplosionSpawnThingCount, props.applyDamageToExplosionCellsNeighbors, props.preExplosionSpawnThingDef, props.preExplosionSpawnChance, props.preExplosionSpawnThingCount, props.chanceToStartFire, props.damageFalloff);
        }