protected void NotifyRemoved(Thing item) { Pawn_InventoryTracker pawn_InventoryTracker = this.owner as Pawn_InventoryTracker; if (pawn_InventoryTracker != null) { pawn_InventoryTracker.Notify_ItemRemoved(item); } Pawn_ApparelTracker pawn_ApparelTracker = this.owner as Pawn_ApparelTracker; if (pawn_ApparelTracker != null) { pawn_ApparelTracker.Notify_ApparelRemoved((Apparel)item); } Pawn_EquipmentTracker pawn_EquipmentTracker = this.owner as Pawn_EquipmentTracker; if (pawn_EquipmentTracker != null) { pawn_EquipmentTracker.Notify_EquipmentRemoved((ThingWithComps)item); } Caravan caravan = this.owner as Caravan; if (caravan != null) { caravan.Notify_PawnRemoved((Pawn)item); } this.NotifyColonistBarIfColonistCorpse(item); }
/// <summary> /// Cleans up all references to the original human pawn after creating the animal pawn. <br /> /// This does not call Pawn.DeSpawn. /// </summary> public static void CleanUpHumanPawnPostTf([NotNull] Pawn originalPawn, [CanBeNull] Hediff cause) { if (originalPawn == null) { throw new ArgumentNullException(nameof(originalPawn)); } HandleApparelAndEquipment(originalPawn); if (cause != null) { originalPawn .health.RemoveHediff(cause); // Remove the hediff that caused the transformation so they don't transform again if reverted. } originalPawn.health.surgeryBills?.Clear(); //if this pawn has any additional surgery bills, get rid of them if (originalPawn.ownership.OwnedBed != null) // If the original pawn owned a bed somewhere... { originalPawn.ownership.UnclaimBed(); // ...unclaim it. } if (originalPawn.CarriedBy != null) // If the original pawn was being carried when they transformed... { Pawn carryingPawn = originalPawn.CarriedBy; Thing outPawn; carryingPawn.carryTracker.TryDropCarriedThing(carryingPawn.Position, ThingPlaceMode.Direct, out outPawn); // ...drop them so they can be removed. } if (originalPawn.IsPrisoner) { HandlePrisoner(originalPawn); } Caravan caravan = originalPawn.GetCaravan(); caravan?.RemovePawn(originalPawn); caravan?.Notify_PawnRemoved(originalPawn); // Make sure any current lords know they can't use this pawn anymore. originalPawn.GetLord()?.Notify_PawnLost(originalPawn, PawnLostCondition.IncappedOrKilled); //remove any jobs the pawn may be doing if (originalPawn.jobs != null && originalPawn.Map != null) { originalPawn.jobs.ClearQueuedJobs(); originalPawn.jobs.EndCurrentJob(JobCondition.InterruptForced); } if (originalPawn.Faction != Faction.OfPlayer) { return; //past here is only relevant for colonists } bool IsMasterOfOriginal(Pawn animalPawn) //function to find all animals our pawn is a master of { if (animalPawn.playerSettings != null) { return(animalPawn.playerSettings.Master == originalPawn); } return(false); } foreach (Pawn animalPawn in PawnsFinder.AllMapsWorldAndTemporary_Alive.Where(IsMasterOfOriginal)) { animalPawn.playerSettings.Master = null; //set to null, these animals don't have a master anymore } }