//Handles the colliders void OnTriggerEnter2D(Collider2D col) { hm = col.GetComponentInChildren <HealthManager>(); bulletDummyHitInstance.Source = gameObject; //Log("[BulletBehaviour] Name" + hm.gameObject.name); //Array.ForEach<Component>(col.gameObject.GetComponents<Component>(), x => Log(x)); if (col.gameObject.name.Contains("Idle") || hm != null) { HeroController.instance.ResetAirMoves(); HitTaker.Hit(col.gameObject, bulletDummyHitInstance); if (!piercesEnemy) { Destroy(gameObject, 0.03f); } return; } else if (hm == null && col.gameObject.layer.Equals(8)) { StartCoroutine(WallHitDust()); if (col.gameObject.GetComponent <Breakable>() != null) { Breakable br = col.gameObject.GetComponent <Breakable>(); bulletDummyHitInstance.Direction = 270f; br.Hit(bulletDummyHitInstance); } if (playSoundOnSurfaceHit) { AudioHandler.instance.PlayMiscSoundEffect(AudioHandler.HollowPointSoundType.TerrainHitSFXGO); } if (!piercesWalls) { Destroy(gameObject, 0.04f); } } }
//Handles the colliders void OnTriggerEnter2D(Collider2D col) { hm = col.GetComponentInChildren <HealthManager>(); bulletHitInstance.Source = gameObject; //Log(col.name); //PURE VESSEL CHECK if (col.gameObject.name.Contains("Idle")) { //Modding.Logger.Log("PV IS HIT"); if (pureVesselHM != null) { hm = pureVesselHM; } Component[] pvc = col.gameObject.GetComponents <Component>(); foreach (Component c in pvc) { Type type = c.GetType(); //Transform BoxCollider2D DamageHero if (type.Name.Contains("Transform")) { Transform pvt = (Transform)c; Component[] parent_pvt = pvt.GetComponentsInParent(typeof(Component)); foreach (Component cp in parent_pvt) { Type type_2 = cp.GetType(); if (type_2.Name.Contains("HealthManager")) { hm = (HealthManager)cp; pureVesselHM = hm; break; } } } break; } } if (hm == null && col.gameObject.layer.Equals(8)) { StartCoroutine(WallHitDust()); if (col.gameObject.GetComponent <Breakable>() != null) { Breakable br = col.gameObject.GetComponent <Breakable>(); bulletHitInstance.Direction = 270f; br.Hit(bulletHitInstance); } //TODO: change this audio source location LoadAssets.sfxDictionary.TryGetValue("impact_0" + rand.Next(1, 6) + ".wav", out AudioClip ac); //if (gameObject.GetComponent<AudioSource>() == null) Modding.Logger.Log("No Audio Source"); HeroController.instance.GetComponent <AudioSource>().PlayOneShot(ac); //Mark target for fire support if (flareRound) { OffensiveFireSupport_Target(gameObject, null, false); return; } Destroy(gameObject); } //Damages the enemy and destroys the bullet else if (hm != null) { HeroController.instance.ResetAirMoves(); if (flareRound) { OffensiveFireSupport_Target(gameObject, col.gameObject, true); hm.Hit(bulletHitInstance); return; } if (!pierce) { Destroy(gameObject); } hm.Hit(bulletHitInstance); } }