public static void ProcessRoofHolderDespawned(CellRect rect, IntVec3 position, Map map, bool removalMode = false, bool canRemoveThickRoof = false)
        {
            CheckCollapseFlyingRoofs(rect, map, removalMode, canRemoveThickRoof);
            RoofGrid roofGrid = map.roofGrid;

            roofsCollapsingBecauseTooFar.Clear();
            for (int i = 0; i < RoofCollapseUtility.RoofSupportRadialCellsCount; i++)
            {
                IntVec3 intVec = position + GenRadial.RadialPattern[i];
                if (intVec.InBounds(map) && roofGrid.Roofed(intVec.x, intVec.z) && !map.roofCollapseBuffer.IsMarkedToCollapse(intVec) && !RoofCollapseUtility.WithinRangeOfRoofHolder(intVec, map))
                {
                    if (removalMode && (canRemoveThickRoof || intVec.GetRoof(map).VanishOnCollapse))
                    {
                        map.roofGrid.SetRoof(intVec, null);
                    }
                    else
                    {
                        map.roofCollapseBuffer.MarkToCollapse(intVec);
                    }
                    roofsCollapsingBecauseTooFar.Add(intVec);
                }
            }
            CheckCollapseFlyingRoofs(roofsCollapsingBecauseTooFar, map, removalMode, canRemoveThickRoof);
            roofsCollapsingBecauseTooFar.Clear();
        }
        public static void ProcessRoofHolderDespawned(CellRect rect, IntVec3 position, Map map, bool removalMode = false)
        {
            RoofCollapseCellsFinder.CheckCollapseFlyingRoofs(rect, map);
            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))
                            {
                                if (removalMode)
                                {
                                    map.roofGrid.SetRoof(intVec, null);
                                }
                                else
                                {
                                    map.roofCollapseBuffer.MarkToCollapse(intVec);
                                }
                                RoofCollapseCellsFinder.roofsCollapsingBecauseTooFar.Add(intVec);
                            }
                        }
                    }
                }
            }
            RoofCollapseCellsFinder.CheckCollapseFlyingRoofs(RoofCollapseCellsFinder.roofsCollapsingBecauseTooFar, map, removalMode);
            RoofCollapseCellsFinder.roofsCollapsingBecauseTooFar.Clear();
        }
Beispiel #3
0
        public static bool IsAnyCellUnderRoof(Thing thing)
        {
            CellRect cellRect = thing.OccupiedRect();
            bool     result   = false;
            RoofGrid roofGrid = thing.Map.roofGrid;

            foreach (IntVec3 item in cellRect)
            {
                if (roofGrid.Roofed(item))
                {
                    return(true);
                }
            }
            return(result);
        }
Beispiel #4
0
 public int OpenRoofCountStopAt(int threshold)
 {
     if (cachedOpenRoofCount == -1 && cachedOpenRoofState == null)
     {
         cachedOpenRoofCount = 0;
         cachedOpenRoofState = Cells.GetEnumerator();
     }
     if (cachedOpenRoofCount < threshold && cachedOpenRoofState != null)
     {
         RoofGrid roofGrid = Map.roofGrid;
         while (cachedOpenRoofCount < threshold && cachedOpenRoofState.MoveNext())
         {
             if (!roofGrid.Roofed(cachedOpenRoofState.Current))
             {
                 cachedOpenRoofCount++;
             }
         }
         if (cachedOpenRoofCount < threshold)
         {
             cachedOpenRoofState = null;
         }
     }
     return(cachedOpenRoofCount);
 }
