private void Update() { for (int i = 0; i < colliders.Count; i++) { Collider collider = colliders[i]; if (collider == null) { colliders.RemoveAt(i); i--; continue; } Vector3 direction = Vector3.up; if (capsCollider.direction == 0) { direction = Vector3.right; } else if (capsCollider.direction == 2) { direction = Vector3.forward; } direction = base.transform.TransformDirection(direction); float num = capsCollider.height; float radius = capsCollider.radius; if (num < radius * 2f) { num = radius * 2f; } Vector3 a = base.transform.TransformPoint(capsCollider.center); Vector3 vector = a - direction * (num * 0.5f); Vector3 vector2 = vector + direction * Mathf.Max(0f, num - radius); Vector3 position = collider.transform.position; Vector3 vector3 = position - vector; float magnitude = Vector3.Cross(direction, vector3).magnitude; float num2 = Vector3.Dot(Vector3.Project(vector3 + vector, direction) - vector2, direction); float num3 = 0f; if (num2 > 0f) { Debug.DrawLine(position, vector2, Color.yellow); num3 = (position - vector2).magnitude / radius; } else { Debug.DrawLine(position, vector, Color.yellow); num3 = magnitude / radius; } num3 = Mathf.Clamp01(1f - num3) * Magnitude; Vector3 vector4 = direction * num3; Rigidbody attachedRigidbody = collider.attachedRigidbody; if (attachedRigidbody != null) { attachedRigidbody.AddForce(vector4, ForceMode.Impulse); continue; } LocomotionController currentController = LocomotionHelper.GetCurrentController(collider.gameObject); if (currentController != null && (!IgnoreIfRunController || !(currentController is RunController))) { currentController.AddForce(vector4, base.gameObject); } } }
private void Update() { for (int i = 0; i < colliders.Count; i++) { Collider collider = colliders[i]; Vector3 vector = collider.transform.position - base.transform.position; float magnitude = vector.magnitude; float num = Magnitude; if (MaxDist > 0f) { num = Mathf.Clamp01(1f - magnitude / MaxDist) * Magnitude; } Vector3 vector2 = vector.normalized * num; Rigidbody attachedRigidbody = collider.attachedRigidbody; if (attachedRigidbody != null) { attachedRigidbody.AddForce(vector2, ForceMode.Impulse); continue; } LocomotionController currentController = LocomotionHelper.GetCurrentController(collider.gameObject); if (currentController != null && (!IgnoreIfRunController || !(currentController is RunController))) { currentController.AddForce(vector2, base.gameObject); } } }
private void applyImpulse(Collider collider) { Vector3 vector = ((ZDirection != null) ? (ZDirection.forward * Magnitude) : (base.transform.forward * Magnitude)); LocomotionController locomotionController = LocomotionHelper.GetCurrentController(collider.gameObject); if (collider.gameObject.layer == LayerMask.NameToLayer(LayerConstants.TubeLayer)) { SlideControllerListener component = collider.GetComponent <SlideControllerListener>(); if (component != null) { locomotionController = component.SlideController; } } if (locomotionController != null) { if (!IgnoreIfRunController || !(locomotionController is RunController)) { if (Behaviour == ImpulseType.AddVelocity) { locomotionController.AddForce(vector * Time.fixedDeltaTime, base.gameObject); } else { locomotionController.SetForce(vector, base.gameObject); } } return; } Rigidbody attachedRigidbody = collider.attachedRigidbody; if (attachedRigidbody != null) { if (Behaviour == ImpulseType.SnapVelocity) { attachedRigidbody.velocity = vector; } else { attachedRigidbody.AddForce(vector, ForceMode.VelocityChange); } } }