コード例 #1
0
        public override void PawnDied(Corpse corpse)
        {
            if (!AndroidsModSettings.Instance.androidExplodesOnDeath)
            {
                return;
            }

            //Pawn
            Pawn pawn = corpse.InnerPawn;

            //Try get energy tracker.
            EnergyTrackerComp energy = pawn.TryGetComp <EnergyTrackerComp>();

            bool shouldBeDeadByNaturalCauses = pawn.health.hediffSet.hediffs.Any(hediff => hediff.CauseDeathNow());

            Hediff overheatingHediff   = pawn.health.hediffSet.GetFirstHediffOfDef(HediffDefOf.ChjOverheating);
            bool   deadFromOverheating = overheatingHediff != null ? overheatingHediff.Severity >= 1f : false;

            if (overheatingHediff != null || !shouldBeDeadByNaturalCauses)
            {
                float explosionRadius = AndroidsModSettings.Instance.androidExplosionRadius * energy.energy;

                if (deadFromOverheating)
                {
                    explosionRadius *= 2;
                }

                //Scale explosion strength from how much remaining energy we got.
                if (explosionRadius >= 1f)
                {
                    GenExplosion.DoExplosion(corpse.Position, corpse.Map, explosionRadius, RimWorld.DamageDefOf.Bomb, corpse.InnerPawn);
                }
            }

            //Remove corpse.
            if (!corpse.Destroyed)
            {
                ButcherUtility.SpawnDrops(corpse.InnerPawn, corpse.Position, corpse.Map);

                //Dump inventory.
                if (corpse.InnerPawn.apparel != null)
                {
                    corpse.InnerPawn.apparel.DropAll(corpse.PositionHeld);
                }

                corpse.Destroy(DestroyMode.Vanish);
            }
        }
コード例 #2
0
        // Token: 0x060000F0 RID: 240 RVA: 0x00009888 File Offset: 0x00007A88
        public override void ApplyOnPawn(Pawn pawn, BodyPartRecord part, Pawn billDoer, List <Thing> ingredients, Bill bill)
        {
            Need_Energy       need_Energy       = pawn.needs.TryGetNeed <Need_Energy>();
            EnergyTrackerComp energyTrackerComp = pawn.TryGetComp <EnergyTrackerComp>();
            bool flag = need_Energy != null;

            if (flag)
            {
                need_Energy.CurLevelPercentage = 0f;
            }
            bool flag2 = energyTrackerComp != null;

            if (flag2)
            {
                energyTrackerComp.energy = 0f;
            }
            ButcherUtility.SpawnDrops(pawn, pawn.Position, pawn.Map);
            pawn.Kill(null, null);
        }
コード例 #3
0
        public override void ApplyOnPawn(Pawn pawn, BodyPartRecord part, Pawn billDoer, List <Thing> ingredients, Bill bill)
        {
            //Set the power Need and EnergyTrackerComp to 0.
            Need_Energy       needEnergy        = pawn.needs.TryGetNeed <Need_Energy>();
            EnergyTrackerComp energyTrackerComp = pawn.TryGetComp <EnergyTrackerComp>();

            if (needEnergy != null)
            {
                needEnergy.CurLevelPercentage = 0f;
            }

            if (energyTrackerComp != null)
            {
                energyTrackerComp.energy = 0f;
            }

            //Spawn extra butcher products.
            ButcherUtility.SpawnDrops(pawn, pawn.Position, pawn.Map);

            pawn.Kill(null);
        }
