Пример #1
0
            /// <summary>
            /// Applied before LateUpdate runs.
            /// </summary>
            internal static bool Prefix(InterfaceTool __instance)
            {
                int cell;

                if (!__instance.populateHitsList)
                {
                    __instance.UpdateHoverElements(null);
                }
                else if (__instance.isAppFocused && Grid.IsValidCell(cell = GetMousePosition(
                                                                         out Vector3 coords)))
                {
                    bool soundPlayed = false;
                    // The game uses different math to arrive at the same answer in two ways...
                    var hits          = __instance.hits;
                    var hoverOverride = __instance.hoverOverride;
                    hits.Clear();
                    if (hoverOverride != null)
                    {
                        hits.Add(hoverOverride);
                    }
                    // If the items have changed, reset cycle count
                    if (GetAllSelectables(cell, coords, __instance.prevIntersectionGroup,
                                          hits))
                    {
                        __instance.hitCycleCount = 0;
                    }
                    var objectUnderCursor = GetFirstSelectable(hits, __instance.layerMask);
                    __instance.UpdateHoverElements(hits);
                    if (!__instance.hasFocus && hoverOverride == null)
                    {
                        ClearHover(__instance);
                    }
                    else if (objectUnderCursor != __instance.hover)
                    {
                        SetHover(__instance, objectUnderCursor);
                        if (objectUnderCursor != null)
                        {
                            Game.Instance.Trigger((int)GameHashes.HighlightStatusItem,
                                                  objectUnderCursor.gameObject);
                            objectUnderCursor.Hover(!__instance.playedSoundThisFrame);
                            // This store was dead in the base game, but the intent is
                            // obviously to avoid playing more than one sound per frame...
                            soundPlayed = true;
                        }
                    }
                    __instance.playedSoundThisFrame = soundPlayed;
                }
                // Stop the slow original method from running
                return(false);
            }