예제 #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);
                 }
             }
         }
     }
 }
예제 #2
0
        private static List <DebugMenuOption> Options_Damage_BodyParts(Pawn p, DamageDef def)
        {
            if (p == null)
            {
                throw new ArgumentNullException("p");
            }
            List <DebugMenuOption> list = new List <DebugMenuOption>();

            list.Add(new DebugMenuOption("(no body part)", DebugMenuOptionMode.Action, delegate
            {
                p.TakeDamage(new DamageInfo(def, 5, -1f, null, null, null, DamageInfo.SourceCategory.ThingOrUnknown));
            }));
            foreach (BodyPartRecord current in p.RaceProps.body.AllParts)
            {
                BodyPartRecord localPart = current;
                list.Add(new DebugMenuOption(localPart.def.LabelCap, DebugMenuOptionMode.Action, delegate
                {
                    Thing arg_30_0           = p;
                    DamageDef def2           = def;
                    int amount               = 5;
                    BodyPartRecord localPart = localPart;
                    arg_30_0.TakeDamage(new DamageInfo(def2, amount, -1f, null, localPart, null, DamageInfo.SourceCategory.ThingOrUnknown));
                }));
            }
            return(list);
        }
        private static List <DebugMenuOption> Options_Damage_BodyParts(Pawn p, DamageDef def)
        {
            if (p == null)
            {
                throw new ArgumentNullException("p");
            }
            List <DebugMenuOption> list = new List <DebugMenuOption>();

            list.Add(new DebugMenuOption("(no body part)", DebugMenuOptionMode.Action, delegate()
            {
                p.TakeDamage(new DamageInfo(def, 5f, 0f, -1f, null, null, null, DamageInfo.SourceCategory.ThingOrUnknown, null));
            }));
            foreach (BodyPartRecord localPart3 in p.RaceProps.body.AllParts)
            {
                BodyPartRecord localPart = localPart3;
                list.Add(new DebugMenuOption(localPart.LabelCap, DebugMenuOptionMode.Action, delegate()
                {
                    Thing p2                  = p;
                    DamageDef def2            = def;
                    float amount              = 5f;
                    BodyPartRecord localPart2 = localPart;
                    p2.TakeDamage(new DamageInfo(def2, amount, 0f, -1f, null, localPart2, null, DamageInfo.SourceCategory.ThingOrUnknown, null));
                }));
            }
            return(list);
        }
예제 #4
0
        private static void ApplyArmor(ref float damAmount, float armorPenetration, float armorRating, Thing armorThing, ref DamageDef damageDef, Pawn pawn, out bool metalArmor)
        {
            if (armorThing != null)
            {
                metalArmor = (armorThing.def.apparel.useDeflectMetalEffect || (armorThing.Stuff != null && armorThing.Stuff.IsMetal));
            }
            else
            {
                metalArmor = pawn.RaceProps.IsMechanoid;
            }
            if (armorThing != null)
            {
                float f = damAmount * 0.25f;
                armorThing.TakeDamage(new DamageInfo(damageDef, GenMath.RoundRandom(f)));
            }
            float num   = Mathf.Max(armorRating - armorPenetration, 0f);
            float value = Rand.Value;
            float num2  = num * 0.5f;
            float num3  = num;

            if (value < num2)
            {
                damAmount = 0f;
            }
            else if (value < num3)
            {
                damAmount = GenMath.RoundRandom(damAmount / 2f);
                if (damageDef.armorCategory == DamageArmorCategoryDefOf.Sharp)
                {
                    damageDef = DamageDefOf.Blunt;
                }
            }
        }
예제 #5
0
 private void CheckApplySpreadDamage(DamageInfo dinfo, Thing t)
 {
     if ((dinfo.Def != DamageDefOf.Flame || t.FlammableNow) && Rand.Chance(0.5f))
     {
         dinfo.SetAmount((float)Mathf.CeilToInt(dinfo.Amount * Rand.Range(0.35f, 0.7f)));
         t.TakeDamage(dinfo);
     }
 }
 // Token: 0x06004B85 RID: 19333 RVA: 0x002344F0 File Offset: 0x002328F0
 private void CheckApplySpreadDamage(DamageInfo dinfo, Thing t)
 {
     if (Rand.Chance(0.5f))
     {
         dinfo.SetAmount((float)Mathf.CeilToInt(dinfo.Amount * Rand.Range(0.35f, 0.7f)));
         t.TakeDamage(dinfo);
     }
 }
