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) && intVec.Roofed(map) && !visitedCells.Contains(intVec) && !roofCollapseBuffer.IsMarkedToCollapse(intVec) && !ConnectsToRoofHolder(intVec, map, visitedCells))
                {
                    map.floodFiller.FloodFill(intVec, (IntVec3 x) => x.Roofed(map), delegate(IntVec3 x)
                    {
                        roofCollapseBuffer.MarkToCollapse(x);
                    });
                    if (removalMode)
                    {
                        List <IntVec3> cellsMarkedToCollapse = roofCollapseBuffer.CellsMarkedToCollapse;
                        for (int num = cellsMarkedToCollapse.Count - 1; num >= 0; num--)
                        {
                            RoofDef roofDef = map.roofGrid.RoofAt(cellsMarkedToCollapse[num]);
                            if (roofDef != null && (canRemoveThickRoof || roofDef.VanishOnCollapse))
                            {
                                map.roofGrid.SetRoof(cellsMarkedToCollapse[num], null);
                                cellsMarkedToCollapse.RemoveAt(num);
                            }
                        }
                    }
                }
            }
            return(false);
        }
Beispiel #2
0
        public void CollapseRoofsMarkedToCollapse()
        {
            RoofCollapseBuffer roofCollapseBuffer = map.roofCollapseBuffer;

            if (!roofCollapseBuffer.CellsMarkedToCollapse.Any())
            {
                return;
            }
            tmpCrushedThings.Clear();
            RoofCollapserImmediate.DropRoofInCells(roofCollapseBuffer.CellsMarkedToCollapse, map, tmpCrushedThings);
            if (tmpCrushedThings.Any())
            {
                StringBuilder stringBuilder = new StringBuilder();
                stringBuilder.AppendLine("RoofCollapsed".Translate());
                stringBuilder.AppendLine();
                stringBuilder.AppendLine("TheseThingsCrushed".Translate());
                tmpCrushedNames.Clear();
                for (int i = 0; i < tmpCrushedThings.Count; i++)
                {
                    Thing  thing = tmpCrushedThings[i];
                    Corpse corpse;
                    if ((corpse = thing as Corpse) == null || !corpse.Bugged)
                    {
                        string item = thing.LabelShortCap;
                        if (thing.def.category == ThingCategory.Pawn)
                        {
                            item = thing.LabelCap;
                        }
                        if (!tmpCrushedNames.Contains(item))
                        {
                            tmpCrushedNames.Add(item);
                        }
                    }
                }
                foreach (string tmpCrushedName in tmpCrushedNames)
                {
                    stringBuilder.AppendLine("    -" + tmpCrushedName);
                }
                Find.LetterStack.ReceiveLetter("LetterLabelRoofCollapsed".Translate(), stringBuilder.ToString().TrimEndNewlines(), LetterDefOf.NegativeEvent, new TargetInfo(roofCollapseBuffer.CellsMarkedToCollapse[0], map));
            }
            else
            {
                Messages.Message("RoofCollapsed".Translate(), new TargetInfo(roofCollapseBuffer.CellsMarkedToCollapse[0], map), MessageTypeDefOf.SilentInput);
            }
            tmpCrushedThings.Clear();
            roofCollapseBuffer.Clear();
        }
        private static bool CheckCollapseFlyingRoofAtAndAdjInternal(IntVec3 root, Map map, bool removalMode)
        {
            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);
                                    }, 2147483647, 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 && roofDef.VanishOnCollapse)
                                            {
                                                map.roofGrid.SetRoof(cellsMarkedToCollapse[j], null);
                                                cellsMarkedToCollapse.RemoveAt(j);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return(false);
        }
Beispiel #4
0
        public void CollapseRoofsMarkedToCollapse()
        {
            RoofCollapseBuffer roofCollapseBuffer = this.map.roofCollapseBuffer;

            if (roofCollapseBuffer.CellsMarkedToCollapse.Any <IntVec3>())
            {
                this.tmpCrushedThings.Clear();
                RoofCollapserImmediate.DropRoofInCells(roofCollapseBuffer.CellsMarkedToCollapse, this.map, this.tmpCrushedThings);
                if (this.tmpCrushedThings.Any <Thing>())
                {
                    StringBuilder stringBuilder = new StringBuilder();
                    stringBuilder.AppendLine("RoofCollapsed".Translate());
                    stringBuilder.AppendLine();
                    stringBuilder.AppendLine("TheseThingsCrushed".Translate());
                    this.tmpCrushedNames.Clear();
                    for (int i = 0; i < this.tmpCrushedThings.Count; i++)
                    {
                        Thing  thing = this.tmpCrushedThings[i];
                        string item  = thing.LabelShort.CapitalizeFirst();
                        if (thing.def.category == ThingCategory.Pawn)
                        {
                            item = thing.LabelCap;
                        }
                        if (!this.tmpCrushedNames.Contains(item))
                        {
                            this.tmpCrushedNames.Add(item);
                        }
                    }
                    foreach (string str in this.tmpCrushedNames)
                    {
                        stringBuilder.AppendLine("    -" + str);
                    }
                    Find.LetterStack.ReceiveLetter("LetterLabelRoofCollapsed".Translate(), stringBuilder.ToString().TrimEndNewlines(), LetterDefOf.NegativeEvent, new TargetInfo(roofCollapseBuffer.CellsMarkedToCollapse[0], this.map, false), null, null);
                }
                else
                {
                    string text = "RoofCollapsed".Translate();
                    Messages.Message(text, new TargetInfo(roofCollapseBuffer.CellsMarkedToCollapse[0], this.map, false), MessageTypeDefOf.SilentInput, true);
                }
                this.tmpCrushedThings.Clear();
                roofCollapseBuffer.Clear();
            }
        }
Beispiel #5
0
        public void CollapseRoofsMarkedToCollapse()
        {
            RoofCollapseBuffer roofCollapseBuffer = this.map.roofCollapseBuffer;

            if (roofCollapseBuffer.CellsMarkedToCollapse.Count > 0)
            {
                RoofCollapserImmediate.DropRoofInCells(roofCollapseBuffer.CellsMarkedToCollapse, this.map);
                if (roofCollapseBuffer.CrushedThingsForLetter.Count > 0)
                {
                    StringBuilder stringBuilder = new StringBuilder();
                    stringBuilder.AppendLine("RoofCollapsed".Translate());
                    stringBuilder.AppendLine();
                    stringBuilder.AppendLine("TheseThingsCrushed".Translate());
                    HashSet <string> hashSet = new HashSet <string>();
                    foreach (Thing item2 in roofCollapseBuffer.CrushedThingsForLetter)
                    {
                        string item = item2.LabelShort.CapitalizeFirst();
                        if (item2.def.category == ThingCategory.Pawn)
                        {
                            item = item2.LabelCap;
                        }
                        if (!hashSet.Contains(item))
                        {
                            hashSet.Add(item);
                        }
                    }
                    foreach (string item3 in hashSet)
                    {
                        stringBuilder.AppendLine("    -" + item3);
                    }
                    Find.LetterStack.ReceiveLetter("LetterLabelRoofCollapsed".Translate(), stringBuilder.ToString(), LetterDefOf.NegativeEvent, new TargetInfo(roofCollapseBuffer.CellsMarkedToCollapse[0], this.map, false), null);
                }
                else
                {
                    string text = "RoofCollapsed".Translate();
                    Messages.Message(text, new TargetInfo(roofCollapseBuffer.CellsMarkedToCollapse[0], this.map, false), MessageTypeDefOf.NegativeHealthEvent);
                }
                roofCollapseBuffer.Clear();
            }
        }
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();
 }