public virtual void Destroy(DestroyMode mode = DestroyMode.Vanish) { if (!allowDestroyNonDestroyable && !def.destroyable) { Log.Error("Tried to destroy non-destroyable thing " + this); return; } if (Destroyed) { Log.Error("Tried to destroy already-destroyed thing " + this); return; } bool spawned = Spawned; Map map = Map; if (Spawned) { DeSpawn(mode); } mapIndexOrState = -2; if (def.DiscardOnDestroyed) { Discard(); } CompExplosive compExplosive = this.TryGetComp <CompExplosive>(); if (spawned) { List <Thing> list = ((compExplosive != null) ? new List <Thing>() : null); GenLeaving.DoLeavingsFor(this, map, mode, list); compExplosive?.AddThingsIgnoredByExplosion(list); } if (holdingOwner != null) { holdingOwner.Notify_ContainedItemDestroyed(this); } RemoveAllReservationsAndDesignationsOnThis(); if (!(this is Pawn)) { stackCount = 0; } if (mode != DestroyMode.QuestLogic) { QuestUtility.SendQuestTargetSignals(questTags, "Destroyed", this.Named("SUBJECT")); } if (mode == DestroyMode.KillFinalize) { QuestUtility.SendQuestTargetSignals(questTags, "Killed", this.Named("SUBJECT")); } }
public virtual void Destroy(DestroyMode mode = DestroyMode.Vanish) { if (!allowDestroyNonDestroyable && !def.destroyable) { Log.Error("Tried to destroy non-destroyable thing " + this); } else if (Destroyed) { Log.Error("Tried to destroy already-destroyed thing " + this); } else { bool spawned = Spawned; Map map = Map; if (Spawned) { DeSpawn(mode); } mapIndexOrState = -2; if (def.DiscardOnDestroyed) { Discard(); } bool flag = this.TryGetComp <CompExplosive>()?.destroyedThroughDetonation ?? false; if (spawned && !flag) { GenLeaving.DoLeavingsFor(this, map, mode); } if (holdingOwner != null) { holdingOwner.Notify_ContainedItemDestroyed(this); } RemoveAllReservationsAndDesignationsOnThis(); if (!(this is Pawn)) { stackCount = 0; } } }