private void TryGenerateAreaNow(Room room)
        {
            if (room.Dereferenced || room.TouchesMapEdge)
            {
                return;
            }
            if (room.RegionCount > 26 || room.CellCount > 320)
            {
                return;
            }
            if (room.RegionType == RegionType.Portal)
            {
                return;
            }
            bool flag = false;

            foreach (IntVec3 c in room.BorderCells)
            {
                Thing roofHolderOrImpassable = c.GetRoofHolderOrImpassable(this.map);
                if (roofHolderOrImpassable != null)
                {
                    if (roofHolderOrImpassable.Faction != null && roofHolderOrImpassable.Faction != Faction.OfPlayer)
                    {
                        return;
                    }
                    if (roofHolderOrImpassable.def.building != null && !roofHolderOrImpassable.def.building.allowAutoroof)
                    {
                        return;
                    }
                    if (roofHolderOrImpassable.Faction == Faction.OfPlayer)
                    {
                        flag = true;
                    }
                }
            }
            if (!flag)
            {
                return;
            }
            this.innerCells.Clear();
            foreach (IntVec3 intVec in room.Cells)
            {
                if (!this.innerCells.Contains(intVec))
                {
                    this.innerCells.Add(intVec);
                }
                for (int i = 0; i < 8; i++)
                {
                    IntVec3 c2 = intVec + GenAdj.AdjacentCells[i];
                    if (c2.InBounds(this.map))
                    {
                        Thing roofHolderOrImpassable2 = c2.GetRoofHolderOrImpassable(this.map);
                        if (roofHolderOrImpassable2 != null && (roofHolderOrImpassable2.def.size.x > 1 || roofHolderOrImpassable2.def.size.z > 1))
                        {
                            CellRect cellRect = roofHolderOrImpassable2.OccupiedRect();
                            cellRect.ClipInsideMap(this.map);
                            for (int j = cellRect.minZ; j <= cellRect.maxZ; j++)
                            {
                                for (int k = cellRect.minX; k <= cellRect.maxX; k++)
                                {
                                    IntVec3 item = new IntVec3(k, 0, j);
                                    if (!this.innerCells.Contains(item))
                                    {
                                        this.innerCells.Add(item);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            this.cellsToRoof.Clear();
            foreach (IntVec3 a in this.innerCells)
            {
                for (int l = 0; l < 9; l++)
                {
                    IntVec3 intVec2 = a + GenAdj.AdjacentCellsAndInside[l];
                    if (intVec2.InBounds(this.map) && (l == 8 || intVec2.GetRoofHolderOrImpassable(this.map) != null) && !this.cellsToRoof.Contains(intVec2))
                    {
                        this.cellsToRoof.Add(intVec2);
                    }
                }
            }
            this.justRoofedCells.Clear();
            foreach (IntVec3 intVec3 in this.cellsToRoof)
            {
                if (this.map.roofGrid.RoofAt(intVec3) == null && !this.justRoofedCells.Contains(intVec3))
                {
                    if (!this.map.areaManager.NoRoof[intVec3] && RoofCollapseUtility.WithinRangeOfRoofHolder(intVec3, this.map, true))
                    {
                        this.map.areaManager.BuildRoof[intVec3] = true;
                        this.justRoofedCells.Add(intVec3);
                    }
                }
            }
        }
예제 #2
0
 private void TryGenerateAreaNow(Room room)
 {
     if (!room.Dereferenced && !room.TouchesMapEdge && room.RegionCount <= 26 && room.CellCount <= 320 && room.RegionType != RegionType.Portal)
     {
         bool flag = false;
         foreach (IntVec3 borderCell in room.BorderCells)
         {
             Thing roofHolderOrImpassable = borderCell.GetRoofHolderOrImpassable(map);
             if (roofHolderOrImpassable != null)
             {
                 if ((roofHolderOrImpassable.Faction != null && roofHolderOrImpassable.Faction != Faction.OfPlayer) || (roofHolderOrImpassable.def.building != null && !roofHolderOrImpassable.def.building.allowAutoroof))
                 {
                     return;
                 }
                 if (roofHolderOrImpassable.Faction == Faction.OfPlayer)
                 {
                     flag = true;
                 }
             }
         }
         if (flag)
         {
             innerCells.Clear();
             foreach (IntVec3 cell in room.Cells)
             {
                 if (!innerCells.Contains(cell))
                 {
                     innerCells.Add(cell);
                 }
                 for (int i = 0; i < 8; i++)
                 {
                     IntVec3 c = cell + GenAdj.AdjacentCells[i];
                     if (c.InBounds(map))
                     {
                         Thing roofHolderOrImpassable2 = c.GetRoofHolderOrImpassable(map);
                         if (roofHolderOrImpassable2 != null && (roofHolderOrImpassable2.def.size.x > 1 || roofHolderOrImpassable2.def.size.z > 1))
                         {
                             CellRect cellRect = roofHolderOrImpassable2.OccupiedRect();
                             cellRect.ClipInsideMap(map);
                             for (int j = cellRect.minZ; j <= cellRect.maxZ; j++)
                             {
                                 for (int k = cellRect.minX; k <= cellRect.maxX; k++)
                                 {
                                     IntVec3 item = new IntVec3(k, 0, j);
                                     if (!innerCells.Contains(item))
                                     {
                                         innerCells.Add(item);
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
             cellsToRoof.Clear();
             foreach (IntVec3 innerCell in innerCells)
             {
                 for (int l = 0; l < 9; l++)
                 {
                     IntVec3 intVec = innerCell + GenAdj.AdjacentCellsAndInside[l];
                     if (intVec.InBounds(map) && (l == 8 || intVec.GetRoofHolderOrImpassable(map) != null) && !cellsToRoof.Contains(intVec))
                     {
                         cellsToRoof.Add(intVec);
                     }
                 }
             }
             justRoofedCells.Clear();
             foreach (IntVec3 item2 in cellsToRoof)
             {
                 RoofDef roofDef = map.roofGrid.RoofAt(item2);
                 if (roofDef == null && !justRoofedCells.Contains(item2) && !map.areaManager.NoRoof[item2] && RoofCollapseUtility.WithinRangeOfRoofHolder(item2, map, assumeNonNoRoofCellsAreRoofed: true))
                 {
                     map.areaManager.BuildRoof[item2] = true;
                     justRoofedCells.Add(item2);
                 }
             }
         }
     }
 }