Beispiel #5
0
        public override void Regenerate()
        {
            LayerSubMesh subMesh = base.GetSubMesh(MatBases.LightOverlay);

            if (subMesh.verts.Count == 0)
            {
                this.MakeBaseGeometry(subMesh);
            }
            Color32[] array = new Color32[subMesh.verts.Count];
            int       maxX  = this.sectRect.maxX;
            int       maxZ  = this.sectRect.maxZ;

            bool[]      array2      = new bool[4];
            Thing[]     innerArray  = base.Map.edificeGrid.InnerArray;
            RoofGrid    roofGrid    = base.Map.roofGrid;
            CellIndices cellIndices = base.Map.cellIndices;

            for (int i = this.sectRect.minX; i <= maxX + 1; i++)
            {
                for (int j = this.sectRect.minZ; j <= maxZ + 1; j++)
                {
                    int num  = default(int);
                    int num2 = default(int);
                    int num3 = default(int);
                    int num4 = default(int);
                    int num5 = default(int);
                    this.CalculateVertexIndices(i, j, out num, out num2, out num3, out num4, out num5);
                    IntVec3 a    = new IntVec3(i, 0, j);
                    bool    flag = false;
                    for (int k = 0; k < 4; k++)
                    {
                        IntVec3 c = a + SectionLayer_LightingOverlay.CheckSquareOffsets[k];
                        if (!c.InBounds(base.Map))
                        {
                            array2[k] = true;
                        }
                        else
                        {
                            Thing   thing   = innerArray[cellIndices.CellToIndex(c)];
                            RoofDef roofDef = roofGrid.RoofAt(c.x, c.z);
                            if (roofDef != null && (roofDef.isThickRoof || thing == null || !thing.def.holdsRoof || thing.def.altitudeLayer == AltitudeLayer.DoorMoveable))
                            {
                                flag = true;
                            }
                            if (thing != null && thing.def.blockLight)
                            {
                                array2[k] = true;
                            }
                            else
                            {
                                array2[k] = false;
                            }
                        }
                    }
                    ColorInt colorInt = new ColorInt(0, 0, 0, 0);
                    int      num6     = 0;
                    if (!array2[0])
                    {
                        colorInt += this.glowGrid[cellIndices.CellToIndex(i, j - 1)].AsColorInt();
                        num6++;
                    }
                    if (!array2[1])
                    {
                        colorInt += this.glowGrid[cellIndices.CellToIndex(i - 1, j - 1)].AsColorInt();
                        num6++;
                    }
                    if (!array2[2])
                    {
                        colorInt += this.glowGrid[cellIndices.CellToIndex(i - 1, j)].AsColorInt();
                        num6++;
                    }
                    if (!array2[3])
                    {
                        colorInt += this.glowGrid[cellIndices.CellToIndex(i, j)].AsColorInt();
                        num6++;
                    }
                    if (num6 > 0)
                    {
                        colorInt  /= (float)num6;
                        array[num] = colorInt.ToColor32;
                    }
                    else
                    {
                        array[num] = new Color32(0, 0, 0, 0);
                    }
                    if (flag && array[num].a < 100)
                    {
                        array[num].a = 100;
                    }
                }
            }
            for (int l = this.sectRect.minX; l <= maxX; l++)
            {
                for (int m = this.sectRect.minZ; m <= maxZ; m++)
                {
                    int num7  = default(int);
                    int num8  = default(int);
                    int num9  = default(int);
                    int num10 = default(int);
                    int num11 = default(int);
                    this.CalculateVertexIndices(l, m, out num7, out num8, out num9, out num10, out num11);
                    ColorInt colA = default(ColorInt) + array[num7];
                    colA        += array[num8];
                    colA        += array[num9];
                    colA        += array[num10];
                    array[num11] = (colA / 4f).ToColor32;
                    Thing thing = innerArray[cellIndices.CellToIndex(l, m)];
                    if (roofGrid.Roofed(l, m) && (thing == null || !thing.def.holdsRoof) && array[num11].a < 100)
                    {
                        array[num11].a = 100;
                    }
                }
            }
            subMesh.mesh.colors32 = array;
        }
