private void LateUpdate() { if (this.target && this.targetFocus) { if (!this.lastLMBState && Input.GetMouseButton(0)) { this.DraggingObject = false; if (this.surfaceColliders != null) { RaycastHit raycastHit = default(RaycastHit); Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); foreach (Collider collider in this.surfaceColliders) { if (collider.Raycast(ray, out raycastHit, float.PositiveInfinity)) { this.DraggingObject = true; break; } } } } else if (this.lastLMBState && !Input.GetMouseButton(0)) { this.DraggingObject = false; } this.lastLMBState = Input.GetMouseButton(0); if (this.DraggingObject) { if (Input.GetMouseButton(0) && !this.disableSteering) { this.req_ObjxSpeed += (Input.GetAxis("Mouse X") * this.xObjSpeed * 0.02f - this.req_ObjxSpeed) * Time.deltaTime * 10f; this.req_ObjySpeed += (Input.GetAxis("Mouse Y") * this.yObjSpeed * 0.02f - this.req_ObjySpeed) * Time.deltaTime * 10f; } else { this.req_ObjxSpeed += (0f - this.req_ObjxSpeed) * Time.deltaTime * 4f; this.req_ObjySpeed += (0f - this.req_ObjySpeed) * Time.deltaTime * 4f; } this.req_xSpeed += (0f - this.req_xSpeed) * Time.deltaTime * 4f; this.req_ySpeed += (0f - this.req_ySpeed) * Time.deltaTime * 4f; } else { if (Input.GetMouseButton(0) && !this.disableSteering) { this.req_xSpeed += (Input.GetAxis("Mouse X") * this.xSpeed * 0.02f - this.req_xSpeed) * Time.deltaTime * 10f; this.req_ySpeed += (Input.GetAxis("Mouse Y") * this.ySpeed * 0.02f - this.req_ySpeed) * Time.deltaTime * 10f; } else { this.req_xSpeed += (0f - this.req_xSpeed) * Time.deltaTime * 4f; this.req_ySpeed += (0f - this.req_ySpeed) * Time.deltaTime * 4f; } this.req_ObjxSpeed += (0f - this.req_ObjxSpeed) * Time.deltaTime * 4f; this.req_ObjySpeed += (0f - this.req_ObjySpeed) * Time.deltaTime * 4f; } this.distance -= Input.GetAxis("Mouse ScrollWheel") * this.ZoomWheelSpeed; this.distance = Mathf.Clamp(this.distance, this.minDistance, this.maxDistance); this.cur_ObjxSpeed += (this.req_ObjxSpeed - this.cur_ObjxSpeed) * Time.deltaTime * 20f; this.cur_ObjySpeed += (this.req_ObjySpeed - this.cur_ObjySpeed) * Time.deltaTime * 20f; this.target.transform.RotateAround(this.targetFocus.position, Vector3.Cross(this.targetFocus.position - base.transform.position, base.transform.right), -this.cur_ObjxSpeed); this.target.transform.RotateAround(this.targetFocus.position, Vector3.Cross(this.targetFocus.position - base.transform.position, base.transform.up), -this.cur_ObjySpeed); this.cur_xSpeed += (this.req_xSpeed - this.cur_xSpeed) * Time.deltaTime * 20f; this.cur_ySpeed += (this.req_ySpeed - this.cur_ySpeed) * Time.deltaTime * 20f; this.x += this.cur_xSpeed; this.y -= this.cur_ySpeed; this.y = UBER_MouseOrbit_DynamicDistance.ClampAngle(this.y, this.yMinLimit + this.normal_angle, this.yMaxLimit + this.normal_angle); if (this.surfaceColliders != null) { RaycastHit raycastHit2 = default(RaycastHit); Vector3 vector = Vector3.Normalize(this.targetFocus.position - base.transform.position); float num = 0.01f; bool flag = false; foreach (Collider collider2 in this.surfaceColliders) { if (collider2.Raycast(new Ray(base.transform.position - vector * this.bounds_MaxSize, vector), out raycastHit2, float.PositiveInfinity)) { num = Mathf.Max(Vector3.Distance(raycastHit2.point, this.targetFocus.position) + this.distance, num); flag = true; } } if (flag) { this.cur_distance += (num - this.cur_distance) * Time.deltaTime * 4f; } } Quaternion rotation = Quaternion.Euler(this.y, this.x, 0f); Vector3 position = rotation * new Vector3(0f, 0f, -this.cur_distance) + this.targetFocus.position; base.transform.rotation = rotation; base.transform.position = position; } }
private void LateUpdate() { if (!Object.op_Implicit((Object)this.target) || !Object.op_Implicit((Object)this.targetFocus)) { return; } if (!this.lastLMBState && Input.GetMouseButton(0)) { this.DraggingObject = false; if (this.surfaceColliders != null) { RaycastHit raycastHit = (RaycastHit)null; Ray ray = Camera.get_main().ScreenPointToRay(Input.get_mousePosition()); foreach (Collider surfaceCollider in this.surfaceColliders) { if (surfaceCollider.Raycast(ray, ref raycastHit, float.PositiveInfinity)) { this.DraggingObject = true; break; } } } } else if (this.lastLMBState && !Input.GetMouseButton(0)) { this.DraggingObject = false; } this.lastLMBState = Input.GetMouseButton(0); if (this.DraggingObject) { if (Input.GetMouseButton(0) && !this.disableSteering) { this.req_ObjxSpeed += (float)(((double)Input.GetAxis("Mouse X") * (double)this.xObjSpeed * 0.0199999995529652 - (double)this.req_ObjxSpeed) * (double)Time.get_deltaTime() * 10.0); this.req_ObjySpeed += (float)(((double)Input.GetAxis("Mouse Y") * (double)this.yObjSpeed * 0.0199999995529652 - (double)this.req_ObjySpeed) * (double)Time.get_deltaTime() * 10.0); } else { this.req_ObjxSpeed += (float)((0.0 - (double)this.req_ObjxSpeed) * (double)Time.get_deltaTime() * 4.0); this.req_ObjySpeed += (float)((0.0 - (double)this.req_ObjySpeed) * (double)Time.get_deltaTime() * 4.0); } this.req_xSpeed += (float)((0.0 - (double)this.req_xSpeed) * (double)Time.get_deltaTime() * 4.0); this.req_ySpeed += (float)((0.0 - (double)this.req_ySpeed) * (double)Time.get_deltaTime() * 4.0); } else { if (Input.GetMouseButton(0) && !this.disableSteering) { this.req_xSpeed += (float)(((double)Input.GetAxis("Mouse X") * (double)this.xSpeed * 0.0199999995529652 - (double)this.req_xSpeed) * (double)Time.get_deltaTime() * 10.0); this.req_ySpeed += (float)(((double)Input.GetAxis("Mouse Y") * (double)this.ySpeed * 0.0199999995529652 - (double)this.req_ySpeed) * (double)Time.get_deltaTime() * 10.0); } else { this.req_xSpeed += (float)((0.0 - (double)this.req_xSpeed) * (double)Time.get_deltaTime() * 4.0); this.req_ySpeed += (float)((0.0 - (double)this.req_ySpeed) * (double)Time.get_deltaTime() * 4.0); } this.req_ObjxSpeed += (float)((0.0 - (double)this.req_ObjxSpeed) * (double)Time.get_deltaTime() * 4.0); this.req_ObjySpeed += (float)((0.0 - (double)this.req_ObjySpeed) * (double)Time.get_deltaTime() * 4.0); } this.distance -= Input.GetAxis("Mouse ScrollWheel") * this.ZoomWheelSpeed; this.distance = Mathf.Clamp(this.distance, this.minDistance, this.maxDistance); this.cur_ObjxSpeed += (float)(((double)this.req_ObjxSpeed - (double)this.cur_ObjxSpeed) * (double)Time.get_deltaTime() * 20.0); this.cur_ObjySpeed += (float)(((double)this.req_ObjySpeed - (double)this.cur_ObjySpeed) * (double)Time.get_deltaTime() * 20.0); this.target.get_transform().RotateAround(this.targetFocus.get_position(), Vector3.Cross(Vector3.op_Subtraction(this.targetFocus.get_position(), ((Component)this).get_transform().get_position()), ((Component)this).get_transform().get_right()), -this.cur_ObjxSpeed); this.target.get_transform().RotateAround(this.targetFocus.get_position(), Vector3.Cross(Vector3.op_Subtraction(this.targetFocus.get_position(), ((Component)this).get_transform().get_position()), ((Component)this).get_transform().get_up()), -this.cur_ObjySpeed); this.cur_xSpeed += (float)(((double)this.req_xSpeed - (double)this.cur_xSpeed) * (double)Time.get_deltaTime() * 20.0); this.cur_ySpeed += (float)(((double)this.req_ySpeed - (double)this.cur_ySpeed) * (double)Time.get_deltaTime() * 20.0); this.x += this.cur_xSpeed; this.y -= this.cur_ySpeed; this.y = UBER_MouseOrbit_DynamicDistance.ClampAngle(this.y, this.yMinLimit + this.normal_angle, this.yMaxLimit + this.normal_angle); if (this.surfaceColliders != null) { RaycastHit raycastHit = (RaycastHit)null; Vector3 vector3 = Vector3.Normalize(Vector3.op_Subtraction(this.targetFocus.get_position(), ((Component)this).get_transform().get_position())); float num = 0.01f; bool flag = false; foreach (Collider surfaceCollider in this.surfaceColliders) { if (surfaceCollider.Raycast(new Ray(Vector3.op_Subtraction(((Component)this).get_transform().get_position(), Vector3.op_Multiply(vector3, this.bounds_MaxSize)), vector3), ref raycastHit, float.PositiveInfinity)) { num = Mathf.Max(Vector3.Distance(((RaycastHit) ref raycastHit).get_point(), this.targetFocus.get_position()) + this.distance, num); flag = true; } } if (flag) { this.cur_distance += (float)(((double)num - (double)this.cur_distance) * (double)Time.get_deltaTime() * 4.0); } } Quaternion quaternion = Quaternion.Euler(this.y, this.x, 0.0f); Vector3 vector3_1 = Vector3.op_Addition(Quaternion.op_Multiply(quaternion, new Vector3(0.0f, 0.0f, -this.cur_distance)), this.targetFocus.get_position()); ((Component)this).get_transform().set_rotation(quaternion); ((Component)this).get_transform().set_position(vector3_1); }