コード例 #1
0
ファイル: GenExplosion.cs プロジェクト: sachdevs/RW-Decompile
        public static void DoExplosion(IntVec3 center, Map map, float radius, DamageDef damType, Thing instigator, int damAmount = -1, SoundDef explosionSound = null, ThingDef weapon = null, ThingDef projectile = null, ThingDef postExplosionSpawnThingDef = null, float postExplosionSpawnChance = 0f, int postExplosionSpawnThingCount = 1, bool applyDamageToExplosionCellsNeighbors = false, ThingDef preExplosionSpawnThingDef = null, float preExplosionSpawnChance = 0f, int preExplosionSpawnThingCount = 1, float chanceToStartFire = 0f, bool dealMoreDamageAtCenter = false)
        {
            if (map == null)
            {
                Log.Warning("Tried to do explosion in a null map.");
                return;
            }
            if (damAmount == 0)
            {
                damAmount = 1;
            }
            Explosion explosion = (Explosion)GenSpawn.Spawn(ThingDefOf.Explosion, center, map);

            explosion.radius     = radius;
            explosion.damType    = damType;
            explosion.instigator = instigator;
            explosion.damAmount  = ((damAmount <= 0) ? damType.explosionDamage : damAmount);
            explosion.weapon     = weapon;
            explosion.projectile = projectile;
            explosion.preExplosionSpawnThingDef            = preExplosionSpawnThingDef;
            explosion.preExplosionSpawnChance              = preExplosionSpawnChance;
            explosion.preExplosionSpawnThingCount          = preExplosionSpawnThingCount;
            explosion.postExplosionSpawnThingDef           = postExplosionSpawnThingDef;
            explosion.postExplosionSpawnChance             = postExplosionSpawnChance;
            explosion.postExplosionSpawnThingCount         = postExplosionSpawnThingCount;
            explosion.applyDamageToExplosionCellsNeighbors = applyDamageToExplosionCellsNeighbors;
            explosion.chanceToStartFire      = chanceToStartFire;
            explosion.dealMoreDamageAtCenter = dealMoreDamageAtCenter;
            explosion.StartExplosion(explosionSound);
        }
コード例 #2
0
ファイル: GenExplosion.cs プロジェクト: KraigXu/GameProject
        public static void DoExplosion(IntVec3 center, Map map, float radius, DamageDef damType, Thing instigator, int damAmount = -1, float armorPenetration = -1f, SoundDef explosionSound = null, ThingDef weapon = null, ThingDef projectile = null, Thing intendedTarget = null, ThingDef postExplosionSpawnThingDef = null, float postExplosionSpawnChance = 0f, int postExplosionSpawnThingCount = 1, bool applyDamageToExplosionCellsNeighbors = false, ThingDef preExplosionSpawnThingDef = null, float preExplosionSpawnChance = 0f, int preExplosionSpawnThingCount = 1, float chanceToStartFire = 0f, bool damageFalloff = false, float?direction = null, List <Thing> ignoredThings = null)
        {
            if (map == null)
            {
                Log.Warning("Tried to do explosion in a null map.");
                return;
            }
            if (damAmount < 0)
            {
                damAmount        = damType.defaultDamage;
                armorPenetration = damType.defaultArmorPenetration;
                if (damAmount < 0)
                {
                    Log.ErrorOnce("Attempted to trigger an explosion without defined damage", 91094882);
                    damAmount = 1;
                }
            }
            if (armorPenetration < 0f)
            {
                armorPenetration = (float)damAmount * 0.015f;
            }
            Explosion obj            = (Explosion)GenSpawn.Spawn(ThingDefOf.Explosion, center, map);
            IntVec3?  needLOSToCell  = null;
            IntVec3?  needLOSToCell2 = null;

            if (direction.HasValue)
            {
                CalculateNeededLOSToCells(center, map, direction.Value, out needLOSToCell, out needLOSToCell2);
            }
            obj.radius                               = radius;
            obj.damType                              = damType;
            obj.instigator                           = instigator;
            obj.damAmount                            = damAmount;
            obj.armorPenetration                     = armorPenetration;
            obj.weapon                               = weapon;
            obj.projectile                           = projectile;
            obj.intendedTarget                       = intendedTarget;
            obj.preExplosionSpawnThingDef            = preExplosionSpawnThingDef;
            obj.preExplosionSpawnChance              = preExplosionSpawnChance;
            obj.preExplosionSpawnThingCount          = preExplosionSpawnThingCount;
            obj.postExplosionSpawnThingDef           = postExplosionSpawnThingDef;
            obj.postExplosionSpawnChance             = postExplosionSpawnChance;
            obj.postExplosionSpawnThingCount         = postExplosionSpawnThingCount;
            obj.applyDamageToExplosionCellsNeighbors = applyDamageToExplosionCellsNeighbors;
            obj.chanceToStartFire                    = chanceToStartFire;
            obj.damageFalloff                        = damageFalloff;
            obj.needLOSToCell1                       = needLOSToCell;
            obj.needLOSToCell2                       = needLOSToCell2;
            obj.StartExplosion(explosionSound, ignoredThings);
        }
コード例 #3
0
 public static void DoExplosion(IntVec3 center, Map map, float radius, DamageDef damType, Thing instigator, int damAmount = -1, float armorPenetration = -1f, SoundDef explosionSound = null, ThingDef weapon = null, ThingDef projectile = null, Thing intendedTarget = null, ThingDef postExplosionSpawnThingDef = null, float postExplosionSpawnChance = 0f, int postExplosionSpawnThingCount = 1, bool applyDamageToExplosionCellsNeighbors = false, ThingDef preExplosionSpawnThingDef = null, float preExplosionSpawnChance = 0f, int preExplosionSpawnThingCount = 1, float chanceToStartFire = 0f, bool damageFalloff = false)
 {
     if (map == null)
     {
         Log.Warning("Tried to do explosion in a null map.", false);
     }
     else
     {
         if (damAmount < 0)
         {
             damAmount        = damType.defaultDamage;
             armorPenetration = damType.defaultArmorPenetration;
             if (damAmount < 0)
             {
                 Log.ErrorOnce("Attempted to trigger an explosion without defined damage", 91094882, false);
                 damAmount = 1;
             }
         }
         if (armorPenetration < 0f)
         {
             armorPenetration = (float)damAmount * 0.015f;
         }
         Explosion explosion = (Explosion)GenSpawn.Spawn(ThingDefOf.Explosion, center, map, WipeMode.Vanish);
         explosion.radius                               = radius;
         explosion.damType                              = damType;
         explosion.instigator                           = instigator;
         explosion.damAmount                            = damAmount;
         explosion.armorPenetration                     = armorPenetration;
         explosion.weapon                               = weapon;
         explosion.projectile                           = projectile;
         explosion.intendedTarget                       = intendedTarget;
         explosion.preExplosionSpawnThingDef            = preExplosionSpawnThingDef;
         explosion.preExplosionSpawnChance              = preExplosionSpawnChance;
         explosion.preExplosionSpawnThingCount          = preExplosionSpawnThingCount;
         explosion.postExplosionSpawnThingDef           = postExplosionSpawnThingDef;
         explosion.postExplosionSpawnChance             = postExplosionSpawnChance;
         explosion.postExplosionSpawnThingCount         = postExplosionSpawnThingCount;
         explosion.applyDamageToExplosionCellsNeighbors = applyDamageToExplosionCellsNeighbors;
         explosion.chanceToStartFire                    = chanceToStartFire;
         explosion.damageFalloff                        = damageFalloff;
         explosion.StartExplosion(explosionSound);
     }
 }