Esempio n. 1
0
 public IEnumerable <IntVec3> ExplosionCellsToHit(Explosion explosion)
 {
     return(ExplosionCellsToHit(explosion.Position, explosion.Map, explosion.radius));
 }
Esempio n. 2
0
 public virtual void Notify_Explosion(Explosion explosion)
 {
 }
Esempio n. 3
0
 // Token: 0x060004D7 RID: 1239 RVA: 0x00018398 File Offset: 0x00016598
 public override void ExplosionStart(Explosion explosion, List <IntVec3> cellsToAffect)
 {
 }
        protected virtual void ExplosionDamageThing(Explosion explosion, Thing t, List <Thing> damagedThings, IntVec3 cell)
        {
            if (t.def.category == ThingCategory.Mote || t.def.category == ThingCategory.Ethereal)
            {
                return;
            }
            if (damagedThings.Contains(t))
            {
                return;
            }
            damagedThings.Add(t);
            if (this.def == DamageDefOf.Bomb && t.def == ThingDefOf.Fire && !t.Destroyed)
            {
                t.Destroy(DestroyMode.Vanish);
                return;
            }
            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);
            }
        }
Esempio n. 5
0
        public virtual void ExplosionAffectCell(Explosion explosion, IntVec3 c, List <Thing> damagedThings, List <Thing> ignoredThings, bool canThrowMotes)
        {
            if (def.explosionCellMote != null && canThrowMotes)
            {
                Mote mote = c.GetFirstThing(explosion.Map, def.explosionCellMote) as Mote;
                if (mote != null)
                {
                    mote.spawnTick = Find.TickManager.TicksGame;
                }
                else
                {
                    float t     = Mathf.Clamp01((explosion.Position - c).LengthHorizontal / explosion.radius);
                    Color color = Color.Lerp(def.explosionColorCenter, def.explosionColorEdge, t);
                    MoteMaker.ThrowExplosionCell(c, explosion.Map, def.explosionCellMote, color);
                }
            }
            thingsToAffect.Clear();
            float        num  = float.MinValue;
            bool         flag = false;
            List <Thing> list = explosion.Map.thingGrid.ThingsListAt(c);

            for (int i = 0; i < list.Count; i++)
            {
                Thing thing = list[i];
                if (thing.def.category != ThingCategory.Mote && thing.def.category != ThingCategory.Ethereal)
                {
                    thingsToAffect.Add(thing);
                    if (thing.def.Fillage == FillCategory.Full && thing.def.Altitude > num)
                    {
                        flag = true;
                        num  = thing.def.Altitude;
                    }
                }
            }
            for (int j = 0; j < thingsToAffect.Count; j++)
            {
                if (thingsToAffect[j].def.Altitude >= num)
                {
                    ExplosionDamageThing(explosion, thingsToAffect[j], damagedThings, ignoredThings, c);
                }
            }
            if (!flag)
            {
                ExplosionDamageTerrain(explosion, c);
            }
            if (def.explosionSnowMeltAmount > 0.0001f)
            {
                float lengthHorizontal = (c - explosion.Position).LengthHorizontal;
                float num2             = 1f - lengthHorizontal / explosion.radius;
                if (num2 > 0f)
                {
                    explosion.Map.snowGrid.AddDepth(c, (0f - num2) * def.explosionSnowMeltAmount);
                }
            }
            if (def != DamageDefOf.Bomb && def != DamageDefOf.Flame)
            {
                return;
            }
            List <Thing> list2 = explosion.Map.listerThings.ThingsOfDef(ThingDefOf.RectTrigger);

            for (int k = 0; k < list2.Count; k++)
            {
                RectTrigger rectTrigger = (RectTrigger)list2[k];
                if (rectTrigger.activateOnExplosion && rectTrigger.Rect.Contains(c))
                {
                    rectTrigger.ActivatedBy(null);
                }
            }
        }