예제 #1
0
        private bool CheckForFreeIntercept(IntVec3 c)
        {
            if (destination.ToIntVec3() == c)
            {
                return(false);
            }
            float num = VerbUtility.InterceptChanceFactorFromDistance(origin, c);

            if (num <= 0f)
            {
                return(false);
            }
            bool         flag      = false;
            List <Thing> thingList = c.GetThingList(base.Map);

            for (int i = 0; i < thingList.Count; i++)
            {
                Thing thing = thingList[i];
                if (!CanHit(thing))
                {
                    continue;
                }
                bool flag2 = false;
                if (thing.def.Fillage == FillCategory.Full)
                {
                    Building_Door building_Door = thing as Building_Door;
                    if (building_Door == null || !building_Door.Open)
                    {
                        ThrowDebugText("int-wall", c);
                        Impact(thing);
                        return(true);
                    }
                    flag2 = true;
                }
                float num2 = 0f;
                Pawn  pawn = thing as Pawn;
                if (pawn != null)
                {
                    num2 = 0.4f * Mathf.Clamp(pawn.BodySize, 0.1f, 2f);
                    if (pawn.GetPosture() != 0)
                    {
                        num2 *= 0.1f;
                    }
                    if (launcher != null && pawn.Faction != null && launcher.Faction != null && !pawn.Faction.HostileTo(launcher.Faction))
                    {
                        num2 *= 0.4f;
                    }
                }
                else if (thing.def.fillPercent > 0.2f)
                {
                    num2 = (flag2 ? 0.05f : ((!DestinationCell.AdjacentTo8Way(c)) ? (thing.def.fillPercent * 0.15f) : (thing.def.fillPercent * 1f)));
                }
                num2 *= num;
                if (num2 > 1E-05f)
                {
                    if (Rand.Chance(num2))
                    {
                        ThrowDebugText("int-" + num2.ToStringPercent(), c);
                        Impact(thing);
                        return(true);
                    }
                    flag = true;
                    ThrowDebugText(num2.ToStringPercent(), c);
                }
            }
            if (!flag)
            {
                ThrowDebugText("o", c);
            }
            return(false);
        }
        private string CurrentDebugString()
        {
            StringBuilder stringBuilder = new StringBuilder();

            if (DebugViewSettings.writeGame)
            {
                stringBuilder.AppendLine("---");
                stringBuilder.AppendLine((Current.Game == null) ? "Current.Game = null" : Current.Game.DebugString());
            }
            if (DebugViewSettings.writeMusicManagerPlay)
            {
                stringBuilder.AppendLine("---");
                stringBuilder.AppendLine(Find.MusicManagerPlay.DebugString());
            }
            if (DebugViewSettings.writePlayingSounds)
            {
                stringBuilder.AppendLine("---");
                stringBuilder.AppendLine("Sustainers:");
                foreach (Sustainer allSustainer in Find.SoundRoot.sustainerManager.AllSustainers)
                {
                    stringBuilder.AppendLine(allSustainer.DebugString());
                }
                stringBuilder.AppendLine();
                stringBuilder.AppendLine("OneShots:");
                foreach (SampleOneShot playingOneShot in Find.SoundRoot.oneShotManager.PlayingOneShots)
                {
                    stringBuilder.AppendLine(playingOneShot.ToString());
                }
            }
            if (DebugViewSettings.writeSoundEventsRecord)
            {
                stringBuilder.AppendLine("---");
                stringBuilder.AppendLine("Recent sound events:\n       ...");
                stringBuilder.AppendLine(DebugSoundEventsLog.EventsListingDebugString);
            }
            if (DebugViewSettings.writeSteamItems)
            {
                stringBuilder.AppendLine("---");
                stringBuilder.AppendLine(WorkshopItems.DebugOutput());
            }
            if (DebugViewSettings.writeConcepts)
            {
                stringBuilder.AppendLine("---");
                stringBuilder.AppendLine(LessonAutoActivator.DebugString());
            }
            if (DebugViewSettings.writeReservations && Find.CurrentMap != null)
            {
                stringBuilder.AppendLine("---");
                stringBuilder.AppendLine(string.Join("\r\n", Find.CurrentMap.reservationManager.ReservationsReadOnly.Select((ReservationManager.Reservation r) => r.ToString()).ToArray()));
            }
            if (DebugViewSettings.writeMemoryUsage)
            {
                stringBuilder.AppendLine("---");
                stringBuilder.AppendLine("Total allocated: " + Profiler.GetTotalAllocatedMemoryLong().ToStringBytes());
                stringBuilder.AppendLine("Total reserved: " + Profiler.GetTotalReservedMemoryLong().ToStringBytes());
                stringBuilder.AppendLine("Total reserved unused: " + Profiler.GetTotalUnusedReservedMemoryLong().ToStringBytes());
                stringBuilder.AppendLine("Mono heap size: " + Profiler.GetMonoHeapSizeLong().ToStringBytes());
                stringBuilder.AppendLine("Mono used size: " + Profiler.GetMonoUsedSizeLong().ToStringBytes());
            }
            if (Current.ProgramState == ProgramState.Playing)
            {
                stringBuilder.AppendLine("Tick " + Find.TickManager.TicksGame);
                if (DebugViewSettings.writeStoryteller)
                {
                    stringBuilder.AppendLine("---");
                    stringBuilder.AppendLine(Find.Storyteller.DebugString());
                }
            }
            if (Current.ProgramState == ProgramState.Playing && Find.CurrentMap != null)
            {
                if (DebugViewSettings.writeMapGameConditions)
                {
                    stringBuilder.AppendLine("---");
                    stringBuilder.AppendLine(Find.CurrentMap.gameConditionManager.DebugString());
                }
                if (DebugViewSettings.drawPawnDebug)
                {
                    stringBuilder.AppendLine("---");
                    stringBuilder.AppendLine(Find.CurrentMap.reservationManager.DebugString());
                }
                if (DebugViewSettings.writeMoteSaturation)
                {
                    stringBuilder.AppendLine("---");
                    stringBuilder.AppendLine("Mote count: " + Find.CurrentMap.moteCounter.MoteCount);
                    stringBuilder.AppendLine("Mote saturation: " + Find.CurrentMap.moteCounter.Saturation);
                }
                if (DebugViewSettings.writeEcosystem)
                {
                    stringBuilder.AppendLine("---");
                    stringBuilder.AppendLine(Find.CurrentMap.wildAnimalSpawner.DebugString());
                }
                if (DebugViewSettings.writeTotalSnowDepth)
                {
                    stringBuilder.AppendLine("---");
                    stringBuilder.AppendLine("Total snow depth: " + Find.CurrentMap.snowGrid.TotalDepth);
                }
                if (DebugViewSettings.writeWind)
                {
                    stringBuilder.AppendLine("---");
                    stringBuilder.AppendLine(Find.CurrentMap.windManager.DebugString());
                }
                if (DebugViewSettings.writeRecentStrikes)
                {
                    stringBuilder.AppendLine("---");
                    stringBuilder.AppendLine(Find.CurrentMap.mineStrikeManager.DebugStrikeRecords());
                }
                if (DebugViewSettings.writeListRepairableBldgs)
                {
                    stringBuilder.AppendLine("---");
                    stringBuilder.AppendLine(Find.CurrentMap.listerBuildingsRepairable.DebugString());
                }
                if (DebugViewSettings.writeListFilthInHomeArea)
                {
                    stringBuilder.AppendLine("---");
                    stringBuilder.AppendLine(Find.CurrentMap.listerFilthInHomeArea.DebugString());
                }
                if (DebugViewSettings.writeListHaulables)
                {
                    stringBuilder.AppendLine("---");
                    stringBuilder.AppendLine(Find.CurrentMap.listerHaulables.DebugString());
                }
                if (DebugViewSettings.writeListMergeables)
                {
                    stringBuilder.AppendLine("---");
                    stringBuilder.AppendLine(Find.CurrentMap.listerMergeables.DebugString());
                }
                if (DebugViewSettings.drawLords)
                {
                    foreach (Lord lord in Find.CurrentMap.lordManager.lords)
                    {
                        stringBuilder.AppendLine("---");
                        stringBuilder.AppendLine(lord.DebugString());
                    }
                }
                IntVec3 intVec = UI.MouseCell();
                if (intVec.InBounds(Find.CurrentMap))
                {
                    stringBuilder.AppendLine("Inspecting " + intVec.ToString());
                    if (DebugViewSettings.writeTerrain)
                    {
                        stringBuilder.AppendLine("---");
                        stringBuilder.AppendLine(Find.CurrentMap.terrainGrid.DebugStringAt(intVec));
                    }
                    if (DebugViewSettings.writeAttackTargets)
                    {
                        foreach (Pawn item in Find.CurrentMap.thingGrid.ThingsAt(UI.MouseCell()).OfType <Pawn>())
                        {
                            stringBuilder.AppendLine("---");
                            stringBuilder.AppendLine("Potential attack targets for " + item.LabelShort + ":");
                            List <IAttackTarget> potentialTargetsFor = Find.CurrentMap.attackTargetsCache.GetPotentialTargetsFor(item);
                            for (int i = 0; i < potentialTargetsFor.Count; i++)
                            {
                                Thing thing = (Thing)potentialTargetsFor[i];
                                stringBuilder.AppendLine(thing.LabelShort + ", " + thing.Faction + (potentialTargetsFor[i].ThreatDisabled(null) ? " (threat disabled)" : ""));
                            }
                        }
                    }
                    if (DebugViewSettings.writeSnowDepth)
                    {
                        stringBuilder.AppendLine("---");
                        stringBuilder.AppendLine("Snow depth: " + Find.CurrentMap.snowGrid.GetDepth(intVec));
                    }
                    if (DebugViewSettings.drawDeepResources)
                    {
                        stringBuilder.AppendLine("---");
                        stringBuilder.AppendLine("Deep resource def: " + Find.CurrentMap.deepResourceGrid.ThingDefAt(intVec));
                        stringBuilder.AppendLine("Deep resource count: " + Find.CurrentMap.deepResourceGrid.CountAt(intVec));
                    }
                    if (DebugViewSettings.writeCanReachColony)
                    {
                        stringBuilder.AppendLine("---");
                        stringBuilder.AppendLine("CanReachColony: " + Find.CurrentMap.reachability.CanReachColony(UI.MouseCell()).ToString());
                    }
                    if (DebugViewSettings.writeMentalStateCalcs)
                    {
                        stringBuilder.AppendLine("---");
                        foreach (Pawn item2 in (from t in Find.CurrentMap.thingGrid.ThingsAt(UI.MouseCell())
                                                where t is Pawn
                                                select t).Cast <Pawn>())
                        {
                            stringBuilder.AppendLine(item2.mindState.mentalBreaker.DebugString());
                        }
                    }
                    if (DebugViewSettings.writeWorkSettings)
                    {
                        foreach (Pawn item3 in (from t in Find.CurrentMap.thingGrid.ThingsAt(UI.MouseCell())
                                                where t is Pawn
                                                select t).Cast <Pawn>())
                        {
                            if (item3.workSettings != null)
                            {
                                stringBuilder.AppendLine("---");
                                stringBuilder.AppendLine(item3.workSettings.DebugString());
                            }
                        }
                    }
                    if (DebugViewSettings.writeApparelScore)
                    {
                        stringBuilder.AppendLine("---");
                        if (intVec.InBounds(Find.CurrentMap))
                        {
                            foreach (Thing thing3 in intVec.GetThingList(Find.CurrentMap))
                            {
                                Apparel apparel = thing3 as Apparel;
                                if (apparel != null)
                                {
                                    stringBuilder.AppendLine(apparel.Label + ": " + JobGiver_OptimizeApparel.ApparelScoreRaw(null, apparel).ToString("F2"));
                                }
                            }
                        }
                    }
                    if (DebugViewSettings.writeCellContents || fullMode)
                    {
                        stringBuilder.AppendLine("---");
                        if (intVec.InBounds(Find.CurrentMap))
                        {
                            foreach (Designation item4 in Find.CurrentMap.designationManager.AllDesignationsAt(intVec))
                            {
                                stringBuilder.AppendLine(item4.ToString());
                            }
                            foreach (Thing item5 in Find.CurrentMap.thingGrid.ThingsAt(intVec))
                            {
                                if (!fullMode)
                                {
                                    stringBuilder.AppendLine(item5.LabelCap + " - " + item5.ToString());
                                }
                                else
                                {
                                    stringBuilder.AppendLine(Scribe.saver.DebugOutputFor(item5));
                                    stringBuilder.AppendLine();
                                }
                            }
                        }
                    }
                    if (DebugViewSettings.debugApparelOptimize)
                    {
                        stringBuilder.AppendLine("---");
                        foreach (Thing item6 in Find.CurrentMap.thingGrid.ThingsAt(intVec))
                        {
                            Apparel apparel2 = item6 as Apparel;
                            if (apparel2 != null)
                            {
                                stringBuilder.AppendLine(apparel2.LabelCap);
                                stringBuilder.AppendLine("   raw: " + JobGiver_OptimizeApparel.ApparelScoreRaw(null, apparel2).ToString("F2"));
                                Pawn pawn = Find.Selector.SingleSelectedThing as Pawn;
                                if (pawn != null)
                                {
                                    stringBuilder.AppendLine("  Pawn: " + pawn);
                                    stringBuilder.AppendLine("  gain: " + JobGiver_OptimizeApparel.ApparelScoreGain(pawn, apparel2).ToString("F2"));
                                }
                            }
                        }
                    }
                    if (DebugViewSettings.drawRegions)
                    {
                        stringBuilder.AppendLine("---");
                        Region regionAt_NoRebuild_InvalidAllowed = Find.CurrentMap.regionGrid.GetRegionAt_NoRebuild_InvalidAllowed(intVec);
                        stringBuilder.AppendLine("Region:\n" + ((regionAt_NoRebuild_InvalidAllowed != null) ? regionAt_NoRebuild_InvalidAllowed.DebugString : "null"));
                    }
                    if (DebugViewSettings.drawRooms)
                    {
                        stringBuilder.AppendLine("---");
                        Room room = intVec.GetRoom(Find.CurrentMap, RegionType.Set_All);
                        if (room != null)
                        {
                            stringBuilder.AppendLine(room.DebugString());
                        }
                        else
                        {
                            stringBuilder.AppendLine("(no room)");
                        }
                    }
                    if (DebugViewSettings.drawRoomGroups)
                    {
                        stringBuilder.AppendLine("---");
                        RoomGroup roomGroup = intVec.GetRoomGroup(Find.CurrentMap);
                        if (roomGroup != null)
                        {
                            stringBuilder.AppendLine(roomGroup.DebugString());
                        }
                        else
                        {
                            stringBuilder.AppendLine("(no room group)");
                        }
                    }
                    if (DebugViewSettings.drawGlow)
                    {
                        stringBuilder.AppendLine("---");
                        stringBuilder.AppendLine("Game glow: " + Find.CurrentMap.glowGrid.GameGlowAt(intVec));
                        stringBuilder.AppendLine("Psych glow: " + Find.CurrentMap.glowGrid.PsychGlowAt(intVec));
                        stringBuilder.AppendLine("Visual Glow: " + Find.CurrentMap.glowGrid.VisualGlowAt(intVec));
                        stringBuilder.AppendLine("GlowReport:\n" + ((SectionLayer_LightingOverlay)Find.CurrentMap.mapDrawer.SectionAt(intVec).GetLayer(typeof(SectionLayer_LightingOverlay))).GlowReportAt(intVec));
                        stringBuilder.AppendLine("SkyManager.CurSkyGlow: " + Find.CurrentMap.skyManager.CurSkyGlow);
                    }
                    if (DebugViewSettings.writePathCosts)
                    {
                        stringBuilder.AppendLine("---");
                        stringBuilder.AppendLine("Perceived path cost: " + Find.CurrentMap.pathGrid.PerceivedPathCostAt(intVec));
                        stringBuilder.AppendLine("Real path cost: " + Find.CurrentMap.pathGrid.CalculatedCostAt(intVec, perceivedStatic: false, IntVec3.Invalid));
                    }
                    if (DebugViewSettings.writeFertility)
                    {
                        stringBuilder.AppendLine("---");
                        stringBuilder.AppendLine("\nFertility: " + Find.CurrentMap.fertilityGrid.FertilityAt(intVec).ToString("##0.00"));
                    }
                    if (DebugViewSettings.writeLinkFlags)
                    {
                        stringBuilder.AppendLine("---");
                        stringBuilder.AppendLine("\nLinkFlags: ");
                        foreach (object value in Enum.GetValues(typeof(LinkFlags)))
                        {
                            if ((Find.CurrentMap.linkGrid.LinkFlagsAt(intVec) & (LinkFlags)value) != 0)
                            {
                                stringBuilder.Append(" " + value);
                            }
                        }
                    }
                    if (DebugViewSettings.writeSkyManager)
                    {
                        stringBuilder.AppendLine("---");
                        stringBuilder.AppendLine(Find.CurrentMap.skyManager.DebugString());
                    }
                    if (DebugViewSettings.writeCover)
                    {
                        stringBuilder.AppendLine("---");
                        stringBuilder.Append("Cover: ");
                        Thing thing2 = Find.CurrentMap.coverGrid[intVec];
                        if (thing2 == null)
                        {
                            stringBuilder.AppendLine("null");
                        }
                        else
                        {
                            stringBuilder.AppendLine(thing2.ToString());
                        }
                    }
                    if (DebugViewSettings.drawPower)
                    {
                        stringBuilder.AppendLine("---");
                        foreach (Thing item7 in Find.CurrentMap.thingGrid.ThingsAt(intVec))
                        {
                            ThingWithComps thingWithComps = item7 as ThingWithComps;
                            if (thingWithComps != null && thingWithComps.GetComp <CompPowerTrader>() != null)
                            {
                                stringBuilder.AppendLine(" " + thingWithComps.GetComp <CompPowerTrader>().DebugString);
                            }
                        }
                        PowerNet powerNet = Find.CurrentMap.powerNetGrid.TransmittedPowerNetAt(intVec);
                        if (powerNet != null)
                        {
                            stringBuilder.AppendLine(powerNet.DebugString() ?? "");
                        }
                        else
                        {
                            stringBuilder.AppendLine("(no PowerNet here)");
                        }
                    }
                    if (DebugViewSettings.drawPreyInfo)
                    {
                        Pawn pawn2 = Find.Selector.SingleSelectedThing as Pawn;
                        if (pawn2 != null)
                        {
                            List <Thing> thingList = intVec.GetThingList(Find.CurrentMap);
                            for (int j = 0; j < thingList.Count; j++)
                            {
                                Pawn pawn3 = thingList[j] as Pawn;
                                if (pawn3 != null)
                                {
                                    stringBuilder.AppendLine("---");
                                    if (FoodUtility.IsAcceptablePreyFor(pawn2, pawn3))
                                    {
                                        stringBuilder.AppendLine("Prey score: " + FoodUtility.GetPreyScoreFor(pawn2, pawn3));
                                    }
                                    else
                                    {
                                        stringBuilder.AppendLine("Prey score: None");
                                    }
                                    break;
                                }
                            }
                        }
                    }
                }
            }
            return(stringBuilder.ToString());
        }
