Пример #1
0
        public static bool MouseoverReadoutOnGUI_Prefix(MouseoverReadout __instance)
        {
            if (Event.current.type != EventType.Repaint)
            {
                return(true);
            }
            if (Find.MainTabsRoot.OpenTab != null)
            {
                return(true);
            }
            IntVec3 c = UI.MouseCell();

            if (!c.InBounds(Find.VisibleMap))
            {
                return(true);
            }

            MapComponentSeenFog seenFog = Find.VisibleMap.getMapComponentSeenFog();

            if (!c.Fogged(Find.VisibleMap) && (seenFog != null && !seenFog.knownCells[Find.VisibleMap.cellIndices.CellToIndex(c)]))
            {
                GenUI.DrawTextWinterShadow(new Rect(256f, (float)(UI.screenHeight - 256), -256f, 256f));
                Text.Font = GameFont.Small;
                GUI.color = new Color(1f, 1f, 1f, 0.8f);

                Rect rect = new Rect(_MouseoverReadout.BotLeft.x, (float)UI.screenHeight - _MouseoverReadout.BotLeft.y, 999f, 999f);
                Widgets.Label(rect, "NotVisible".Translate());
                GUI.color = Color.white;
                return(false);
            }

            return(true);
        }
        public static bool MouseoverReadoutOnGUI(MouseoverReadout __instance)
        {
            IntVec3 c = UI.MouseCell();

            if (!c.InBounds(Find.CurrentMap) ||
                Event.current.type != EventType.Repaint ||
                Find.MainTabsRoot.OpenTab != null)
            {
                return(false);
            }

            if (Find.CurrentMap.GetComponent <MapComponent_FertilityMods>().Get is MapComponent_FertilityMods fert &&
                fert.ActiveCells.Contains(c))
            {
                //Original Variables
                Vector2 BotLeft = new Vector2(15f, 65f);

                GenUI.DrawTextWinterShadow(new Rect(256f, (float)(UI.screenHeight - 256), -256f, 256f));
                Text.Font = GameFont.Small;
                GUI.color = new Color(1f, 1f, 1f, 0.8f);

                float num = 0f;
                Rect  rect;
                if (c.Fogged(Find.CurrentMap))
                {
                    rect = new Rect(BotLeft.x, (float)UI.screenHeight - BotLeft.y - num, 999f, 999f);
                    Widgets.Label(rect, "Undiscovered".Translate());
                    GUI.color = Color.white;
                    return(false);
                }
                rect = new Rect(BotLeft.x, (float)UI.screenHeight - BotLeft.y - num, 999f, 999f);
                int      num2        = Mathf.RoundToInt(Find.CurrentMap.glowGrid.GameGlowAt(c) * 100f);
                string[] glowStrings = Traverse.Create(__instance).Field("glowStrings").GetValue <string[]>();
                Widgets.Label(rect, glowStrings[num2]);
                num += 19f;
                rect = new Rect(BotLeft.x, (float)UI.screenHeight - BotLeft.y - num, 999f, 999f);
                TerrainDef terrain = c.GetTerrain(Find.CurrentMap);
                //string SpeedPercentString = Traverse.Create(__instance).Method("SpeedPercentString", (float)terrain.pathCost).GetValue<string>();
                //TerrainDef cachedTerrain = Traverse.Create(__instance).Field("cachedTerrain").GetValue<TerrainDef>();
                string cachedTerrainString =
                    Traverse.Create(__instance).Field("cachedTerrainString").GetValue <string>();

                //if (terrain != cachedTerrain)
                //{
                float  fertNum = Find.CurrentMap.fertilityGrid.FertilityAt(c);
                string str     = ((double)fertNum <= 0.0001)
                    ? string.Empty
                    : (" " + "FertShort".Translate() + " " + fertNum.ToStringPercent());
                cachedTerrainString = terrain.LabelCap + ((terrain.passability == Traversability.Impassable)
                                          ? null
                                          : (" (" + "WalkSpeed".Translate(new object[]
                {
                    SpeedPercentString((float)terrain.pathCost)
                }) + str + ")"));
                //cachedTerrain = terrain;
                //}
                Widgets.Label(rect, cachedTerrainString);
                num += 19f;
                Zone zone = c.GetZone(Find.CurrentMap);
                if (zone != null)
                {
                    rect = new Rect(BotLeft.x, (float)UI.screenHeight - BotLeft.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)
                {
                    rect = new Rect(BotLeft.x, (float)UI.screenHeight - BotLeft.y - num, 999f, 999f);
                    SnowCategory snowCategory = SnowUtility.GetSnowCategory(depth);
                    string       label2       = SnowUtility.GetDescription(snowCategory) + " (" + "WalkSpeed".Translate(new object[]
                    {
                        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)
                    {
                        rect = new Rect(BotLeft.x, (float)UI.screenHeight - BotLeft.y - num, 999f, 999f);
                        string labelMouseover = thing.LabelMouseover;
                        Widgets.Label(rect, labelMouseover);
                        num += 19f;
                    }
                }
                RoofDef roof = c.GetRoof(Find.CurrentMap);
                if (roof != null)
                {
                    rect = new Rect(BotLeft.x, (float)UI.screenHeight - BotLeft.y - num, 999f, 999f);
                    Widgets.Label(rect, roof.LabelCap);
                    num += 19f;
                }
                GUI.color = Color.white;
                return(false);
            }
            return(true);
        }