예제 #1
0
        protected void Detonate(Map map)
        {
            if (!parent.SpawnedOrAnyParentSpawned)
            {
                return;
            }
            CompProperties_Explosive_GasProp 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();
            }
            IntVec3   positionHeld        = parent.PositionHeld;
            float     radius              = num;
            DamageDef explosiveDamageType = props.explosiveDamageType;
            Thing     thing                = instigator ?? parent;
            int       damageAmountBase     = props.damageAmountBase;
            float     armorPenetrationBase = props.armorPenetrationBase;
            var       comp = parent.GetComp <CompGasTank>();

            if (comp != null)
            {
                damageAmountBase = Mathf.Clamp(damageAmountBase + (int)(comp.Storage * 0.8f), 0, 6000);
            }
            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);
        }
예제 #2
0
        public float ExplosiveRadius()
        {
            CompProperties_Explosive_GasProp props = Props;
            float num = props.explosiveRadius;

            if (parent.stackCount > 1 && props.explosiveExpandPerStackcount > 0f)
            {
                num += Mathf.Sqrt((float)(parent.stackCount - 1) * props.explosiveExpandPerStackcount);
            }
            if (props.explosiveExpandPerFuel > 0f && parent.GetComp <CompRefuelable>() != null)
            {
                num += Mathf.Sqrt(parent.GetComp <CompRefuelable>().Fuel *props.explosiveExpandPerFuel);
            }

            var comp = parent.GetComp <CompGasTank>();

            if (comp != null)
            {
                num = Mathf.Clamp(num + comp.Storage / 100, 0, 20);
            }

            return(num);
        }