public override void DeSpawn(DestroyMode mode = DestroyMode.Vanish) { Map map = base.Map; base.DeSpawn(mode); if (def.IsEdifice()) { map.edificeGrid.DeRegister(this); if (def.Fillage == FillCategory.Full) { map.terrainGrid.Drawer.SetDirty(); } if (def.AffectsFertility) { map.fertilityGrid.Drawer.SetDirty(); } } if (mode != DestroyMode.WillReplace) { if (def.MakeFog) { map.fogGrid.Notify_FogBlockerRemoved(base.Position); } if (def.holdsRoof) { RoofCollapseCellsFinder.Notify_RoofHolderDespawned(this, map); } if (def.IsSmoothable) { SmoothSurfaceDesignatorUtility.Notify_BuildingDespawned(this, map); } } if (sustainerAmbient != null) { 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 (def.coversFloor) { mapMeshFlag |= MapMeshFlag.Terrain; } if (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); map.listerArtificialBuildingsForMeditation.Notify_BuildingDeSpawned(this); if (def.building.leaveTerrain != null && Current.ProgramState == ProgramState.Playing && canChangeTerrainOnDestroyed) { foreach (IntVec3 item in this.OccupiedRect()) { map.terrainGrid.SetTerrain(item, def.building.leaveTerrain); } } map.designationManager.Notify_BuildingDespawned(this); if (!this.CanBeSeenOver()) { map.exitMapGrid.Notify_LOSBlockerDespawned(); } if (def.building.hasFuelingPort) { FuelingPortUtility.LaunchableAt(FuelingPortUtility.GetFuelingPortCell(base.Position, base.Rotation), map)?.Notify_FuelingPortSourceDeSpawned(); } map.avoidGrid.Notify_BuildingDespawned(this); }
public override void DeSpawn(DestroyMode mode = DestroyMode.Vanish) { Map map = base.Map; base.DeSpawn(mode); if (this.def.IsEdifice()) { map.edificeGrid.DeRegister(this); } if (mode != DestroyMode.WillReplace) { if (this.def.MakeFog) { map.fogGrid.Notify_FogBlockerRemoved(base.Position); } if (this.def.holdsRoof) { RoofCollapseCellsFinder.Notify_RoofHolderDespawned(this, map); } if (this.def.IsSmoothable) { SmoothSurfaceDesignatorUtility.Notify_BuildingDespawned(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.building.leaveTerrain != null && Current.ProgramState == ProgramState.Playing && this.canChangeTerrainOnDestroyed) { CellRect.CellRectIterator iterator = this.OccupiedRect().GetIterator(); while (!iterator.Done()) { map.terrainGrid.SetTerrain(iterator.Current, this.def.building.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); } }
public override void DeSpawn(DestroyMode mode = DestroyMode.Vanish) { var map = Map; // before DeSpawn! base.DeSpawn(mode); if (def.IsEdifice()) { map.edificeGrid.DeRegister(this); } if (mode != DestroyMode.WillReplace) { if (def.MakeFog) { map.fogGrid.Notify_FogBlockerRemoved(Position); } if (def.holdsRoof) { RoofCollapseCellsFinder.Notify_RoofHolderDespawned(this, map); } if (def.IsSmoothable) { SmoothSurfaceDesignatorUtility.Notify_BuildingDespawned(this, map); } } if (sustainerAmbient != null) { sustainerAmbient.End(); } CellRect occRect = GenAdj.OccupiedRect(this); for (int z = occRect.minZ; z <= occRect.maxZ; z++) { for (int x = occRect.minX; x <= occRect.maxX; x++) { IntVec3 c = new IntVec3(x, 0, z); MapMeshFlag changeType = MapMeshFlag.Buildings; if (def.coversFloor) { changeType |= MapMeshFlag.Terrain; } if (def.Fillage == FillCategory.Full) { changeType |= MapMeshFlag.Roofs; changeType |= MapMeshFlag.Snow; } map.mapDrawer.MapMeshDirty(c, changeType); map.glowGrid.MarkGlowGridDirty(c); } } map.listerBuildings.Remove(this); map.listerBuildingsRepairable.Notify_BuildingDeSpawned(this); if (def.building.leaveTerrain != null && Current.ProgramState == ProgramState.Playing && canChangeTerrainOnDestroyed) { for (var cri = GenAdj.OccupiedRect(this).GetIterator(); !cri.Done(); cri.MoveNext()) { map.terrainGrid.SetTerrain(cri.Current, def.building.leaveTerrain); } } //Mining, planning, etc map.designationManager.Notify_BuildingDespawned(this); if (!this.CanBeSeenOver()) { map.exitMapGrid.Notify_LOSBlockerDespawned(); } if (def.building.hasFuelingPort) { var fuelingPortCell = FuelingPortUtility.GetFuelingPortCell(Position, Rotation); var launchable = FuelingPortUtility.LaunchableAt(fuelingPortCell, map); if (launchable != null) { launchable.Notify_FuelingPortSourceDeSpawned(); } } //Must go after removing from buildings list map.avoidGrid.Notify_BuildingDespawned(this); }