Beispiel #1
0
		// Token: 0x06002799 RID: 10137 RVA: 0x000B88A8 File Offset: 0x000B6AA8
		public static void _WritePingInfo_PingerController(NetworkWriter writer, PingerController.PingInfo value)
		{
			writer.Write(value.active);
			writer.Write(value.origin);
			writer.Write(value.normal);
			writer.Write(value.targetNetworkIdentity);
		}
Beispiel #2
0
        private static void TelePingCmd(InCmdResult res, InCmdArgs args)
        {
            var ctrl = args.Sender.master.GetComponent <PingerController>();
            var tele = TeleporterInteraction.instance;

            PingerController.PingInfo pingInfo = new PingerController.PingInfo {
                active = true,
                origin = tele.transform.position,
                targetNetworkIdentity = ClientScene.objects[tele.netId],
            };
            typeof(PingerController).GetMethod("SetCurrentPing", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(ctrl, new object[] { pingInfo });
        }
Beispiel #3
0
        private static PingIndicator CreatePingIndicator(PingerController self, PingerController.PingInfo pingInfo, bool neverExpire = true)
        {
            var pingIndicator = ((GameObject)UnityEngine.Object.Instantiate(Resources.Load("Prefabs/PingIndicator"))).GetComponent <PingIndicator>();

            pingIndicator.pingOwner  = self.gameObject;
            pingIndicator.pingOrigin = pingInfo.origin;
            pingIndicator.pingNormal = pingInfo.normal;
            pingIndicator.pingTarget = pingInfo.targetGameObject;
            pingIndicator.RebuildPing();
            // Never expire plz.
            if (neverExpire)
            {
                var field = typeof(PingIndicator).GetField("fixedTimer", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy | System.Reflection.BindingFlags.Instance);
                field.SetValue(pingIndicator, float.MaxValue);
            }
            return(pingIndicator);
        }
Beispiel #4
0
        public void PingHurtBox(HurtBox hurtBox)
        {
            if (this.pinger)
            {
                PingerController.PingInfo pingInfo = new PingerController.PingInfo
                {
                    active = true
                };

                Transform transform = hurtBox.healthComponent.transform;
                pingInfo.origin = transform.position;
                pingInfo.targetNetworkIdentity = hurtBox.healthComponent.GetComponent <NetworkIdentity>();

                Reflection.InvokeMethod(this.pinger, "SetCurrentPing", new object[] {
                    pingInfo
                });
            }
        }
Beispiel #5
0
 private void TogglePing(GameObject body, PingerController self, PingerController.PingInfo pingInfo)
 {
     if (pings.ContainsKey(body) && pings[body])
     {
         UnityEngine.Object.Destroy((UnityEngine.Object)pings[body].gameObject);
         pings.Remove(body);
     }
     else if (pings.ContainsKey(body))
     {
         // If the PI is destroyed somewhere else in the game, it suddenly turns into a null reference? WTF?
         // In this case, the PI is not really visible. Let's remove the old (null) one, and create a new one.
         pings.Remove(body);
         pings.Add(body, CreatePingIndicator(self, pingInfo));
     }
     else
     {
         // Create a new ping indicator.
         pings.Add(body, CreatePingIndicator(self, pingInfo));
     }
 }
        public bool BuildPosOnlyPingInfo(LayerMask layerMask, QueryTriggerInteraction queryInteract, float distanceBonus = 1000f)
        {
            if (!owner.body || !owner.bodyInputs)
            {
                return(false);
            }
            float      rayDist;
            var        aimRay  = CameraRigController.ModifyAimRayIfApplicable(new Ray(owner.bodyInputs.aimOrigin, owner.bodyInputs.aimDirection), owner.body.gameObject, out rayDist);
            float      maxDist = rayDist + distanceBonus;
            RaycastHit raycastHit;

            if (!Util.CharacterRaycast(owner.body.gameObject, aimRay, out raycastHit, maxDist, layerMask, queryInteract))
            {
                return(false);
            }
            lastPingInfo = new PingerController.PingInfo {
                active = true,
                origin = raycastHit.point,
                normal = raycastHit.normal,
                targetNetworkIdentity = null
            };
            return(true);
        }
Beispiel #7
0
        private void PingerController_RebuildPing(On.RoR2.PingerController.orig_RebuildPing orig, PingerController self, PingerController.PingInfo pingInfo)
        {
            Type[] types = { typeof(ShopTerminalBehavior) /* MultiShops */, typeof(ShrineChanceBehavior), typeof(ChestBehavior), typeof(TeleporterInteraction) };
            Type   ty    = null;

            try
            {
                // TODO: Find a FirstOr method...
                ty = types.First((t) => pingInfo.targetGameObject?.GetComponent(t) != null);
            }
            catch (InvalidOperationException e) { /* Do nothing */ }

            if (ty != null)
            {
                TogglePing(pingInfo.targetGameObject?.GetComponent(ty).gameObject, self, pingInfo);
            }
            else
            {
                // TODO: Broken.
                //orig(self, pingInfo);

                // Since calling orig is broken, let's just copy pasta the game's code, with some small adjustments to take into account the fact that there's only a single behavior
                // (instead of one per player)
                if (!this.ownedPings.ContainsKey(self.gameObject))
                {
                    this.ownedPings[self.gameObject] = null;
                }

                if (!pingInfo.active && this.ownedPings[self.gameObject] != null)
                {
                    UnityEngine.Object.Destroy((UnityEngine.Object) this.ownedPings[self.gameObject].gameObject);
                    this.ownedPings[self.gameObject] = (PingIndicator)null;
                }
                else
                {
                    if (!(bool)((UnityEngine.Object) this.ownedPings[self.gameObject]))
                    {
                        this.ownedPings[self.gameObject]           = ((GameObject)UnityEngine.Object.Instantiate(Resources.Load("Prefabs/PingIndicator"))).GetComponent <PingIndicator>();
                        this.ownedPings[self.gameObject].pingOwner = ((Component)self).gameObject;
                    }
                    this.ownedPings[self.gameObject].pingOrigin = pingInfo.origin;
                    this.ownedPings[self.gameObject].pingNormal = pingInfo.normal;
                    this.ownedPings[self.gameObject].pingTarget = pingInfo.targetGameObject;
                    this.ownedPings[self.gameObject].RebuildPing();
                }
            }
        }
Beispiel #8
0
        private void PickupDropletController_CreatePickupDroplet(On.RoR2.PickupDropletController.orig_CreatePickupDroplet orig, PickupIndex pickupIndex, Vector3 position, Vector3 velocity)
        {
            orig(pickupIndex, position, velocity);
            //Check if a lunar coin dropped
            if (pickupIndex != PickupCatalog.FindPickupIndex("LunarCoin.Coin0"))
            {
                return;
            }

            //Send message
            Chat.AddMessage("<color=#307FFF>Lunar Coin</color><style=cEvent> Dropped</style>");

            if (!ShouldPing)
            {
                return;
            }

            //Create a new Ping
            PingerController.PingInfo pingInfo = new PingerController.PingInfo
            {
                active = true
            };

            //Remove old Ping Target
            try
            {
                Destroy(GameObject.Find("FakeLunarCoin"));
            }
            catch
            {
            }

            //Create Ping Target
            //Had weird glitches when I used the real Lunar coin
            GameObject fakeLunarCoin = new GameObject("FakeLunarCoin");

            //Position it to the real Lunar Coin
            fakeLunarCoin.transform.position = position;
            //Add neccesary Component
            fakeLunarCoin.AddComponent <ModelLocator>();

            pingInfo.origin = position;

            //Check if another ping is active
            if (!pingInfo.active && this.pingIndicator != null)
            {
                UnityEngine.Object.Destroy(this.pingIndicator.gameObject);
                this.pingIndicator = null;
                return;
            }
            //Creat new Ping Object
            if (!this.pingIndicator)
            {
                GameObject gameObject = (GameObject)UnityEngine.Object.Instantiate(Resources.Load("Prefabs/PingIndicator"));
                this.pingIndicator           = gameObject.GetComponent <PingIndicator>();
                this.pingIndicator.pingOwner = base.gameObject;
            }
            //Set some stuff
            this.pingIndicator.pingOrigin = pingInfo.origin;
            this.pingIndicator.pingNormal = pingInfo.normal;
            this.pingIndicator.pingTarget = fakeLunarCoin;
            this.pingIndicator.pingOwner  = LocalUserManager.GetFirstLocalUser().cachedMasterObject;
            this.pingIndicator.RebuildPing();

            //Clear old Coroutine
            //Dont wanna have it removed because of the old one
            try
            {
                StopCoroutine(clearCoroutine);
            }
            catch (System.Exception)
            {
                Debug.Log("No Coroutine Running!");
            }
            clearCoroutine = StartCoroutine(ClearPing());
        }
Beispiel #9
0
        private void PickupDropletController_CreatePickupDroplet(On.RoR2.PickupDropletController.orig_CreatePickupDroplet orig, PickupIndex pickupIndex, Vector3 position, Vector3 velocity)
        {
            orig.Invoke(pickupIndex, position, velocity);
            //Check if a lunar coin dropped
            if (pickupIndex != PickupIndex.lunarCoin1)
            {
                return;
            }

            //Send message
            Chat.AddMessage("<color=#307FFF>Lunar Coin</color><style=cEvent> Dropped</style>");

            if (!shouldPing)
            {
                return;
            }

            //Create a new Ping
            PingerController.PingInfo pingInfo = new PingerController.PingInfo
            {
                active = true
            };

            //Remove old Ping Target
            try
            {
                Destroy(GameObject.Find("FakeLunarCoin"));
            }
            catch (System.Exception)
            {
            }

            //Create Ping Target
            //Had weird glitches when I used the real Lunar coin
            GameObject fakeLunarCoin = new GameObject("FakeLunarCoin");

            #region OLD

            /*try
             * {
             *  //<style=cIsHealing>💝 Der Felix 💝 wants to move here.</style>
             *  if(GameObject.Find("PickupLunarCoin") != null)
             *  {
             *      fakeLunarCoin = GameObject.Find("PickupLunarCoin");
             *      if (fakeLunarCoin.GetComponentInParent<IDisplayNameProvider>() != null)
             *          Chat.AddMessage("1 Not Null");
             *      else
             *          Chat.AddMessage("1 Null");
             *
             *      if (fakeLunarCoin.GetComponent<IDisplayNameProvider>() != null)
             *          Chat.AddMessage("2 Not Null");
             *      else
             *          Chat.AddMessage("2 Null");
             *
             *      if (fakeLunarCoin.GetComponentInChildren<IDisplayNameProvider>() != null)
             *          Chat.AddMessage("3 Not Null");
             *      else
             *          Chat.AddMessage("3 Null");
             *  }
             *
             * }
             * catch (System.Exception)
             * {
             *
             *  Chat.AddMessage("Not Found!");
             * }*/
            #endregion

            //Position it to the real Lunar Coin
            fakeLunarCoin.transform.position = position;
            //Add neccesary Component
            fakeLunarCoin.AddComponent <ModelLocator>();

            pingInfo.origin = position;

            //Check if another ping is active
            if (!pingInfo.active && this.pingIndicator != null)
            {
                UnityEngine.Object.Destroy(this.pingIndicator.gameObject);
                this.pingIndicator = null;
                return;
            }
            //Creat new Ping Object
            if (!this.pingIndicator)
            {
                GameObject gameObject = (GameObject)UnityEngine.Object.Instantiate(Resources.Load("Prefabs/PingIndicator"));
                this.pingIndicator           = gameObject.GetComponent <PingIndicator>();
                this.pingIndicator.pingOwner = base.gameObject;
            }
            //Set some stuff
            this.pingIndicator.pingOrigin = pingInfo.origin;
            this.pingIndicator.pingNormal = pingInfo.normal;
            this.pingIndicator.pingTarget = fakeLunarCoin;
            this.pingIndicator.pingOwner  = LocalUserManager.GetFirstLocalUser().cachedMasterObject;
            this.pingIndicator.RebuildPing();

            //Clear old Coroutine
            //Dont wanna have it removed because of the old one
            try
            {
                StopCoroutine(clearCoroutine);
            }
            catch (System.Exception)
            {
                Debug.Log("No Coroutine Running!");
            }
            clearCoroutine = StartCoroutine(ClearPing());
        }
Beispiel #10
0
 private void On_CmdPing(On.RoR2.PingerController.orig_CmdPing orig, PingerController self, PingerController.PingInfo incomingPing)
 {
     orig(self, incomingPing);
     FrogtownShared.SendChat(string.Format("Origin: {0}", FormatVector3String(incomingPing.origin)));
     FrogtownShared.SendChat(string.Format("Normal: {0}", FormatVector3String(incomingPing.normal)));
 }
Beispiel #11
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);
            }
        }