Beispiel #6
0
 public void ConstructComponents()
 {
     this.spawnedThings      = new ThingOwner <Thing>(this);
     this.cellIndices        = new CellIndices(this);
     this.listerThings       = new ListerThings(ListerThingsUse.Global);
     this.listerBuildings    = new ListerBuildings();
     this.mapPawns           = new MapPawns(this);
     this.dynamicDrawManager = new DynamicDrawManager(this);
     this.mapDrawer          = new MapDrawer(this);
     this.tooltipGiverList   = new TooltipGiverList();
     this.pawnDestinationReservationManager = new PawnDestinationReservationManager();
     this.reservationManager = new ReservationManager(this);
     this.physicalInteractionReservationManager = new PhysicalInteractionReservationManager();
     this.designationManager             = new DesignationManager(this);
     this.lordManager                    = new LordManager(this);
     this.debugDrawer                    = new DebugCellDrawer();
     this.passingShipManager             = new PassingShipManager(this);
     this.haulDestinationManager         = new HaulDestinationManager(this);
     this.gameConditionManager           = new GameConditionManager(this);
     this.weatherManager                 = new WeatherManager(this);
     this.zoneManager                    = new ZoneManager(this);
     this.resourceCounter                = new ResourceCounter(this);
     this.mapTemperature                 = new MapTemperature(this);
     this.temperatureCache               = new TemperatureCache(this);
     this.areaManager                    = new AreaManager(this);
     this.attackTargetsCache             = new AttackTargetsCache(this);
     this.attackTargetReservationManager = new AttackTargetReservationManager(this);
     this.lordsStarter                   = new VoluntarilyJoinableLordsStarter(this);
     this.thingGrid                  = new ThingGrid(this);
     this.coverGrid                  = new CoverGrid(this);
     this.edificeGrid                = new EdificeGrid(this);
     this.blueprintGrid              = new BlueprintGrid(this);
     this.fogGrid                    = new FogGrid(this);
     this.glowGrid                   = new GlowGrid(this);
     this.regionGrid                 = new RegionGrid(this);
     this.terrainGrid                = new TerrainGrid(this);
     this.pathGrid                   = new PathGrid(this);
     this.roofGrid                   = new RoofGrid(this);
     this.fertilityGrid              = new FertilityGrid(this);
     this.snowGrid                   = new SnowGrid(this);
     this.deepResourceGrid           = new DeepResourceGrid(this);
     this.exitMapGrid                = new ExitMapGrid(this);
     this.linkGrid                   = new LinkGrid(this);
     this.glowFlooder                = new GlowFlooder(this);
     this.powerNetManager            = new PowerNetManager(this);
     this.powerNetGrid               = new PowerNetGrid(this);
     this.regionMaker                = new RegionMaker(this);
     this.pathFinder                 = new PathFinder(this);
     this.pawnPathPool               = new PawnPathPool(this);
     this.regionAndRoomUpdater       = new RegionAndRoomUpdater(this);
     this.regionLinkDatabase         = new RegionLinkDatabase();
     this.moteCounter                = new MoteCounter();
     this.gatherSpotLister           = new GatherSpotLister();
     this.windManager                = new WindManager(this);
     this.listerBuildingsRepairable  = new ListerBuildingsRepairable();
     this.listerHaulables            = new ListerHaulables(this);
     this.listerMergeables           = new ListerMergeables(this);
     this.listerFilthInHomeArea      = new ListerFilthInHomeArea(this);
     this.reachability               = new Reachability(this);
     this.itemAvailability           = new ItemAvailability(this);
     this.autoBuildRoofAreaSetter    = new AutoBuildRoofAreaSetter(this);
     this.roofCollapseBufferResolver = new RoofCollapseBufferResolver(this);
     this.roofCollapseBuffer         = new RoofCollapseBuffer();
     this.wildAnimalSpawner          = new WildAnimalSpawner(this);
     this.wildPlantSpawner           = new WildPlantSpawner(this);
     this.steadyEnvironmentEffects   = new SteadyEnvironmentEffects(this);
     this.skyManager                 = new SkyManager(this);
     this.overlayDrawer              = new OverlayDrawer();
     this.floodFiller                = new FloodFiller(this);
     this.weatherDecider             = new WeatherDecider(this);
     this.fireWatcher                = new FireWatcher(this);
     this.dangerWatcher              = new DangerWatcher(this);
     this.damageWatcher              = new DamageWatcher();
     this.strengthWatcher            = new StrengthWatcher(this);
     this.wealthWatcher              = new WealthWatcher(this);
     this.regionDirtyer              = new RegionDirtyer(this);
     this.cellsInRandomOrder         = new MapCellsInRandomOrder(this);
     this.rememberedCameraPos        = new RememberedCameraPos(this);
     this.mineStrikeManager          = new MineStrikeManager();
     this.storyState                 = new StoryState(this);
     this.retainedCaravanData        = new RetainedCaravanData(this);
     this.components.Clear();
     this.FillComponents();
 }
