public static void SetParents(TransferWindow.Data transferWindowData, Transform markerPlanet, Transform markerOrbit, Material meshPlanetMaterial) { if (transferWindowData.transferType == TransferWindow.TransferType.None) { return; } markerOrbit.parent = Ref.map.mapRefs[transferWindowData.departure].holder; markerOrbit.localPosition = Vector3.zero; if (transferWindowData.transferType != TransferWindow.TransferType.ToNeighbour) { return; } bool flag = transferWindowData.firstNeighbour.orbitData.orbitHeightM > transferWindowData.secondNeighbour.orbitData.orbitHeightM; float num = (float)(transferWindowData.firstNeighbour.orbitData.orbitHeightM / 10000.0); markerPlanet.localScale = new Vector3(num, (!flag) ? (-num) : num, 1f); markerPlanet.parent = Ref.map.mapRefs[transferWindowData.firstNeighbour.parentBody].holder; markerPlanet.localPosition = Vector3.zero; TransferWindow.UpdateTransferWindowAlpha(meshPlanetMaterial, transferWindowData); }
public static void PositionPlanetMarker(ref bool show, ref MeshFilter markerPlanet, TransferWindow.Data transferWindow) { if (transferWindow.transferType != TransferWindow.TransferType.ToNeighbour) { return; } double num = transferWindow.phaseAngle + Ref.controller.globalTime * transferWindow.secondNeighbour.orbitData._meanMotion; markerPlanet.transform.localEulerAngles = new Vector3(0f, 0f, (float)num * 57.29578f); show = true; }
public static void UpdateTransferWindowAlpha(Material material, TransferWindow.Data data) { material.color = new Color(1f, 1f, 1f, 0.05f + Mathf.Clamp01((float)(-(float)(Ref.map.mapPosition.z * 10000.0) / (data.firstNeighbour.orbitData.orbitHeightM * 0.5))) * 0.2f); }
public static void PositionOrbitMarker(ref bool show, ref MeshFilter meshFilterOrbit, List <Orbit> orbits, TransferWindow.Data transferWindow) { if (transferWindow.transferType == TransferWindow.TransferType.None) { return; } if (orbits.Count == 0) { return; } if (orbits[0].orbitType == Orbit.Type.Encounter) { return; } double ejectionOrbitHeight = Math.Min(orbits[0].periapsis * 1.35, orbits[0].apoapsis); TransferWindow.UpdateLocalTransferWindowMarker(ref show, ref meshFilterOrbit, ejectionOrbitHeight, orbits[0], transferWindow); }
private static void UpdateLocalTransferWindowMarker(ref bool show, ref MeshFilter meshFilterOrbit, double ejectionOrbitHeight, Orbit orbit, TransferWindow.Data transferWindow) { if (transferWindow.departure.type == CelestialBodyData.Type.Star || (transferWindow.transferType == TransferWindow.TransferType.ToNeighbour && transferWindow.departure != transferWindow.firstNeighbour)) { return; } if (transferWindow.transferType == TransferWindow.TransferType.ToNeighbour || transferWindow.transferType == TransferWindow.TransferType.ToParent) { CelestialBodyData celestialBodyData = (transferWindow.transferType != TransferWindow.TransferType.ToNeighbour) ? transferWindow.departure : transferWindow.firstNeighbour; double orbitHeightM = celestialBodyData.orbitData.orbitHeightM; double num = (transferWindow.transferType != TransferWindow.TransferType.ToNeighbour) ? (transferWindow.target.radius + transferWindow.target.atmosphereData.atmosphereHeightM) : transferWindow.secondNeighbour.orbitData.orbitHeightM; double num2 = Math.Min(num, orbitHeightM); double num3 = (orbitHeightM + num) * 0.5; double e = 1.0 - num2 / num3; double mass = celestialBodyData.parentBody.mass; double meanMotion = Kepler.GetMeanMotion(Kepler.GetPeriod(e, num3, mass), e, mass, num3); bool flag = num > orbitHeightM; double magnitude2d = Kepler.GetVelocity(num3, orbitHeightM, meanMotion, (!flag) ? 3.1415926535897931 : 0.0, (!flag) ? 3.1415926535897931 : 0.0, e, 0.0).magnitude2d; double escapeVelocity = magnitude2d - -celestialBodyData.orbitData.orbitalVelocity; float num4 = (float)(Kepler.GetEjectionAngle(escapeVelocity, ejectionOrbitHeight, celestialBodyData.mass, celestialBodyData.orbitData.SOI) * (double)Math.Sign(-orbit.meanMotion) + ((!flag) ? 3.1415926535897931 : 0.0)); float ejectionAngle = num4 + (float)(Ref.controller.globalTime * celestialBodyData.orbitData._meanMotion) - 1.57079637f; TransferWindow.GenerateMeshOrbitTW(ref meshFilterOrbit, ref show, ejectionAngle, orbit); return; } if (transferWindow.transferType != TransferWindow.TransferType.ToSatellite) { return; } if (ejectionOrbitHeight > transferWindow.target.orbitData.orbitHeightM * 0.75) { return; } float num5 = (float)Kepler.GetPhaseAngle(ejectionOrbitHeight, transferWindow.target.orbitData.orbitHeightM); float ejectionAngle2 = num5 + (float)(Ref.controller.globalTime * transferWindow.target.orbitData._meanMotion); TransferWindow.GenerateMeshOrbitTW(ref meshFilterOrbit, ref show, ejectionAngle2, orbit); }