예제 #3
0
        public void MouseoverReadoutOnGUI()
        {
            if (Event.current.type != EventType.Repaint)
            {
                return;
            }
            if (Find.MainTabsRoot.OpenTab != null)
            {
                return;
            }
            GenUI.DrawTextWinterShadow(new Rect(256f, (float)(UI.screenHeight - 256), -256f, 256f));
            Text.Font = GameFont.Small;
            GUI.color = new Color(1f, 1f, 1f, 0.8f);
            IntVec3 c = UI.MouseCell();

            if (!c.InBounds(Find.VisibleMap))
            {
                return;
            }
            float num = 0f;
            Rect  rect;

            if (c.Fogged(Find.VisibleMap))
            {
                rect = new Rect(MouseoverReadout.BotLeft.x, (float)UI.screenHeight - MouseoverReadout.BotLeft.y - num, 999f, 999f);
                Widgets.Label(rect, "Undiscovered".Translate());
                GUI.color = Color.white;
                return;
            }
            rect = new Rect(MouseoverReadout.BotLeft.x, (float)UI.screenHeight - MouseoverReadout.BotLeft.y - num, 999f, 999f);
            int num2 = Mathf.RoundToInt(Find.VisibleMap.glowGrid.GameGlowAt(c, false) * 100f);

            Widgets.Label(rect, this.glowStrings[num2]);
            num += 19f;
            rect = new Rect(MouseoverReadout.BotLeft.x, (float)UI.screenHeight - MouseoverReadout.BotLeft.y - num, 999f, 999f);
            TerrainDef terrain = c.GetTerrain(Find.VisibleMap);

            if (terrain != this.cachedTerrain)
            {
                string str = ((double)terrain.fertility <= 0.0001) ? string.Empty : (" " + "FertShort".Translate() + " " + terrain.fertility.ToStringPercent());
                this.cachedTerrainString = terrain.LabelCap + ((terrain.passability == Traversability.Impassable) ? null : (" (" + "WalkSpeed".Translate(new object[]
                {
                    this.SpeedPercentString((float)terrain.pathCost)
                }) + str + ")"));
                this.cachedTerrain = terrain;
            }
            Widgets.Label(rect, this.cachedTerrainString);
            num += 19f;
            Zone zone = c.GetZone(Find.VisibleMap);

            if (zone != null)
            {
                rect = new Rect(MouseoverReadout.BotLeft.x, (float)UI.screenHeight - MouseoverReadout.BotLeft.y - num, 999f, 999f);
                string label = zone.label;
                Widgets.Label(rect, label);
                num += 19f;
            }
            float depth = Find.VisibleMap.snowGrid.GetDepth(c);

            if (depth > 0.03f)
            {
                rect = new Rect(MouseoverReadout.BotLeft.x, (float)UI.screenHeight - MouseoverReadout.BotLeft.y - num, 999f, 999f);
                SnowCategory snowCategory = SnowUtility.GetSnowCategory(depth);
                string       label2       = SnowUtility.GetDescription(snowCategory) + " (" + "WalkSpeed".Translate(new object[]
                {
                    this.SpeedPercentString((float)SnowUtility.MovementTicksAddOn(snowCategory))
                }) + ")";
                Widgets.Label(rect, label2);
                num += 19f;
            }
            List <Thing> thingList = c.GetThingList(Find.VisibleMap);

            for (int i = 0; i < thingList.Count; i++)
            {
                Thing thing = thingList[i];
                if (thing.def.category != ThingCategory.Mote)
                {
                    rect = new Rect(MouseoverReadout.BotLeft.x, (float)UI.screenHeight - MouseoverReadout.BotLeft.y - num, 999f, 999f);
                    string labelMouseover = thing.LabelMouseover;
                    Widgets.Label(rect, labelMouseover);
                    num += 19f;
                }
            }
            RoofDef roof = c.GetRoof(Find.VisibleMap);

            if (roof != null)
            {
                rect = new Rect(MouseoverReadout.BotLeft.x, (float)UI.screenHeight - MouseoverReadout.BotLeft.y - num, 999f, 999f);
                Widgets.Label(rect, roof.LabelCap);
                num += 19f;
            }
            GUI.color = Color.white;
        }
