Example #1
0
        public static void Ressurrect(Pawn pawn, Thing thing)
        {
            if (thing is HoloEmitter)
            {
                if (pawn.Corpse.holdingOwner != null)
                {
                    pawn.Corpse.GetDirectlyHeldThings().TryTransferToContainer(pawn, pawn.Corpse.holdingOwner, true);
                }
                else if (pawn.Corpse.Spawned)
                {
                    ResurrectionUtility.Resurrect(pawn);
                    PawnDiedOrDownedThoughtsUtility.RemoveDiedThoughts(pawn);
                    PawnComponentsUtility.AddAndRemoveDynamicComponents(pawn, false);
                    CompOsiris.FixPawnRelationships(pawn);
                    pawn.health.Reset();
                    if (pawn.Corpse != null && pawn.Corpse.Spawned)
                    {
                        pawn.Corpse.DeSpawn();
                    }
                    GenSpawn.Spawn(pawn, pawn.Corpse.Position, pawn.Corpse.Map);
                    GiveSideEffects(pawn);
                }
                if (pawn.Corpse != null)
                {
                    pawn.Corpse.Destroy(DestroyMode.Vanish);
                }
            }
            else
            {
                ResurrectionUtility.Resurrect(pawn);
                PawnDiedOrDownedThoughtsUtility.RemoveDiedThoughts(pawn);
                CompOsiris.FixPawnRelationships(pawn);
                pawn.health.Reset();
                if (pawn.Corpse != null && pawn.Corpse.Spawned)
                {
                    pawn.Corpse.DeSpawn();
                }
                GenSpawn.Spawn(pawn, thing.Position, thing.Map);
                GiveSideEffects(pawn);

                Building_Casket building_Casket = thing as Building_Casket;
                if (building_Casket != null)
                {
                    building_Casket.GetDirectlyHeldThings().Clear();
                }
            }
        }
Example #2
0
        public static void ResurrectPawnFromVoid(Map map, IntVec3 loc, Pawn pawn)
        {
            Corpse corpse = pawn.Corpse;

            if (corpse != null)
            {
                corpse.Destroy(DestroyMode.Vanish);
            }
            if (pawn.IsWorldPawn())
            {
                Find.WorldPawns.RemovePawn(pawn);
            }
            pawn.ForceSetStateToUnspawned();
            PawnComponentsUtility.CreateInitialComponents(pawn);
            pawn.health.Notify_Resurrected();
            if (pawn.Faction != null && pawn.Faction.IsPlayer)
            {
                if (pawn.workSettings != null)
                {
                    pawn.workSettings.EnableAndInitialize();
                }
                Find.StoryWatcher.watcherPopAdaptation.Notify_PawnEvent(pawn, PopAdaptationEvent.GainedColonist);
            }
            GenSpawn.Spawn(pawn, loc, map, WipeMode.Vanish);
            for (int i = 0; i < 10; i++)
            {
                //MoteMaker.ThrowAirPuffUp(pawn.DrawPos, map);
                DebugActionsUtility.DustPuffFrom(pawn);
            }
            if (pawn.Faction != null && pawn.Faction != Faction.OfPlayer && pawn.HostileTo(Faction.OfPlayer))
            {
                LordMaker.MakeNewLord(pawn.Faction, new LordJob_AssaultColony(pawn.Faction, true, true, false, false, true), pawn.Map, Gen.YieldSingle <Pawn>(pawn));
            }
            if (pawn.apparel != null)
            {
                List <Apparel> wornApparel = pawn.apparel.WornApparel;
                for (int j = 0; j < wornApparel.Count; j++)
                {
                    wornApparel[j].Notify_PawnResurrected();
                }
            }
            PawnDiedOrDownedThoughtsUtility.RemoveDiedThoughts(pawn);
        }
Example #3
0
        public static void Resurrect(Pawn pawn)
        {
            if (!pawn.Dead)
            {
                Log.Error("Tried to resurrect a pawn who is not dead: " + pawn.ToStringSafe <Pawn>(), false);
                return;
            }
            if (pawn.Discarded)
            {
                Log.Error("Tried to resurrect a discarded pawn: " + pawn.ToStringSafe <Pawn>(), false);
                return;
            }
            Corpse  corpse = pawn.Corpse;
            bool    flag   = false;
            IntVec3 loc    = IntVec3.Invalid;
            Map     map    = null;

            if (corpse != null)
            {
                flag             = corpse.Spawned;
                loc              = corpse.Position;
                map              = corpse.Map;
                corpse.InnerPawn = null;
                corpse.Destroy(DestroyMode.Vanish);
            }
            if (flag && pawn.IsWorldPawn())
            {
                Find.WorldPawns.RemovePawn(pawn);
            }
            pawn.ForceSetStateToUnspawned();
            PawnComponentsUtility.CreateInitialComponents(pawn);
            pawn.health.Notify_Resurrected();
            if (pawn.Faction != null && pawn.Faction.IsPlayer)
            {
                if (pawn.workSettings != null)
                {
                    pawn.workSettings.EnableAndInitialize();
                }
                Find.StoryWatcher.watcherPopAdaptation.Notify_PawnEvent(pawn, PopAdaptationEvent.GainedColonist);
            }
            if (flag)
            {
                GenSpawn.Spawn(pawn, loc, map, WipeMode.Vanish);
                for (int i = 0; i < 10; i++)
                {
                    MoteMaker.ThrowAirPuffUp(pawn.DrawPos, map);
                }
                if (pawn.Faction != null && pawn.Faction != Faction.OfPlayer && pawn.HostileTo(Faction.OfPlayer))
                {
                    LordMaker.MakeNewLord(pawn.Faction, new LordJob_AssaultColony(pawn.Faction, true, true, false, false, true), pawn.Map, Gen.YieldSingle <Pawn>(pawn));
                }
                if (pawn.apparel != null)
                {
                    List <Apparel> wornApparel = pawn.apparel.WornApparel;
                    for (int j = 0; j < wornApparel.Count; j++)
                    {
                        wornApparel[j].Notify_PawnResurrected();
                    }
                }
            }
            PawnDiedOrDownedThoughtsUtility.RemoveDiedThoughts(pawn);
        }