public static void DoImpact(GameObject go, SurfaceInfoObject.ImpactType type, Vector3 worldPos, Quaternion rotation) { SurfaceInfoObject surfaceInfoFor = SurfaceInfo.GetSurfaceInfoFor(go, worldPos); UnityEngine.Object obj = UnityEngine.Object.Instantiate(surfaceInfoFor.GetImpactEffect(type), worldPos, rotation); UnityEngine.Object.Destroy(obj, 1f); }
private void Update() { if (!this.impacted) { float num = Time.time - this.lastUpdateTime; this.lastUpdateTime = Time.time; RaycastHit hit = new RaycastHit(); RaycastHit2 invalid = RaycastHit2.invalid; base.transform.Rotate(Vector3.right, (float)(this.dropDegreesPerSec * num)); Ray ray = new Ray(base.transform.position, base.transform.forward); float num2 = this.speedPerSec * num; bool flag = true; if (!Physics2.Raycast2(ray, out invalid, this.speedPerSec * num, this.layerMask)) { Transform transform = base.transform; transform.position += (Vector3)((base.transform.forward * this.speedPerSec) * num); this.distance += this.speedPerSec * num; } else { Vector3 point; Vector3 normal; GameObject gameObject; Rigidbody rigidbody; if (flag) { normal = invalid.normal; point = invalid.point; gameObject = invalid.gameObject; rigidbody = invalid.rigidbody; } else { normal = hit.normal; point = hit.point; gameObject = hit.collider.gameObject; rigidbody = hit.rigidbody; } Quaternion rotation = Quaternion.LookRotation(normal); Vector3 zero = Vector3.zero; int layer = gameObject.layer; bool flag2 = true; if (((rigidbody != null) && !rigidbody.isKinematic) && !rigidbody.CompareTag("Door")) { rigidbody.AddForceAtPosition((Vector3)(Vector3.up * 200f), point); rigidbody.AddForceAtPosition((Vector3)(ray.direction * 1000f), point); } switch (layer) { case 0x11: case 0x12: case 0x1b: case 0x15: flag2 = false; break; default: zero = point + ((Vector3)(normal * 0.01f)); break; } this.impacted = true; base.transform.position = point; this.TryReportHit(gameObject); base.transform.parent = gameObject.transform; TrailRenderer component = base.GetComponent <TrailRenderer>(); if (component != null) { component.enabled = false; } base.audio.enabled = false; if (gameObject != null) { SurfaceInfoObject surfaceInfoFor = SurfaceInfo.GetSurfaceInfoFor(gameObject, point); surfaceInfoFor.GetImpactEffect(SurfaceInfoObject.ImpactType.Bullet); Object.Destroy(Object.Instantiate(surfaceInfoFor.GetImpactEffect(SurfaceInfoObject.ImpactType.Bullet), point, rotation), 1.5f); this.TryReportMiss(); } Object.Destroy(base.gameObject, 20f); } if ((this.distance > this.maxRange) || ((Time.time - this.spawnTime) > this.maxLifeTime)) { Object.Destroy(base.gameObject); } } }
private void Update() { Vector3 vector3; Vector3 vector31; GameObject gameObject; Rigidbody rigidbody; if (this.impacted) { return; } float single = Time.time - this.lastUpdateTime; this.lastUpdateTime = Time.time; RaycastHit raycastHit = new RaycastHit(); RaycastHit2 raycastHit2 = RaycastHit2.invalid; base.transform.Rotate(Vector3.right, this.dropDegreesPerSec * single); Ray ray = new Ray(base.transform.position, base.transform.forward); bool flag = true; if (!Physics2.Raycast2(ray, out raycastHit2, this.speedPerSec * single, this.layerMask)) { Transform transforms = base.transform; transforms.position = transforms.position + ((base.transform.forward * this.speedPerSec) * single); ArrowMovement arrowMovement = this; arrowMovement.distance = arrowMovement.distance + this.speedPerSec * single; } else { if (!flag) { vector31 = raycastHit.normal; vector3 = raycastHit.point; gameObject = raycastHit.collider.gameObject; rigidbody = raycastHit.rigidbody; } else { vector31 = raycastHit2.normal; vector3 = raycastHit2.point; gameObject = raycastHit2.gameObject; rigidbody = raycastHit2.rigidbody; } Quaternion quaternion = Quaternion.LookRotation(vector31); Vector3 vector32 = Vector3.zero; int num = gameObject.layer; bool flag1 = true; if (rigidbody && !rigidbody.isKinematic && !rigidbody.CompareTag("Door")) { rigidbody.AddForceAtPosition(Vector3.up * 200f, vector3); rigidbody.AddForceAtPosition(ray.direction * 1000f, vector3); } if (num == 17 || num == 18 || num == 27 || num == 21) { flag1 = false; } else { vector32 = vector3 + (vector31 * 0.01f); } this.impacted = true; base.transform.position = vector3; this.TryReportHit(gameObject); base.transform.parent = gameObject.transform; TrailRenderer component = base.GetComponent <TrailRenderer>(); if (component) { component.enabled = false; } base.audio.enabled = false; if (gameObject) { SurfaceInfoObject surfaceInfoFor = SurfaceInfo.GetSurfaceInfoFor(gameObject, vector3); surfaceInfoFor.GetImpactEffect(SurfaceInfoObject.ImpactType.Bullet); UnityEngine.Object obj = UnityEngine.Object.Instantiate(surfaceInfoFor.GetImpactEffect(SurfaceInfoObject.ImpactType.Bullet), vector3, quaternion); UnityEngine.Object.Destroy(obj, 1.5f); this.TryReportMiss(); } UnityEngine.Object.Destroy(base.gameObject, 20f); } if (this.distance > this.maxRange || Time.time - this.spawnTime > this.maxLifeTime) { UnityEngine.Object.Destroy(base.gameObject); } }