コード例 #4
0
        // Token: 0x060000EB RID: 235 RVA: 0x0000969C File Offset: 0x0000789C
        public override void PawnDied(Corpse corpse)
        {
            bool flag = !AndroidsModSettings.Instance.androidExplodesOnDeath;

            if (!flag)
            {
                Pawn innerPawn = corpse.InnerPawn;
                EnergyTrackerComp energyTrackerComp = corpse.InnerPawn.TryGetComp <EnergyTrackerComp>();
                bool flag2 = energyTrackerComp != null;
                if (flag2)
                {
                    bool   flag3            = innerPawn.health.hediffSet.hediffs.Any((Hediff hediff) => hediff.CauseDeathNow());
                    Hediff firstHediffOfDef = innerPawn.health.hediffSet.GetFirstHediffOfDef(HediffDefOf.ChjOverheating, false);
                    bool   flag4            = firstHediffOfDef != null && firstHediffOfDef.Severity >= 1f;
                    bool   flag5            = flag4 || !flag3;
                    if (flag5)
                    {
                        float num   = AndroidsModSettings.Instance.androidExplosionRadius * energyTrackerComp.energy;
                        bool  flag6 = flag4;
                        if (flag6)
                        {
                            num *= 2f;
                        }
                        bool flag7 = num >= 1f;
                        if (flag7)
                        {
                            GenExplosion.DoExplosion(corpse.Position, corpse.Map, num, DamageDefOf.Bomb, corpse.InnerPawn, -1, null, null, null, null, 0f, 1, false, null, 0f, 1, 0f, false);
                        }
                    }
                }
                else
                {
                    Log.Warning("Androids.DeathActionWorker_Android: EnergyTrackerComp is null at " + corpse.ThingID);
                }
            }
        }
コード例 #5
0
        public override void PawnDied(Corpse corpse)
        {
            //Log.Message("Inside DeathActionWorker");

            if (!AndroidsModSettings.Instance.androidExplodesOnDeath)
            {
                return;
            }

            //Pawn
            Pawn pawn = corpse.InnerPawn;

            //Try get energy tracker.
            EnergyTrackerComp energy = pawn.TryGetComp <EnergyTrackerComp>();

            if (energy != null)
            {
                //Log.Message("EnergyTracker");

                //Make sure we did not die from natural causes. As natural as an Android can be.
                bool shouldBeDeadByNaturalCauses = pawn.health.hediffSet.hediffs.Any(hediff => hediff.CauseDeathNow());

                Hediff overheatingHediff = pawn.health.hediffSet.GetFirstHediffOfDef(HediffDefOf.ChjOverheating);
                //bool deadFromOverheating = overheatingHediff != null ? overheatingHediff.Severity >= 1f : false;

                if (overheatingHediff == null)
                {
                    return;
                }

                //Overheating death is excepted.
                if (overheatingHediff != null || !shouldBeDeadByNaturalCauses)
                {
                    float explosionRadius = overheatingHediff.Severity * AndroidsModSettings.Instance.androidExplosionRadius * energy.energy;

                    //if (deadFromOverheating)
                    //    explosionRadius *= 2;

                    //Scale explosion strength from how much remaining energy we got.
                    if (overheatingHediff != null && explosionRadius >= 1f)
                    {
                        GenExplosion.DoExplosion(corpse.Position, corpse.Map, explosionRadius, RimWorld.DamageDefOf.Bomb, corpse.InnerPawn);
                    }
                }
            }
            else
            {
                //Log.Message("Android Like");

                //Attempt to get the energy need directly.
                if (pawn.health.hediffSet.GetFirstHediffOfDef(HediffDefOf.ChjAndroidLike) is Hediff androidLike && androidLike is AndroidLikeHediff androidLikeForReal)
                {
                    //Make sure we did not die from natural causes. As natural as an Android can be.
                    bool shouldBeDeadByNaturalCauses = pawn.health.hediffSet.hediffs.Any(hediff => hediff.CauseDeathNow());

                    Hediff overheatingHediff = pawn.health.hediffSet.GetFirstHediffOfDef(HediffDefOf.ChjOverheating);
                    //bool deadFromOverheating = overheatingHediff != null ? overheatingHediff.Severity >= 1f : false;

                    if (overheatingHediff == null)
                    {
                        return;
                    }

                    //Overheating death is excepted.
                    if (overheatingHediff != null || !shouldBeDeadByNaturalCauses)
                    {
                        float explosionRadius = overheatingHediff.Severity * AndroidsModSettings.Instance.androidExplosionRadius * androidLikeForReal.energyTracked;

                        //if (deadFromOverheating)
                        //    explosionRadius *= 2;

                        //Scale explosion strength from how much remaining energy we got.
                        if (overheatingHediff != null && explosionRadius >= 1f)
                        {
                            GenExplosion.DoExplosion(corpse.Position, corpse.Map, explosionRadius, RimWorld.DamageDefOf.Bomb, corpse.InnerPawn);
                        }
                    }
                    return;
                }