예제 #7
0
        private static void GiveRandomSurgeryInjuries(Pawn p, int totalDamage, BodyPartRecord operatedPart)
        {
            IEnumerable <BodyPartRecord> source;

            if (operatedPart == null)
            {
                source = from x in p.health.hediffSet.GetNotMissingParts(BodyPartHeight.Undefined, BodyPartDepth.Undefined, null, null)
                         where !x.def.conceptual
                         select x;
            }
            else
            {
                source = from x in p.health.hediffSet.GetNotMissingParts(BodyPartHeight.Undefined, BodyPartDepth.Undefined, null, null)
                         where !x.def.conceptual
                         select x into pa
                         where pa == operatedPart || pa.parent == operatedPart || (operatedPart != null && operatedPart.parent == pa)
                         select pa;
            }
            source = from x in source
                     where HealthUtility.GetMinHealthOfPartsWeWantToAvoidDestroying(x, p) >= 2f
                     select x;
            BodyPartRecord brain = p.health.hediffSet.GetBrain();

            if (brain != null)
            {
                float maxBrainHealth = brain.def.GetMaxHealth(p);
                source = from x in source
                         where x != brain || p.health.hediffSet.GetPartHealth(x) >= maxBrainHealth * 0.5f + 1f
                         select x;
            }
            while (totalDamage > 0 && source.Any <BodyPartRecord>())
            {
                BodyPartRecord bodyPartRecord = source.RandomElementByWeight((BodyPartRecord x) => x.coverageAbs);
                float          partHealth     = p.health.hediffSet.GetPartHealth(bodyPartRecord);
                int            num            = Mathf.Max(3, GenMath.RoundRandom(partHealth * Rand.Range(0.5f, 1f)));
                float          minHealthOfPartsWeWantToAvoidDestroying = HealthUtility.GetMinHealthOfPartsWeWantToAvoidDestroying(bodyPartRecord, p);
                if (minHealthOfPartsWeWantToAvoidDestroying - (float)num < 1f)
                {
                    num = Mathf.RoundToInt(minHealthOfPartsWeWantToAvoidDestroying - 1f);
                }
                if (bodyPartRecord == brain && partHealth - (float)num < brain.def.GetMaxHealth(p) * 0.5f)
                {
                    num = Mathf.Max(Mathf.RoundToInt(partHealth - brain.def.GetMaxHealth(p) * 0.5f), 1);
                }
                if (num <= 0)
                {
                    break;
                }
                DamageDef      damageDef = Rand.Element <DamageDef>(DamageDefOf.Cut, DamageDefOf.Scratch, DamageDefOf.Stab, DamageDefOf.Crush);
                Thing          p2        = p;
                DamageDef      def       = damageDef;
                float          amount    = (float)num;
                BodyPartRecord hitPart   = bodyPartRecord;
                p2.TakeDamage(new DamageInfo(def, amount, 0f, -1f, null, hitPart, null, DamageInfo.SourceCategory.ThingOrUnknown, null));
                totalDamage -= num;
            }
        }
