Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private bool PartLOS(Transform refXForm, out string obscuringPart)
- {
- bool result = true;
- obscuringPart = "nil";
- CelestialBody celestialBody = FlightGlobals.get_Bodies()[0];
- RaycastHit raycastHit;
- if (Physics.Raycast(refXForm.get_position(), refXForm.get_position() - celestialBody.get_transform().get_position(), ref raycastHit, 2500f))
- {
- Transform transform = raycastHit.get_transform();
- Part component = transform.GetComponent<Part>();
- if (component != null && component != base.get_part())
- {
- result = false;
- obscuringPart = component.partInfo.name;
- }
- }
- return result;
- }
- private bool SolarLOS(Transform refXForm, out float angle, out string obscuringBody)
- {
- bool result = true;
- angle = 0f;
- obscuringBody = "nil";
- CelestialBody celestialBody = FlightGlobals.get_Bodies()[0];
- CelestialBody currentMainBody = FlightGlobals.currentMainBody;
- angle = Vector3.Angle(refXForm.get_forward(), celestialBody.get_transform().get_position() - refXForm.get_position());
- if (currentMainBody != celestialBody)
- {
- Vector3d vector3d = celestialBody.get_position() - base.get_part().vessel.GetWorldPos3D();
- Vector3d vector3d2 = currentMainBody.get_position() - base.get_part().vessel.GetWorldPos3D();
- if (Vector3d.Dot(vector3d, vector3d2) > vector3d2.get_sqrMagnitude() - currentMainBody.Radius * currentMainBody.Radius && (double)Mathf.Pow(Vector3.Dot(vector3d, vector3d2), 2f) / vector3d.get_sqrMagnitude() > vector3d2.get_sqrMagnitude() - currentMainBody.Radius * currentMainBody.Radius)
- {
- result = false;
- obscuringBody = currentMainBody.get_name();
- }
- }
- return result;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement