Ejemplo n.º 1
0
 protected virtual void defaultDamageThing(Explosion explosion, Thing t, List <Thing> damagedThings, IntVec3 cell)
 {
     if (t.def.category != ThingCategory.Mote && t.def.category != ThingCategory.Ethereal)
     {
         if (!damagedThings.Contains(t))
         {
             damagedThings.Add(t);
             if (this.def == DamageDefOf.Bomb && t.def == ThingDefOf.Fire && !t.Destroyed)
             {
                 t.Destroy(DestroyMode.Vanish);
             }
             else
             {
                 float num;
                 if (t.Position == explosion.Position)
                 {
                     num = (float)Rand.RangeInclusive(0, 359);
                 }
                 else
                 {
                     num = (t.Position - explosion.Position).AngleFlat;
                 }
                 DamageDef  damageDef          = this.def;
                 float      amount             = (float)explosion.GetDamageAmountAt(cell);
                 float      armorPenetrationAt = explosion.GetArmorPenetrationAt(cell);
                 float      angle      = num;
                 Thing      instigator = explosion.instigator;
                 ThingDef   weapon     = explosion.weapon;
                 DamageInfo dinfo      = new DamageInfo(damageDef, amount, armorPenetrationAt, angle, instigator, null, weapon, DamageInfo.SourceCategory.ThingOrUnknown, explosion.intendedTarget);
                 if (this.def.explosionAffectOutsidePartsOnly)
                 {
                     dinfo.SetBodyRegion(BodyPartHeight.Undefined, BodyPartDepth.Outside);
                 }
                 if (t.def.category == ThingCategory.Building)
                 {
                     int num2 = Mathf.RoundToInt(dinfo.Amount * this.def.explosionBuildingDamageFactor);
                     dinfo.SetAmount((float)num2);
                 }
                 else if (t.def.category == ThingCategory.Plant)
                 {
                     int num3 = Mathf.RoundToInt(dinfo.Amount * this.def.explosionPlantDamageFactor);
                     dinfo.SetAmount((float)num3);
                 }
                 BattleLogEntry_ExplosionImpact battleLogEntry_ExplosionImpact = null;
                 Pawn pawn = t as Pawn;
                 if (pawn != null)
                 {
                     battleLogEntry_ExplosionImpact = new BattleLogEntry_ExplosionImpact(explosion.instigator, t, explosion.weapon, explosion.projectile, this.def);
                     Find.BattleLog.Add(battleLogEntry_ExplosionImpact);
                 }
                 DamageWorker.DamageResult damageResult = t.TakeDamage(dinfo);
                 damageResult.AssociateWithLog(battleLogEntry_ExplosionImpact);
                 if (pawn != null && damageResult.wounded && pawn.stances != null)
                 {
                     pawn.stances.StaggerFor(95);
                 }
             }
         }
     }
 }
Ejemplo n.º 2
0
        // Token: 0x060004DA RID: 1242 RVA: 0x000187A4 File Offset: 0x000169A4
        protected override void ExplosionDamageThing(Explosion explosion, Thing t, List <Thing> damagedThings, List <Thing> ignoredThings, IntVec3 cell)
        {
            if (t.def.category == ThingCategory.Mote || t.def.category == ThingCategory.Ethereal)
            {
                return;
            }
            if (damagedThings.Contains(t))
            {
                return;
            }
            damagedThings.Add(t);
            if (ignoredThings != null && ignoredThings.Contains(t))
            {
                return;
            }
            if (this.def == DamageDefOf.Bomb && t.def == ThingDefOf.Fire && !t.Destroyed)
            {
                t.Destroy(DestroyMode.Vanish);
                return;
            }
            float angle;

            if (t.Position == explosion.Position)
            {
                angle = (float)Rand.RangeInclusive(0, 359);
            }
            else
            {
                angle = (t.Position - explosion.Position).AngleFlat;
            }
            DamageInfo dinfo = new DamageInfo(this.def, (float)explosion.GetDamageAmountAt(cell), explosion.GetArmorPenetrationAt(cell), angle, explosion.instigator, null, explosion.weapon, DamageInfo.SourceCategory.ThingOrUnknown, explosion.intendedTarget);

            if (this.def.explosionAffectOutsidePartsOnly)
            {
                dinfo.SetBodyRegion(BodyPartHeight.Undefined, BodyPartDepth.Outside);
            }
            BattleLogEntry_ExplosionImpact battleLogEntry_ExplosionImpact = null;
            Pawn pawn = t as Pawn;

            if (pawn != null)
            {
                battleLogEntry_ExplosionImpact = new BattleLogEntry_ExplosionImpact(explosion.instigator, t, explosion.weapon, explosion.projectile, this.def);
                Find.BattleLog.Add(battleLogEntry_ExplosionImpact);
            }
            DamageWorker.DamageResult damageResult = t.TakeDamage(dinfo);
            damageResult.AssociateWithLog(battleLogEntry_ExplosionImpact);
            if (pawn != null && damageResult.wounded && pawn.stances != null)
            {
                pawn.stances.StaggerFor(95);
            }
        }