Advertisement
Guest User

Untitled

a guest
Sep 3rd, 2015
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.68 KB | None | 0 0
  1. private bool PartLOS(Transform refXForm, out string obscuringPart)
  2. {
  3. bool result = true;
  4. obscuringPart = "nil";
  5. CelestialBody celestialBody = FlightGlobals.get_Bodies()[0];
  6. RaycastHit raycastHit;
  7. if (Physics.Raycast(refXForm.get_position(), refXForm.get_position() - celestialBody.get_transform().get_position(), ref raycastHit, 2500f))
  8. {
  9. Transform transform = raycastHit.get_transform();
  10. Part component = transform.GetComponent<Part>();
  11. if (component != null && component != base.get_part())
  12. {
  13. result = false;
  14. obscuringPart = component.partInfo.name;
  15. }
  16. }
  17. return result;
  18. }
  19.  
  20. private bool SolarLOS(Transform refXForm, out float angle, out string obscuringBody)
  21. {
  22. bool result = true;
  23. angle = 0f;
  24. obscuringBody = "nil";
  25. CelestialBody celestialBody = FlightGlobals.get_Bodies()[0];
  26. CelestialBody currentMainBody = FlightGlobals.currentMainBody;
  27. angle = Vector3.Angle(refXForm.get_forward(), celestialBody.get_transform().get_position() - refXForm.get_position());
  28. if (currentMainBody != celestialBody)
  29. {
  30. Vector3d vector3d = celestialBody.get_position() - base.get_part().vessel.GetWorldPos3D();
  31. Vector3d vector3d2 = currentMainBody.get_position() - base.get_part().vessel.GetWorldPos3D();
  32. 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)
  33. {
  34. result = false;
  35. obscuringBody = currentMainBody.get_name();
  36. }
  37. }
  38. return result;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement