IEnumerator ClearPing() { yield return(new WaitForSeconds(PingDuration)); try { UnityEngine.Object.Destroy(this.pingIndicator.gameObject); this.pingIndicator = null; } catch (System.Exception) { Debug.Log("Gameobject not found. Problaby already destroyed!"); throw; } }
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()); }
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()); }