예제 #4
0
        private static void DropRoofInCellPhaseOne(IntVec3 c, Map map)
        {
            RoofDef roofDef = map.roofGrid.RoofAt(c);

            if (roofDef == null)
            {
                return;
            }
            if (roofDef.collapseLeavingThingDef != null && roofDef.collapseLeavingThingDef.passability == Traversability.Impassable)
            {
                for (int i = 0; i < 2; i++)
                {
                    List <Thing> thingList = c.GetThingList(map);
                    for (int j = thingList.Count - 1; j >= 0; j--)
                    {
                        Thing thing = thingList[j];
                        map.roofCollapseBuffer.Notify_Crushed(thing);
                        Pawn       pawn = thing as Pawn;
                        DamageInfo dinfo;
                        if (pawn != null)
                        {
                            DamageDef      crush  = DamageDefOf.Crush;
                            int            amount = 99999;
                            BodyPartRecord brain  = pawn.health.hediffSet.GetBrain();
                            dinfo = new DamageInfo(crush, amount, -1f, null, brain, null, DamageInfo.SourceCategory.Collapse);
                        }
                        else
                        {
                            dinfo = new DamageInfo(DamageDefOf.Crush, 99999, -1f, null, null, null, DamageInfo.SourceCategory.Collapse);
                            dinfo.SetBodyRegion(BodyPartHeight.Top, BodyPartDepth.Outside);
                        }
                        BattleLogEntry_DamageTaken battleLogEntry_DamageTaken = null;
                        if (i == 0 && pawn != null)
                        {
                            battleLogEntry_DamageTaken = new BattleLogEntry_DamageTaken(pawn, RulePackDefOf.DamageEvent_Ceiling, null);
                            Find.BattleLog.Add(battleLogEntry_DamageTaken);
                        }
                        thing.TakeDamage(dinfo).InsertIntoLog(battleLogEntry_DamageTaken);
                        if (!thing.Destroyed && thing.def.destroyable)
                        {
                            thing.Destroy(DestroyMode.Vanish);
                        }
                    }
                }
            }
            else
            {
                List <Thing> thingList2 = c.GetThingList(map);
                for (int k = thingList2.Count - 1; k >= 0; k--)
                {
                    Thing thing2 = thingList2[k];
                    if (thing2.def.category == ThingCategory.Item || thing2.def.category == ThingCategory.Plant || thing2.def.category == ThingCategory.Building || thing2.def.category == ThingCategory.Pawn)
                    {
                        map.roofCollapseBuffer.Notify_Crushed(thing2);
                        float num = (float)RoofCollapserImmediate.ThinRoofCrushDamageRange.RandomInRange;
                        if (thing2.def.building != null)
                        {
                            num *= thing2.def.building.roofCollapseDamageMultiplier;
                        }
                        BattleLogEntry_DamageTaken battleLogEntry_DamageTaken2 = null;
                        if (thing2 is Pawn)
                        {
                            battleLogEntry_DamageTaken2 = new BattleLogEntry_DamageTaken(thing2 as Pawn, RulePackDefOf.DamageEvent_Ceiling, null);
                            Find.BattleLog.Add(battleLogEntry_DamageTaken2);
                        }
                        DamageInfo dinfo2 = new DamageInfo(DamageDefOf.Crush, GenMath.RoundRandom(num), -1f, null, null, null, DamageInfo.SourceCategory.Collapse);
                        dinfo2.SetBodyRegion(BodyPartHeight.Top, BodyPartDepth.Outside);
                        thing2.TakeDamage(dinfo2).InsertIntoLog(battleLogEntry_DamageTaken2);
                    }
                }
            }
            if (roofDef.collapseLeavingThingDef != null)
            {
                Thing thing3 = GenSpawn.Spawn(roofDef.collapseLeavingThingDef, c, map);
                if (thing3.def.rotatable)
                {
                    thing3.Rotation = Rot4.Random;
                }
            }
            for (int l = 0; l < 1; l++)
            {
                Vector3 vector = c.ToVector3Shifted();
                vector += Gen.RandomHorizontalVector(0.6f);
                MoteMaker.ThrowDustPuff(vector, map, 2f);
            }
        }