예제 #8
0
        protected virtual void ExplosionDamageThing(Explosion explosion, Thing t, List <Thing> damagedThings, IntVec3 cell)
        {
            if (t.def.category == ThingCategory.Mote)
            {
                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;
            int        amount     = explosion.GetDamageAmountAt(cell);
            float      angle      = num;
            Thing      instigator = explosion.instigator;
            ThingDef   weapon     = explosion.weapon;
            DamageInfo dinfo      = new DamageInfo(damageDef, amount, angle, instigator, null, weapon, DamageInfo.SourceCategory.ThingOrUnknown);

            if (this.def.explosionAffectOutsidePartsOnly)
            {
                dinfo.SetBodyRegion(BodyPartHeight.Undefined, BodyPartDepth.Outside);
            }
            if (t.def.category == ThingCategory.Building)
            {
                int num2 = Mathf.RoundToInt((float)dinfo.Amount * this.def.explosionBuildingDamageFactor);
                damageDef  = this.def;
                amount     = num2;
                angle      = dinfo.Angle;
                instigator = explosion.instigator;
                weapon     = dinfo.Weapon;
                dinfo      = new DamageInfo(damageDef, amount, angle, instigator, null, weapon, DamageInfo.SourceCategory.ThingOrUnknown);
            }
            BattleLogEntry_ExplosionImpact battleLogEntry_ExplosionImpact = null;

            if (t is Pawn)
            {
                battleLogEntry_ExplosionImpact = new BattleLogEntry_ExplosionImpact(explosion.instigator, t, explosion.weapon, explosion.projectile, this.def);
                Find.BattleLog.Add(battleLogEntry_ExplosionImpact);
            }
            t.TakeDamage(dinfo).InsertIntoLog(battleLogEntry_ExplosionImpact);
        }
예제 #9
0
 private void CheckApplySpreadDamage(DamageInfo dinfo, Thing t)
 {
     if (dinfo.Def == DamageDefOf.Flame && !t.FlammableNow)
     {
         return;
     }
     if (Random.value < 0.5)
     {
         dinfo.SetAmount(Mathf.CeilToInt((float)dinfo.Amount * Rand.Range(0.35f, 0.7f)));
         t.TakeDamage(dinfo);
     }
 }
예제 #10
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);
            }
        }
예제 #11
0
        private static void ApplyArmor(ref float damAmount, float armorRating, Thing armorThing, DamageDef damageDef)
        {
            float num;
            float num2;

            if ((double)armorRating <= 0.5)
            {
                num  = armorRating;
                num2 = 0f;
            }
            else if (armorRating < 1f)
            {
                num  = 0.5f;
                num2 = armorRating - 0.5f;
            }
            else
            {
                num  = 0.5f + (armorRating - 1f) * 0.25f;
                num2 = 0.5f + (armorRating - 1f) * 0.25f;
            }
            if (num > 0.9f)
            {
                num = 0.9f;
            }
            if (num2 > 0.9f)
            {
                num2 = 0.9f;
            }
            float num3;

            if (Rand.Value < num2)
            {
                num3 = damAmount;
            }
            else
            {
                num3 = damAmount * num;
            }
            if (armorThing != null)
            {
                float f = damAmount * 0.25f;
                armorThing.TakeDamage(new DamageInfo(damageDef, GenMath.RoundRandom(f), -1f, null, null, null, DamageInfo.SourceCategory.ThingOrUnknown));
            }
            damAmount -= num3;
        }
예제 #12
0
        private static void ApplyArmor(ref float damAmount, float armorRating, Thing armorThing, DamageDef damageDef)
        {
            float num;
            float num2;

            if ((double)armorRating <= 0.5)
            {
                num  = armorRating;
                num2 = 0f;
            }
            else if (armorRating < 1.0)
            {
                num  = 0.5f;
                num2 = (float)(armorRating - 0.5);
            }
            else
            {
                num  = (float)(0.5 + (armorRating - 1.0) * 0.25);
                num2 = (float)(0.5 + (armorRating - 1.0) * 0.25);
            }
            if (num > 0.89999997615814209)
            {
                num = 0.9f;
            }
            if (num2 > 0.89999997615814209)
            {
                num2 = 0.9f;
            }
            float num3 = (!(Rand.Value < num2)) ? (damAmount * num) : damAmount;

            if (armorThing != null)
            {
                float f = (float)(damAmount * 0.25);
                armorThing.TakeDamage(new DamageInfo(damageDef, GenMath.RoundRandom(f), -1f, null, null, null, DamageInfo.SourceCategory.ThingOrUnknown));
            }
            damAmount -= num3;
        }
        private static void DropRoofInCellPhaseOne(IntVec3 c, Map map, List <Thing> outCrushedThings)
        {
            RoofDef roofDef = map.roofGrid.RoofAt(c);

            if (roofDef == null)
            {
                return;
            }
            if (roofDef.collapseLeavingThingDef != null && roofDef.collapseLeavingThingDef.passability == Traversability.Impassable)
            {
                for (int i = 0; i < 2; i++)
                {
                    List <Thing> thingList = c.GetThingList(map);
                    for (int j = thingList.Count - 1; j >= 0; j--)
                    {
                        Thing thing = thingList[j];
                        RoofCollapserImmediate.TryAddToCrushedThingsList(thing, outCrushedThings);
                        Pawn       pawn = thing as Pawn;
                        DamageInfo dinfo;
                        if (pawn != null)
                        {
                            DamageDef      crush            = DamageDefOf.Crush;
                            float          amount           = 99999f;
                            float          armorPenetration = 999f;
                            BodyPartRecord brain            = pawn.health.hediffSet.GetBrain();
                            dinfo = new DamageInfo(crush, amount, armorPenetration, -1f, null, brain, null, DamageInfo.SourceCategory.Collapse, null);
                        }
                        else
                        {
                            dinfo = new DamageInfo(DamageDefOf.Crush, 99999f, 999f, -1f, null, null, null, DamageInfo.SourceCategory.Collapse, null);
                            dinfo.SetBodyRegion(BodyPartHeight.Top, BodyPartDepth.Outside);
                        }
                        BattleLogEntry_DamageTaken battleLogEntry_DamageTaken = null;
                        if (i == 0 && pawn != null)
                        {
                            battleLogEntry_DamageTaken = new BattleLogEntry_DamageTaken(pawn, RulePackDefOf.DamageEvent_Ceiling, null);
                            Find.BattleLog.Add(battleLogEntry_DamageTaken);
                        }
                        thing.TakeDamage(dinfo).AssociateWithLog(battleLogEntry_DamageTaken);
                        if (!thing.Destroyed && thing.def.destroyable)
                        {
                            thing.Kill(new DamageInfo?(new DamageInfo(DamageDefOf.Crush, 99999f, 999f, -1f, null, null, null, DamageInfo.SourceCategory.Collapse, null)), null);
                        }
                    }
                }
            }
            else
            {
                List <Thing> thingList2 = c.GetThingList(map);
                for (int k = thingList2.Count - 1; k >= 0; k--)
                {
                    Thing thing2 = thingList2[k];
                    if (thing2.def.category == ThingCategory.Item || thing2.def.category == ThingCategory.Plant || thing2.def.category == ThingCategory.Building || thing2.def.category == ThingCategory.Pawn)
                    {
                        RoofCollapserImmediate.TryAddToCrushedThingsList(thing2, outCrushedThings);
                        float num = (float)RoofCollapserImmediate.ThinRoofCrushDamageRange.RandomInRange;
                        if (thing2.def.building != null)
                        {
                            num *= thing2.def.building.roofCollapseDamageMultiplier;
                        }
                        BattleLogEntry_DamageTaken battleLogEntry_DamageTaken2 = null;
                        if (thing2 is Pawn)
                        {
                            battleLogEntry_DamageTaken2 = new BattleLogEntry_DamageTaken((Pawn)thing2, RulePackDefOf.DamageEvent_Ceiling, null);
                            Find.BattleLog.Add(battleLogEntry_DamageTaken2);
                        }
                        DamageInfo dinfo2 = new DamageInfo(DamageDefOf.Crush, (float)GenMath.RoundRandom(num), 0f, -1f, null, null, null, DamageInfo.SourceCategory.Collapse, null);
                        dinfo2.SetBodyRegion(BodyPartHeight.Top, BodyPartDepth.Outside);
                        thing2.TakeDamage(dinfo2).AssociateWithLog(battleLogEntry_DamageTaken2);
                    }
                }
            }
            if (roofDef.collapseLeavingThingDef != null)
            {
                Thing thing3 = GenSpawn.Spawn(roofDef.collapseLeavingThingDef, c, map, WipeMode.Vanish);
                if (thing3.def.rotatable)
                {
                    thing3.Rotation = Rot4.Random;
                }
            }
            for (int l = 0; l < 1; l++)
            {
                Vector3 vector = c.ToVector3Shifted();
                vector += Gen.RandomHorizontalVector(0.6f);
                MoteMaker.ThrowDustPuff(vector, map, 2f);
            }
        }
