AlertSpeaker.Building_AlertSpeaker.Destroy C# (CSharp) Method

Destroy() public method

Destroys the alert speaker and remove any bonus/malus i fthere are no more on the map.
public Destroy ( DestroyMode mode = DestroyMode.Vanish ) : void
mode DestroyMode
return void
        public override void Destroy(DestroyMode mode = DestroyMode.Vanish)
        {
            base.Destroy();

            if (mode == DestroyMode.Deconstruct)
            {
                List<ThingCount> costList = this.def.costList;
                foreach (ThingCount cost in costList)
                {
                    Thing deconstructedResource = ThingMaker.MakeThing(cost.thingDef);
                    deconstructedResource.stackCount = cost.count;
                    GenSpawn.Spawn(deconstructedResource, this.Position);
                }
            }

            numberOfAlertSpeakers--;
            if (numberOfAlertSpeakers == 0)
            {
                RemoveAnyStatBonusFromAllColonists();
                RemoveAnyStatMalusFromAllColonists();
                RemoveAnyThoughtBonusFromAllColonists();
                RemoveAnyThoughtMalusFromAllColonists();
            }
        }