Beispiel #7
0
        public override void Regenerate()
        {
            LayerSubMesh subMesh = base.GetSubMesh(MatBases.LightOverlay);

            if (subMesh.verts.Count == 0)
            {
                this.MakeBaseGeometry(subMesh);
            }
            Color32[] array = new Color32[subMesh.verts.Count];
            int       maxX  = this.sectRect.maxX;
            int       maxZ  = this.sectRect.maxZ;
            int       width = this.sectRect.Width;
            Map       map   = base.Map;
            int       x     = map.Size.x;

            Thing[]     innerArray  = map.edificeGrid.InnerArray;
            int         num         = innerArray.Length;
            RoofGrid    roofGrid    = map.roofGrid;
            CellIndices cellIndices = map.cellIndices;
            int         num2;
            int         num3;
            int         num4;
            int         num5;
            int         num6;

            this.CalculateVertexIndices(this.sectRect.minX, this.sectRect.minZ, out num2, out num3, out num4, out num5, out num6);
            int num7 = cellIndices.CellToIndex(new IntVec3(this.sectRect.minX, 0, this.sectRect.minZ));

            int[] array2 = new int[4];
            array2[0] = -map.Size.x - 1;
            array2[1] = -map.Size.x;
            array2[2] = -1;
            int[] array3 = array2;
            int[] array4 = new int[4];
            array4[0] = -1;
            array4[1] = -1;
            int[] array5 = array4;
            for (int i = this.sectRect.minZ; i <= maxZ + 1; i++)
            {
                int num8 = num7 / x;
                int j    = this.sectRect.minX;
                while (j <= maxX + 1)
                {
                    ColorInt colorInt = new ColorInt(0, 0, 0, 0);
                    int      num9     = 0;
                    bool     flag     = false;
                    for (int k = 0; k < 4; k++)
                    {
                        int num10 = num7 + array3[k];
                        if (num10 >= 0 && num10 < num && num10 / x == num8 + array5[k])
                        {
                            Thing   thing   = innerArray[num10];
                            RoofDef roofDef = roofGrid.RoofAt(num10);
                            if (roofDef != null && (roofDef.isThickRoof || thing == null || !thing.def.holdsRoof || thing.def.altitudeLayer == AltitudeLayer.DoorMoveable))
                            {
                                flag = true;
                            }
                            if (thing == null || !thing.def.blockLight)
                            {
                                colorInt += this.glowGrid[num10];
                                num9++;
                            }
                        }
                    }
                    if (num9 > 0)
                    {
                        array[num2] = (colorInt / num9).ToColor32;
                    }
                    else
                    {
                        array[num2] = new Color32(0, 0, 0, 0);
                    }
                    if (flag && array[num2].a < 100)
                    {
                        array[num2].a = 100;
                    }
                    j++;
                    num2++;
                    num7++;
                }
                int num11 = maxX + 2 - this.sectRect.minX;
                num2 -= num11;
                num7 -= num11;
                num2 += width + 1;
                num7 += map.Size.x;
            }
            int num12;
            int num13;
            int num14;
            int num15;
            int num16;

            this.CalculateVertexIndices(this.sectRect.minX, this.sectRect.minZ, out num12, out num13, out num14, out num15, out num16);
            int num17 = cellIndices.CellToIndex(this.sectRect.minX, this.sectRect.minZ);

            for (int l = this.sectRect.minZ; l <= maxZ; l++)
            {
                int m = this.sectRect.minX;
                while (m <= maxX)
                {
                    ColorInt colA = default(ColorInt) + array[num12];
                    colA        += array[num12 + 1];
                    colA        += array[num12 + width + 1];
                    colA        += array[num12 + width + 2];
                    array[num16] = new Color32((byte)(colA.r / 4), (byte)(colA.g / 4), (byte)(colA.b / 4), (byte)(colA.a / 4));
                    if (array[num16].a < 100 && roofGrid.Roofed(num17))
                    {
                        Thing thing2 = innerArray[num17];
                        if (thing2 == null || !thing2.def.holdsRoof)
                        {
                            array[num16].a = 100;
                        }
                    }
                    m++;
                    num12++;
                    num16++;
                    num17++;
                }
                num12++;
                num17 -= width;
                num17 += map.Size.x;
            }
            subMesh.mesh.colors32 = array;
        }
