示例#1
0
        public override void DeSpawn()
        {
            Map map = base.Map;

            base.DeSpawn();
            if (this.def.IsEdifice())
            {
                map.edificeGrid.DeRegister(this);
            }
            if (this.def.MakeFog)
            {
                map.fogGrid.Notify_FogBlockerRemoved(base.Position);
            }
            if (this.def.holdsRoof)
            {
                RoofCollapseCellsFinder.Notify_RoofHolderDespawned(this, map);
            }
            if (this.sustainerAmbient != null)
            {
                this.sustainerAmbient.End();
            }
            CellRect cellRect = this.OccupiedRect();

            for (int i = cellRect.minZ; i <= cellRect.maxZ; i++)
            {
                for (int j = cellRect.minX; j <= cellRect.maxX; j++)
                {
                    IntVec3     loc         = new IntVec3(j, 0, i);
                    MapMeshFlag mapMeshFlag = MapMeshFlag.Buildings;
                    if (this.def.coversFloor)
                    {
                        mapMeshFlag |= MapMeshFlag.Terrain;
                    }
                    if (this.def.Fillage == FillCategory.Full)
                    {
                        mapMeshFlag |= MapMeshFlag.Roofs;
                        mapMeshFlag |= MapMeshFlag.Snow;
                    }
                    map.mapDrawer.MapMeshDirty(loc, mapMeshFlag);
                    map.glowGrid.MarkGlowGridDirty(loc);
                }
            }
            map.listerBuildings.Remove(this);
            map.listerBuildingsRepairable.Notify_BuildingDeSpawned(this);
            if (this.def.leaveTerrain != null && Current.ProgramState == ProgramState.Playing)
            {
                CellRect.CellRectIterator iterator = this.OccupiedRect().GetIterator();
                while (!iterator.Done())
                {
                    map.terrainGrid.SetTerrain(iterator.Current, this.def.leaveTerrain);
                    iterator.MoveNext();
                }
            }
            map.designationManager.Notify_BuildingDespawned(this);
            if (!this.CanBeSeenOver())
            {
                map.exitMapGrid.Notify_LOSBlockerDespawned();
            }
            if (this.def.building.hasFuelingPort)
            {
                IntVec3        fuelingPortCell = FuelingPortUtility.GetFuelingPortCell(base.Position, base.Rotation);
                CompLaunchable compLaunchable  = FuelingPortUtility.LaunchableAt(fuelingPortCell, map);
                if (compLaunchable != null)
                {
                    compLaunchable.Notify_FuelingPortSourceDeSpawned();
                }
            }
            if (this.def.building.ai_combatDangerous)
            {
                AvoidGridMaker.Notify_CombatDangerousBuildingDespawned(this, map);
            }
        }