public static void RemoveBulkCollapsingRoofs(List <IntVec3> nearCells, Map map) { for (int i = 0; i < nearCells.Count; i++) { RoofCollapseCellsFinder.ProcessRoofHolderDespawned(new CellRect(nearCells[i].x, nearCells[i].z, 1, 1), nearCells[i], map, true, true); } }
public static void ProcessRoofHolderDespawned(CellRect rect, IntVec3 position, Map map, bool removalMode = false, bool canRemoveThickRoof = false) { RoofCollapseCellsFinder.CheckCollapseFlyingRoofs(rect, map, removalMode, canRemoveThickRoof); RoofGrid roofGrid = map.roofGrid; RoofCollapseCellsFinder.roofsCollapsingBecauseTooFar.Clear(); for (int i = 0; i < RoofCollapseUtility.RoofSupportRadialCellsCount; i++) { IntVec3 intVec = position + GenRadial.RadialPattern[i]; if (intVec.InBounds(map)) { if (roofGrid.Roofed(intVec.x, intVec.z)) { if (!map.roofCollapseBuffer.IsMarkedToCollapse(intVec)) { if (!RoofCollapseUtility.WithinRangeOfRoofHolder(intVec, map, false)) { if (removalMode && (canRemoveThickRoof || intVec.GetRoof(map).VanishOnCollapse)) { map.roofGrid.SetRoof(intVec, null); } else { map.roofCollapseBuffer.MarkToCollapse(intVec); } RoofCollapseCellsFinder.roofsCollapsingBecauseTooFar.Add(intVec); } } } } } RoofCollapseCellsFinder.CheckCollapseFlyingRoofs(RoofCollapseCellsFinder.roofsCollapsingBecauseTooFar, map, removalMode, canRemoveThickRoof); RoofCollapseCellsFinder.roofsCollapsingBecauseTooFar.Clear(); }
public static void Notify_RoofHolderDespawned(Thing t, Map map) { if (Current.ProgramState == ProgramState.Playing) { RoofCollapseCellsFinder.ProcessRoofHolderDespawned(t.OccupiedRect(), t.Position, map, false, false); } }
public static void CheckCollapseFlyingRoofs(List <IntVec3> nearCells, Map map, bool removalMode = false, bool canRemoveThickRoof = false) { RoofCollapseCellsFinder.visitedCells.Clear(); for (int i = 0; i < nearCells.Count; i++) { RoofCollapseCellsFinder.CheckCollapseFlyingRoofAtAndAdjInternal(nearCells[i], map, removalMode, canRemoveThickRoof); } RoofCollapseCellsFinder.visitedCells.Clear(); }
public static void CheckCollapseFlyingRoofs(CellRect nearRect, Map map, bool removalMode = false, bool canRemoveThickRoof = false) { RoofCollapseCellsFinder.visitedCells.Clear(); CellRect.CellRectIterator iterator = nearRect.GetIterator(); while (!iterator.Done()) { RoofCollapseCellsFinder.CheckCollapseFlyingRoofAtAndAdjInternal(iterator.Current, map, removalMode, canRemoveThickRoof); iterator.MoveNext(); } RoofCollapseCellsFinder.visitedCells.Clear(); }
public static void CheckCollapseFlyingRoofs(CellRect nearRect, Map map) { RoofCollapseCellsFinder.visitedCells.Clear(); CellRect.CellRectIterator iterator = nearRect.GetIterator(); while (!iterator.Done()) { RoofCollapseCellsFinder.CheckCollapseFlyingRoofAtAndAdjInternal(iterator.Current, map, false); iterator.MoveNext(); } RoofCollapseCellsFinder.visitedCells.Clear(); }
private static bool CheckCollapseFlyingRoofAtAndAdjInternal(IntVec3 root, Map map, bool removalMode, bool canRemoveThickRoof) { RoofCollapseBuffer roofCollapseBuffer = map.roofCollapseBuffer; if (removalMode && roofCollapseBuffer.CellsMarkedToCollapse.Count > 0) { map.roofCollapseBufferResolver.CollapseRoofsMarkedToCollapse(); } for (int i = 0; i < 5; i++) { IntVec3 intVec = root + GenAdj.CardinalDirectionsAndInside[i]; if (intVec.InBounds(map)) { if (intVec.Roofed(map)) { if (!RoofCollapseCellsFinder.visitedCells.Contains(intVec)) { if (!roofCollapseBuffer.IsMarkedToCollapse(intVec)) { if (!RoofCollapseCellsFinder.ConnectsToRoofHolder(intVec, map, RoofCollapseCellsFinder.visitedCells)) { map.floodFiller.FloodFill(intVec, (IntVec3 x) => x.Roofed(map), delegate(IntVec3 x) { roofCollapseBuffer.MarkToCollapse(x); }, int.MaxValue, false, null); if (removalMode) { List <IntVec3> cellsMarkedToCollapse = roofCollapseBuffer.CellsMarkedToCollapse; for (int j = cellsMarkedToCollapse.Count - 1; j >= 0; j--) { RoofDef roofDef = map.roofGrid.RoofAt(cellsMarkedToCollapse[j]); if (roofDef != null && (canRemoveThickRoof || roofDef.VanishOnCollapse)) { map.roofGrid.SetRoof(cellsMarkedToCollapse[j], null); cellsMarkedToCollapse.RemoveAt(j); } } } } } } } } } return(false); }
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); } }
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) { 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); }