Example #1
0
        public static bool DestroyCorpse(this HediffComp_RandySpawnUponDeath comp, Corpse corpse)
        {
            bool DidIt = false;

            if (comp.Props.HasParentRedress && comp.Props.redressParent.destroyCorpse && !corpse.Negligible())
            {
                DidIt = true;
                corpse.DeSpawn();
            }

            return(DidIt);
        }
Example #2
0
        public override void Notify_PawnDied()
        {
            base.Notify_PawnDied();
            Corpse       corpse = Pawn?.Corpse;
            CompRottable rott   = corpse.TryGetComp <CompRottable>();

            //float corpseNutrition = corpse.GetStatValue(StatDefOf.Nutrition);

            corpse.Strip();

            List <BodyPartRecord> parts =
                Pawn.RaceProps.body.corePart.parts.Where((BodyPartRecord part) => part.coverageAbs > 0f && !Pawn.health.hediffSet.PartIsMissing(part)).ToList();

            //parts.Add(Pawn.RaceProps.body.corePart);
            //foreach (BodyPartRecord part in Pawn.RaceProps.body.AllParts.Where((BodyPartRecord part) => !part.IsCorePart && part.coverageAbs > 0f && !Pawn.health.hediffSet.PartIsMissing(part)))
            foreach (BodyPartRecord part in parts)
            {
                Hediff hediff = HediffMaker.MakeHediff(InjectionHediffDef, Pawn, part);

                hediff.Severity = part.def.hitPoints * 20;
                Pawn.health.AddHediff(hediff, part, new DamageInfo(
                                          InjectionDamageDef, part.def.hitPoints * 20,
                                          armorPenetration: 2f,
                                          instigator: Pawn,
                                          weapon: Pawn.def,
                                          hitPart: part
                                          ));

                /*Pawn.TakeDamage(
                 *  new DamageInfo(
                 *      InjectionDamageDef, part.def.hitPoints * 20,
                 *      armorPenetration: 2f,
                 *      instigator: Pawn,
                 *      weapon: Pawn.def,
                 *      hitPart: part
                 *      )
                 * );*/
            }
            if (rott != null &&
                rott.RotProgress < rott.PropsRot.TicksToDessicated)
            {
                rott.RotProgress = rott.PropsRot.TicksToDessicated;
            }
            Plant thingTree = (Plant)ThingMaker.MakeThing(FleshTreeDef);

            GenSpawn.Spawn(thingTree, corpse.Position, corpse.Map, WipeMode.FullRefund);

            corpse.DeSpawn();
            thingTree.TryGetComp <CompThingHolder>().innerContainer.TryAdd(corpse);
        }
        private bool PawnDestroy()
        {
            if (Pawn.Dead)
            {
                Tools.Warn(Pawn.LabelShort + " is dead and will get destroyed", myDebug);
                if (Pawn.Corpse == null)
                {
                    Tools.Warn("found no corpse to work with, wont do anything", myDebug);
                    return(false);
                }
                Corpse corpse = Pawn.Corpse;

                if (Props.StripBeforeDeath && corpse.AnythingToStrip())
                {
                    corpse.Strip();
                }

                corpse.DeSpawn();
            }
            else if (Pawn.Downed)
            {
                Tools.Warn(Pawn.LabelShort + " is downed and will get destroyed", myDebug);
                if (Props.StripBeforeDeath && Pawn.AnythingToStrip())
                {
                    Pawn.Strip();
                }

                Pawn.Destroy();
            }
            else
            {
                Tools.Warn("How?", myDebug);
            }

            if (Props.DestroyWeapon && RememberWeapon != null && RememberWeapon.Spawned)
            {
                RememberWeapon.Destroy();
            }

            return(true);
        }
Example #4
0
        private bool PawnSaysGoodBye()
        {
            if (!IsPawn)
            {
                if (MyDebug)
                {
                    Log.Warning("Non pawn tried to say good bye as pawn, wont destroy");
                }
                return(false);
            }

            Lifespan_Utility.RemoveBadMemoriesOfDeadPawn(pawn);

            if (pawn.Dead)
            {
                if (pawn.Corpse == null)
                {
                    if (MyDebug)
                    {
                        Log.Warning("found no corpse to work with, wont do anything");
                    }
                    return(false);
                }


                Corpse corpse = pawn.Corpse;

                if (corpse.AnythingToStrip())
                {
                    corpse.Strip();
                }

                corpse.DeSpawn();
            }
            else
            {
                parent.Destroy();
            }

            return(true);
        }
Example #5
0
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            map         = parms.target as Map;
            pos         = altar(map).Position;
            exSacrifice = corpse(map).InnerPawn;
            deadBody    = corpse(map);

            LongEventHandler.QueueLongEvent(delegate
            {
                //Throw some smoke
                MoteMaker.ThrowDustPuff(pos, map, 2f);

                //Make the body strip and despawn around the altar
                deadBody.Strip();
                deadBody.DeSpawn();

                //Trigger the nightmare event on the altar
                altar(map).NightmareEvent();

                Utility.ApplyTaleDef("Cults_SpellReincarnation", deadBody.InnerPawn);
            }, "Cults_SpellReincarnation", false, null);
            return(true);
        }
        public static Toil FinishRecipeAndStartStoringCorpse(TargetIndex corpseIndex)
        {
            Toil toil = new Toil();

            toil.initAction = delegate
            {
                Pawn   actor  = toil.actor;
                Job    curJob = actor.jobs.curJob;
                Corpse corpse = actor.jobs.curJob.GetTarget(TargetIndex.B).Thing as Corpse;

                actor.skills.GetSkill(SkillDefOf.Medicine).Learn(Dissection.Singleton.ExpPerCorpse, Dissection.Singleton.IgnoreDailyLimit);

                ApplyThoughts(actor, corpse);
                RecordTale(actor, corpse);

                bool destroyedBody = RemoveDissectedBodyParts(actor, corpse);

                curJob.bill.Notify_IterationCompleted(actor, new List <Thing>()
                {
                    corpse
                });
                RecordsUtility.Notify_BillDone(actor, new List <Thing>()
                {
                    corpse
                });

                if (destroyedBody)
                {
                    actor.jobs.EndCurrentJob(JobCondition.Succeeded);
                    return;
                }

                IntVec3 bestStoreCell = IntVec3.Invalid;
                if (curJob.bill.GetStoreMode() == BillStoreModeDefOf.BestStockpile)
                {
                    StoreUtility.TryFindBestBetterStoreCellFor(corpse, actor, actor.Map, StoragePriority.Unstored, actor.Faction, out bestStoreCell, true);
                }
                else if (curJob.bill.GetStoreMode() == BillStoreModeDefOf.SpecificStockpile)
                {
                    StoreUtility.TryFindBestBetterStoreCellForIn(corpse, actor, actor.Map, StoragePriority.Unstored, actor.Faction, curJob.bill.GetStoreZone().slotGroup, out bestStoreCell, true);
                }
                else
                {
                    Log.ErrorOnce("Unknown store mode", 9158246, false);
                }

                if (bestStoreCell.IsValid)
                {
                    corpse.DeSpawn();
                    actor.carryTracker.TryStartCarry(corpse);
                    curJob.targetC = bestStoreCell;
                    curJob.targetB = corpse;
                    curJob.count   = 99999;

                    curJob.placedThings?.Clear();
                }
                else
                {
                    actor.jobs.EndCurrentJob(JobCondition.Succeeded);
                }
            };
            return(toil);
        }