Ejemplo n.º 1
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);
            }
        }
Ejemplo n.º 2
0
        private void PingerController_SetCurrentPing(On.RoR2.PingerController.orig_SetCurrentPing orig, PingerController self, PingerController.PingInfo newPingInfo)
        {
            orig(self, newPingInfo);

            var user = UsersHelper.GetUser(self);
            var item = newPingInfo.targetGameObject?.GetComponent <GenericPickupController>();

            if (item && user)
            {
                watchedPingedItems[user.id] = item.GetInstanceID();
            }
            else if (user)
            {
                watchedPingedItems.Remove(user.id);
            }
        }