예제 #14
0
        private static void DropRoofInCellPhaseOne(IntVec3 c, Map map, List <Thing> outCrushedThings)
        {
            RoofDef roofDef = map.roofGrid.RoofAt(c);

            if (roofDef == null)
            {
                return;
            }
            if (roofDef.collapseLeavingThingDef != null && roofDef.collapseLeavingThingDef.passability == Traversability.Impassable)
            {
                for (int i = 0; i < 2; i++)
                {
                    List <Thing> thingList = c.GetThingList(map);
                    for (int num = thingList.Count - 1; num >= 0; num--)
                    {
                        Thing thing = thingList[num];
                        TryAddToCrushedThingsList(thing, outCrushedThings);
                        Pawn       pawn = thing as Pawn;
                        DamageInfo dinfo;
                        if (pawn != null)
                        {
                            dinfo = new DamageInfo(DamageDefOf.Crush, 99999f, 999f, -1f, null, pawn.health.hediffSet.GetBrain(), null, DamageInfo.SourceCategory.Collapse);
                        }
                        else
                        {
                            dinfo = new DamageInfo(DamageDefOf.Crush, 99999f, 999f, -1f, null, null, null, DamageInfo.SourceCategory.Collapse);
                            dinfo.SetBodyRegion(BodyPartHeight.Top, BodyPartDepth.Outside);
                        }
                        BattleLogEntry_DamageTaken battleLogEntry_DamageTaken = null;
                        if (i == 0 && pawn != null)
                        {
                            battleLogEntry_DamageTaken = new BattleLogEntry_DamageTaken(pawn, RulePackDefOf.DamageEvent_Ceiling);
                            Find.BattleLog.Add(battleLogEntry_DamageTaken);
                        }
                        thing.TakeDamage(dinfo).AssociateWithLog(battleLogEntry_DamageTaken);
                        if (!thing.Destroyed && thing.def.destroyable)
                        {
                            thing.Kill(new DamageInfo(DamageDefOf.Crush, 99999f, 999f, -1f, null, null, null, DamageInfo.SourceCategory.Collapse));
                        }
                    }
                }
            }
            else
            {
                List <Thing> thingList2 = c.GetThingList(map);
                for (int num2 = thingList2.Count - 1; num2 >= 0; num2--)
                {
                    Thing thing2 = thingList2[num2];
                    if (thing2.def.category == ThingCategory.Item || thing2.def.category == ThingCategory.Plant || thing2.def.category == ThingCategory.Building || thing2.def.category == ThingCategory.Pawn)
                    {
                        TryAddToCrushedThingsList(thing2, outCrushedThings);
                        float num3 = ThinRoofCrushDamageRange.RandomInRange;
                        if (thing2.def.building != null)
                        {
                            num3 *= thing2.def.building.roofCollapseDamageMultiplier;
                        }
                        BattleLogEntry_DamageTaken battleLogEntry_DamageTaken2 = null;
                        if (thing2 is Pawn)
                        {
                            battleLogEntry_DamageTaken2 = new BattleLogEntry_DamageTaken((Pawn)thing2, RulePackDefOf.DamageEvent_Ceiling);
                            Find.BattleLog.Add(battleLogEntry_DamageTaken2);
                        }
                        DamageInfo dinfo2 = new DamageInfo(DamageDefOf.Crush, GenMath.RoundRandom(num3), 0f, -1f, null, null, null, DamageInfo.SourceCategory.Collapse);
                        dinfo2.SetBodyRegion(BodyPartHeight.Top, BodyPartDepth.Outside);
                        thing2.TakeDamage(dinfo2).AssociateWithLog(battleLogEntry_DamageTaken2);
                    }
                }
            }
            if (roofDef.collapseLeavingThingDef != null)
            {
                Thing thing3 = GenSpawn.Spawn(roofDef.collapseLeavingThingDef, c, map);
                if (thing3.def.rotatable)
                {
                    thing3.Rotation = Rot4.Random;
                }
            }
            for (int j = 0; j < 1; j++)
            {
                MoteMaker.ThrowDustPuff(c.ToVector3Shifted() + Gen.RandomHorizontalVector(0.6f), map, 2f);
            }
        }
