Exemple #1
0
        /// <summary>
        /// Sets the ping text and sprite color for a given <see cref="PingIndicator"/>
        /// </summary>
        /// <param name="pingIndicator">Target <see cref="PingIndicator"/></param>
        private void SetPingIndicatorColor(RoR2.UI.PingIndicator pingIndicator)
        {
            SpriteRenderer sprRenderer;
            Color          textColor = new Color(0, 0, 0, 0);

            RoR2.UI.PingIndicator.PingType pingType =
                pingIndicator.GetObjectValue <RoR2.UI.PingIndicator.PingType>("pingType");

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

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

            case RoR2.UI.PingIndicator.PingType.Interactable:
                textColor         = _colors["InteractiblePingColor"];
                sprRenderer       = pingIndicator.interactablePingGameObjects[0].GetComponent <SpriteRenderer>();
                sprRenderer.color = _colors["InteractiblePingSpriteColor"];
                break;
            }

            pingIndicator.pingText.color = textColor;
        }
Exemple #2
0
        /// <summary>
        /// Override method for RoR2.PingerController.SetCurrentPing
        /// </summary>
        public void SetCurrentPing(On.RoR2.PingerController.orig_SetCurrentPing orig,
                                   RoR2.PingerController self, RoR2.PingerController.PingInfo newPingInfo)
        {
            // For some reason, if you ping somewhere that is not pingable, it will create a
            // Ping at 0,0,0. If that happens, we just leave, since that isn't possible in the
            // regular game either, or if so, not at exactly those coordinates
            if (newPingInfo.origin == Vector3.zero)
            {
                return;
            }

            // If the targeted game object already has a ping, don't do anything
            // This is here to avoid stacking of different player pings on interactables
            if (newPingInfo.targetGameObject != null &&
                _pingIndicators.Any(indicator => indicator && indicator.pingTarget == newPingInfo.targetGameObject))
            {
                return;
            }

            self.NetworkcurrentPing = newPingInfo;

            // Here we create an instance of PingIndicator
            // since we're not jumping into PingerController.RebuildPing() to create one.
            GameObject go = (GameObject)Object.Instantiate(Resources.Load("Prefabs/PingIndicator"));

            RoR2.UI.PingIndicator pingIndicator = go.GetComponent <RoR2.UI.PingIndicator>();

            pingIndicator.pingOwner  = self.gameObject;
            pingIndicator.pingOrigin = newPingInfo.origin;
            pingIndicator.pingNormal = newPingInfo.normal;
            pingIndicator.pingTarget = newPingInfo.targetGameObject;

            pingIndicator.RebuildPing();

            RoR2.UI.PingIndicator.PingType pingType =
                pingIndicator.GetObjectValue <RoR2.UI.PingIndicator.PingType>("pingType");

            _painter.SetPingIndicatorColor(pingIndicator, pingType);
            _textBuilder.SetPingText(pingIndicator, pingType);
            SetPingTimer(pingIndicator, pingType);

            if (pingType == RoR2.UI.PingIndicator.PingType.Interactable)
            {
                _notificationBuilder.SetUnlockedItemNotification(pingIndicator);
            }

            // We add the ping indicator to our own local list
            _pingIndicators.Add(pingIndicator);

            if (self.hasAuthority)
            {
                self.CallCmdPing(self.currentPing);
            }
        }
        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;
            }
        }
Exemple #4
0
        private void SetPingTimer(RoR2.UI.PingIndicator pingIndicator, RoR2.UI.PingIndicator.PingType pingType)
        {
            float fixedTimer = 0f;

            switch (pingType)
            {
            case RoR2.UI.PingIndicator.PingType.Default:
                fixedTimer = _config.DefaultPingLifetime.Value;
                break;

            case RoR2.UI.PingIndicator.PingType.Enemy:
                fixedTimer = _config.EnemyPingLifetime.Value;
                break;

            case RoR2.UI.PingIndicator.PingType.Interactable:
                fixedTimer = _config.InteractablePingLifetime.Value;
                break;
            }

            pingIndicator.SetObjectValue("fixedTimer", fixedTimer);
        }
Exemple #5
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;
        }