Ejemplo n.º 1
0
        public static void ShowPingIndicators(PingIndicator.orig_Update orig, RoR2.UI.PingIndicator self)
        {
            if (!PingConfiguration.ShowPings.Value)
            {
                foreach (Transform transform in self.transform)
                {
                    transform.gameObject.SetActive(false);
                }

                foreach (var t in self.defaultPingGameObjects)
                {
                    t.SetActive(false);
                }

                foreach (GameObject gameObject in self.defaultPingGameObjects)
                {
                    gameObject.SetActive(false);
                }

                foreach (GameObject gameObject in self.enemyPingGameObjects)
                {
                    gameObject.SetActive(false);
                }

                foreach (GameObject gameObject in self.interactablePingGameObjects)
                {
                    gameObject.SetActive(false);
                }
            }

            orig(self);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Adds text labels for various interactables to a <see cref="PingIndicator"/>
        /// </summary>
        /// <param name="pingIndicator">Target <see cref="PingIndicator"/> that should have the text added</param>
        private static void AddLootText(RoR2.UI.PingIndicator pingIndicator)
        {
            const string         textStart    = "<size=70%>\n";
            string               price        = GetPrice(pingIndicator.pingTarget);
            ShopTerminalBehavior shopTerminal = pingIndicator.pingTarget.GetComponent <ShopTerminalBehavior>();

            if (shopTerminal && _config.ShowShopText.Value)
            {
                string      text        = textStart;
                PickupIndex pickupIndex = shopTerminal.CurrentPickupIndex();
                PickupDef   pickup      = PickupCatalog.GetPickupDef(pickupIndex);
                text += shopTerminal.pickupIndexIsHidden
                    ? "?"
                    : $"{Language.GetString(pickup.nameToken)}";
                pingIndicator.pingText.text += $"{text} ({price})";
                return;
            }

            GenericPickupController pickupController = pingIndicator.pingTarget.GetComponent <GenericPickupController>();

            if (pickupController && _config.ShowPickupText.Value)
            {
                PickupDef pickup = PickupCatalog.GetPickupDef(pickupController.pickupIndex);
                pingIndicator.pingText.text += $"{textStart}{Language.GetString(pickup.nameToken)}";
            }

            ChestBehavior chest = pingIndicator.pingTarget.GetComponent <ChestBehavior>();

            if (chest && _config.ShowChestText.Value)
            {
                pingIndicator.pingText.text += $"{textStart}{Util.GetBestBodyName(pingIndicator.pingTarget)} ({price})";
                return;
            }

            string name = "";

            PurchaseInteraction purchaseInteraction = pingIndicator.pingTarget.GetComponent <PurchaseInteraction>();

            if (purchaseInteraction)
            {
                name = Language.GetString(purchaseInteraction.displayNameToken);
            }

            // Drones
            SummonMasterBehavior summonMaster = pingIndicator.pingTarget.GetComponent <SummonMasterBehavior>();

            if (summonMaster && _config.ShowDroneText.Value)
            {
                pingIndicator.pingText.text += $"{textStart}{name} ({price})";
                return;
            }

            if (_config.ShowShrineText.Value)
            {
                pingIndicator.pingText.text += $"{textStart}{name}";
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Adds name labels for targeted enemies to a <see cref="PingIndicator"/>
        /// </summary>
        /// <param name="pingIndicator">Target <see cref="PingIndicator"/> that should have the text added</param>
        private static void AddEnemyText(RoR2.UI.PingIndicator pingIndicator)
        {
            const string textStart = "<size=70%>\n";
            string       name      = Util.GetBestBodyName(pingIndicator.pingTarget);

            if (_config.ShowEnemyText.Value)
            {
                pingIndicator.pingText.text += $"{textStart}{name}";
            }
        }
Ejemplo n.º 4
0
        public void SetPingText(RoR2.UI.PingIndicator pingIndicator, RoR2.UI.PingIndicator.PingType pingType)
        {
            switch (pingType)
            {
            case RoR2.UI.PingIndicator.PingType.Default:
                break;

            case RoR2.UI.PingIndicator.PingType.Enemy:
                AddEnemyText(pingIndicator);
                break;

            case RoR2.UI.PingIndicator.PingType.Interactable:
                AddLootText(pingIndicator);
                break;
            }
        }
Ejemplo n.º 5
0
        public void Update(On.RoR2.UI.PingIndicator.orig_Update orig, RoR2.UI.PingIndicator self)
        {
            LocalUser localUser = LocalUserManager.GetFirstLocalUser();

            if (localUser != null)
            {
                if (_config.ShowPingDistance.Value && localUser.cachedBody)
                {
                    Vector3 origin = new Vector3(0, 0, 0);
                    origin = localUser.cachedBody.footPosition;

                    float  distance = Vector3.Distance(origin, self.transform.position);
                    int    index    = self.pingText.text.IndexOf((char)0x200B);
                    string sub      = index >= 0 ? self.pingText.text.Substring(0, index) : self.pingText.text;
                    self.pingText.text = sub + (char)0x200B + $" ({distance:0.0}m)";
                }

                if (_config.HideOffscreenPingText.Value)
                {
                    if (!localUser.cameraRigController.sceneCam.IsObjectVisible(self.transform))
                    {
                        self.pingText.alpha = 0;
                    }
                    else
                    {
                        self.pingText.alpha = 1;
                    }
                }
            }

            if (self.pingTarget)
            {
                BarrelInteraction barrelInteraction = self.pingTarget.GetComponent <BarrelInteraction>();
                if (barrelInteraction)
                {
                    if (barrelInteraction.Networkopened)
                    {
                        Object.Destroy(self.gameObject);
                    }
                }
            }

            orig(self);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Sets the ping text and sprite color for a given <see cref="PingIndicator"/>
        /// </summary>
        /// <param name="pingIndicator">Target <see cref="PingIndicator"/></param>
        /// <param name="pingType">Type of the ping</param>
        public void SetPingIndicatorColor(RoR2.UI.PingIndicator pingIndicator, RoR2.UI.PingIndicator.PingType pingType)
        {
            SpriteRenderer sprRenderer = new SpriteRenderer();
            Color          textColor   = Color.black;
            Color          spriteColor = Color.black;

            switch (pingType)
            {
            case RoR2.UI.PingIndicator.PingType.Default:
                sprRenderer = pingIndicator.defaultPingGameObjects[0].GetComponent <SpriteRenderer>();
                textColor   = _colors["DefaultPingColor"];
                spriteColor = _colors["DefaultPingSpriteColor"];
                break;

            case RoR2.UI.PingIndicator.PingType.Enemy:
                sprRenderer = pingIndicator.enemyPingGameObjects[0].GetComponent <SpriteRenderer>();
                textColor   = _colors["EnemyPingColor"];
                spriteColor = _colors["EnemyPingSpriteColor"];
                break;

            case RoR2.UI.PingIndicator.PingType.Interactable:
                sprRenderer = pingIndicator.interactablePingGameObjects[0].GetComponent <SpriteRenderer>();
                if (_tieredInteractablePingColor)
                {
                    Color pickupColor = GetTargetTierColor(pingIndicator.pingTarget);
                    textColor   = pickupColor;
                    spriteColor = pickupColor;
                }
                else
                {
                    textColor   = _colors["InteractablePingColor"];
                    spriteColor = _colors["InteractablePingSpriteColor"];
                }
                break;
            }

            pingIndicator.pingText.color = textColor;
            sprRenderer.color            = spriteColor;
        }
Ejemplo n.º 7
0
 private static void PingIndicatorRebuildPing(On.RoR2.UI.PingIndicator.orig_RebuildPing orig, RoR2.UI.PingIndicator self)
 {
     self.interactablePingDuration = 5 * 60;
     orig(self);
 }
Ejemplo n.º 8
0
 public static void ShowPingHighlights(PingIndicator.orig_Update orig, RoR2.UI.PingIndicator self)
 {
     self.pingHighlight.enabled = PingConfiguration.ShowPingHighlight.Value;
     orig(self);
 }