internal void Detonate() { if (_detonated || !_useDetonation) { return; } _detonated = true; bool showBaseEffect = true; if (_detonationSurfaceResponse != null && _currentCollision != null) { RaycastHit raycastHit = RaycastContact(_currentCollision.contacts[0]); SurfaceResponse.ResponseEffect responseEffect = GetResponseEffect(raycastHit, _detonationSurfaceResponse); if (responseEffect != null) { showBaseEffect = !responseEffect.disableBaseEffect; CreateEffect(responseEffect.castable, raycastHit); } } if (showBaseEffect && _detonationCastable != null) { _detonationCastable.SetCaster(_caster); CreateEffect(_detonationCastable, this.transform.position, this.transform.rotation); } Destroy(this.gameObject); }
protected void CreateEffect(Castable castable, Vector3 position, Quaternion rotation) { if (castable == null) { return; } // castable caster and instantiate effect castable.SetCaster(_caster); GameObject newCastableGameObject = Instantiate(castable.gameObject, position, rotation); }