예제 #15
0
        private static void DropRoofInCellPhaseOne(IntVec3 c, Map map)
        {
            RoofDef roofDef = map.roofGrid.RoofAt(c);

            if (roofDef != null)
            {
                if (roofDef.collapseLeavingThingDef != null && roofDef.collapseLeavingThingDef.passability == Traversability.Impassable)
                {
                    for (int i = 0; i < 2; i++)
                    {
                        List <Thing> thingList = c.GetThingList(map);
                        for (int num = thingList.Count - 1; num >= 0; num--)
                        {
                            Thing thing = thingList[num];
                            map.roofCollapseBuffer.Notify_Crushed(thing);
                            Pawn       pawn  = thing as Pawn;
                            DamageInfo dinfo = default(DamageInfo);
                            if (pawn != null)
                            {
                                DamageDef      crush  = DamageDefOf.Crush;
                                int            amount = 99999;
                                BodyPartRecord brain  = pawn.health.hediffSet.GetBrain();
                                dinfo = new DamageInfo(crush, amount, -1f, null, brain, null, DamageInfo.SourceCategory.Collapse);
                            }
                            else
                            {
                                dinfo = new DamageInfo(DamageDefOf.Crush, 99999, -1f, null, null, null, DamageInfo.SourceCategory.Collapse);
                                dinfo.SetBodyRegion(BodyPartHeight.Top, BodyPartDepth.Outside);
                            }
                            BattleLogEntry_DamageTaken battleLogEntry_DamageTaken = null;
                            if (i == 0 && pawn != null)
                            {
                                battleLogEntry_DamageTaken = new BattleLogEntry_DamageTaken(pawn, RulePackDefOf.DamageEvent_Ceiling, null);
                                Find.BattleLog.Add(battleLogEntry_DamageTaken);
                            }
                            thing.TakeDamage(dinfo).InsertIntoLog(battleLogEntry_DamageTaken);
                            if (!thing.Destroyed && thing.def.destroyable)
                            {
                                thing.Destroy(DestroyMode.Vanish);
                            }
                        }
                    }
                }
                else
                {
                    List <Thing> thingList2 = c.GetThingList(map);
                    for (int num2 = thingList2.Count - 1; num2 >= 0; num2--)
                    {
                        Thing thing2 = thingList2[num2];
                        if (thing2.def.category == ThingCategory.Item || thing2.def.category == ThingCategory.Plant || thing2.def.category == ThingCategory.Building || thing2.def.category == ThingCategory.Pawn)
                        {
                            map.roofCollapseBuffer.Notify_Crushed(thing2);
                            float num3 = (float)RoofCollapserImmediate.ThinRoofCrushDamageRange.RandomInRange;
                            if (thing2.def.building != null)
                            {
                                num3 *= thing2.def.building.roofCollapseDamageMultiplier;
                            }
                            BattleLogEntry_DamageTaken battleLogEntry_DamageTaken2 = null;
                            if (thing2 is Pawn)
                            {
                                battleLogEntry_DamageTaken2 = new BattleLogEntry_DamageTaken(thing2 as Pawn, RulePackDefOf.DamageEvent_Ceiling, null);
                                Find.BattleLog.Add(battleLogEntry_DamageTaken2);
                            }
                            DamageInfo dinfo2 = new DamageInfo(DamageDefOf.Crush, GenMath.RoundRandom(num3), -1f, null, null, null, DamageInfo.SourceCategory.Collapse);
                            dinfo2.SetBodyRegion(BodyPartHeight.Top, BodyPartDepth.Outside);
                            thing2.TakeDamage(dinfo2).InsertIntoLog(battleLogEntry_DamageTaken2);
                        }
                    }
                }
                if (roofDef.collapseLeavingThingDef != null)
                {
                    Thing thing3 = GenSpawn.Spawn(roofDef.collapseLeavingThingDef, c, map);
                    if (thing3.def.rotatable)
                    {
                        thing3.Rotation = Rot4.Random;
                    }
                }
                for (int j = 0; j < 1; j++)
                {
                    Vector3 a = c.ToVector3Shifted();
                    a += Gen.RandomHorizontalVector(0.6f);
                    MoteMaker.ThrowDustPuff(a, map, 2f);
                }
            }
        }