Beispiel #8
0
        public override void Regenerate()
        {
            LayerSubMesh subMesh = GetSubMesh(MatBases.LightOverlay);

            if (subMesh.verts.Count == 0)
            {
                MakeBaseGeometry(subMesh);
            }
            Color32[] array = new Color32[subMesh.verts.Count];
            int       maxX  = sectRect.maxX;
            int       maxZ  = sectRect.maxZ;
            int       width = sectRect.Width;
            Map       map   = base.Map;
            int       x     = map.Size.x;

            Thing[]     innerArray  = map.edificeGrid.InnerArray;
            Thing[]     array2      = innerArray;
            int         num         = array2.Length;
            RoofGrid    roofGrid    = map.roofGrid;
            CellIndices cellIndices = map.cellIndices;

            CalculateVertexIndices(sectRect.minX, sectRect.minZ, out int botLeft, out int _, out int _, out int _, out int _);
            int num2 = cellIndices.CellToIndex(new IntVec3(sectRect.minX, 0, sectRect.minZ));

            int[] array3 = new int[4]
            {
                -map.Size.x - 1,
                -map.Size.x,
                -1,
                0
            };
            int[] array4 = new int[4]
            {
                -1,
                -1,
                0,
                0
            };
            for (int i = sectRect.minZ; i <= maxZ + 1; i++)
            {
                int num3 = num2 / x;
                int num4 = sectRect.minX;
                while (num4 <= maxX + 1)
                {
                    ColorInt a    = new ColorInt(0, 0, 0, 0);
                    int      num5 = 0;
                    bool     flag = false;
                    for (int j = 0; j < 4; j++)
                    {
                        int num6 = num2 + array3[j];
                        if (num6 >= 0 && num6 < num && num6 / x == num3 + array4[j])
                        {
                            Thing   thing   = array2[num6];
                            RoofDef roofDef = roofGrid.RoofAt(num6);
                            if (roofDef != null && (roofDef.isThickRoof || thing == null || !thing.def.holdsRoof || thing.def.altitudeLayer == AltitudeLayer.DoorMoveable))
                            {
                                flag = true;
                            }
                            if (thing == null || !thing.def.blockLight)
                            {
                                a += glowGrid[num6];
                                num5++;
                            }
                        }
                    }
                    if (num5 > 0)
                    {
                        array[botLeft] = (a / num5).ToColor32;
                    }
                    else
                    {
                        array[botLeft] = new Color32(0, 0, 0, 0);
                    }
                    if (flag && array[botLeft].a < 100)
                    {
                        array[botLeft].a = 100;
                    }
                    num4++;
                    botLeft++;
                    num2++;
                }
                int num7 = maxX + 2 - sectRect.minX;
                botLeft -= num7;
                num2    -= num7;
                botLeft += width + 1;
                num2    += map.Size.x;
            }
            CalculateVertexIndices(sectRect.minX, sectRect.minZ, out int botLeft2, out int _, out int _, out int _, out int center2);
            int num8 = cellIndices.CellToIndex(sectRect.minX, sectRect.minZ);

            for (int k = sectRect.minZ; k <= maxZ; k++)
            {
                int num9 = sectRect.minX;
                while (num9 <= maxX)
                {
                    ColorInt colorInt = default(ColorInt) + array[botLeft2];
                    colorInt      += array[botLeft2 + 1];
                    colorInt      += array[botLeft2 + width + 1];
                    colorInt      += array[botLeft2 + width + 2];
                    array[center2] = new Color32((byte)(colorInt.r / 4), (byte)(colorInt.g / 4), (byte)(colorInt.b / 4), (byte)(colorInt.a / 4));
                    if (array[center2].a < 100 && roofGrid.Roofed(num8))
                    {
                        Thing thing2 = array2[num8];
                        if (thing2 == null || !thing2.def.holdsRoof)
                        {
                            array[center2].a = 100;
                        }
                    }
                    num9++;
                    botLeft2++;
                    center2++;
                    num8++;
                }
                botLeft2++;
                num8 -= width;
                num8 += map.Size.x;
            }
            subMesh.mesh.colors32 = array;
        }