예제 #5
0
 public void MouseoverReadoutOnGUI()
 {
     if (Event.current.type == EventType.Repaint && Find.MainTabsRoot.OpenTab == null)
     {
         GenUI.DrawTextWinterShadow(new Rect(256f, (float)(UI.screenHeight - 256), -256f, 256f));
         Text.Font = GameFont.Small;
         GUI.color = new Color(1f, 1f, 1f, 0.8f);
         IntVec3 c = UI.MouseCell();
         if (c.InBounds(Find.CurrentMap))
         {
             float num  = 0f;
             Rect  rect = default(Rect);
             if (c.Fogged(Find.CurrentMap))
             {
                 Vector2 botLeft  = BotLeft;
                 float   x        = botLeft.x;
                 float   num2     = (float)UI.screenHeight;
                 Vector2 botLeft2 = BotLeft;
                 rect = new Rect(x, num2 - botLeft2.y - num, 999f, 999f);
                 Widgets.Label(rect, "Undiscovered".Translate());
                 GUI.color = Color.white;
             }
             else
             {
                 Vector2 botLeft3 = BotLeft;
                 float   x2       = botLeft3.x;
                 float   num3     = (float)UI.screenHeight;
                 Vector2 botLeft4 = BotLeft;
                 rect = new Rect(x2, num3 - botLeft4.y - num, 999f, 999f);
                 int num4 = Mathf.RoundToInt(Find.CurrentMap.glowGrid.GameGlowAt(c) * 100f);
                 Widgets.Label(rect, glowStrings[num4]);
                 num += 19f;
                 Vector2 botLeft5 = BotLeft;
                 float   x3       = botLeft5.x;
                 float   num5     = (float)UI.screenHeight;
                 Vector2 botLeft6 = BotLeft;
                 rect = new Rect(x3, num5 - botLeft6.y - num, 999f, 999f);
                 TerrainDef terrain = c.GetTerrain(Find.CurrentMap);
                 if (terrain != cachedTerrain)
                 {
                     string str = (!((double)terrain.fertility > 0.0001)) ? string.Empty : (" " + "FertShort".Translate() + " " + terrain.fertility.ToStringPercent());
                     cachedTerrainString = terrain.LabelCap + ((terrain.passability == Traversability.Impassable) ? null : (" (" + "WalkSpeed".Translate(SpeedPercentString((float)terrain.pathCost)) + str + ")"));
                     cachedTerrain       = terrain;
                 }
                 Widgets.Label(rect, cachedTerrainString);
                 num += 19f;
                 Zone zone = c.GetZone(Find.CurrentMap);
                 if (zone != null)
                 {
                     Vector2 botLeft7 = BotLeft;
                     float   x4       = botLeft7.x;
                     float   num6     = (float)UI.screenHeight;
                     Vector2 botLeft8 = BotLeft;
                     rect = new Rect(x4, num6 - botLeft8.y - num, 999f, 999f);
                     string label = zone.label;
                     Widgets.Label(rect, label);
                     num += 19f;
                 }
                 float depth = Find.CurrentMap.snowGrid.GetDepth(c);
                 if (depth > 0.03f)
                 {
                     Vector2 botLeft9  = BotLeft;
                     float   x5        = botLeft9.x;
                     float   num7      = (float)UI.screenHeight;
                     Vector2 botLeft10 = BotLeft;
                     rect = new Rect(x5, num7 - botLeft10.y - num, 999f, 999f);
                     SnowCategory snowCategory = SnowUtility.GetSnowCategory(depth);
                     string       label2       = SnowUtility.GetDescription(snowCategory) + " (" + "WalkSpeed".Translate(SpeedPercentString((float)SnowUtility.MovementTicksAddOn(snowCategory))) + ")";
                     Widgets.Label(rect, label2);
                     num += 19f;
                 }
                 List <Thing> thingList = c.GetThingList(Find.CurrentMap);
                 for (int i = 0; i < thingList.Count; i++)
                 {
                     Thing thing = thingList[i];
                     if (thing.def.category != ThingCategory.Mote)
                     {
                         Vector2 botLeft11 = BotLeft;
                         float   x6        = botLeft11.x;
                         float   num8      = (float)UI.screenHeight;
                         Vector2 botLeft12 = BotLeft;
                         rect = new Rect(x6, num8 - botLeft12.y - num, 999f, 999f);
                         string labelMouseover = thing.LabelMouseover;
                         Widgets.Label(rect, labelMouseover);
                         num += 19f;
                     }
                 }
                 RoofDef roof = c.GetRoof(Find.CurrentMap);
                 if (roof != null)
                 {
                     Vector2 botLeft13 = BotLeft;
                     float   x7        = botLeft13.x;
                     float   num9      = (float)UI.screenHeight;
                     Vector2 botLeft14 = BotLeft;
                     rect = new Rect(x7, num9 - botLeft14.y - num, 999f, 999f);
                     Widgets.Label(rect, roof.LabelCap);
                     num += 19f;
                 }
                 GUI.color = Color.white;
             }
         }
     }
 }