public static void render() { // get home body position Vector3 home = ScaledSpace.LocalToScaledSpace(FlightGlobals.GetHomeBody().position); // for each vessel foreach (Vessel v in FlightGlobals.Vessels) { // get info from the cache vessel_info vi = Cache.VesselInfo(v); // skip invalid vessels if (!vi.is_valid) { continue; } // get data from db vessel_data vd = DB.VesselData(v.id); // skip vessels with showlink disabled if (vd.cfg_showlink == 0) { continue; } // get link data link_data link = vi.link; // skip vessels with no antenna if (link.status == link_status.no_antenna) { continue; } // start of the line Vector3 a = ScaledSpace.LocalToScaledSpace(v.GetWorldPos3D()); // determine end of line and color Vector3 b; Color color; if (link.status == link_status.no_link) { b = home; color = Color.red; } else if (link.status == link_status.direct_link) { b = home; color = Color.green; } else //< indirect link { // get link path var path = link.path; // use relay position b = ScaledSpace.LocalToScaledSpace(path[path.Count - 1].GetWorldPos3D()); color = Color.yellow; } // commit the line LineRenderer.commit(a, b, color); } }
public static void render() { // do nothing if signal mechanic is disabled if (!Features.Signal) { return; } // get home body position Vector3 home = ScaledSpace.LocalToScaledSpace(FlightGlobals.GetHomeBody().position); // for each vessel foreach (Vessel v in FlightGlobals.Vessels) { // get info from the cache vessel_info vi = Cache.VesselInfo(v); // skip invalid vessels if (!vi.is_valid) { continue; } // get data from db VesselData vd = DB.Vessel(v); // skip vessels with showlink disabled if (!vd.cfg_showlink) { continue; } // get connection info ConnectionInfo conn = vi.connection; // skip unlinked vessels // - we don't show the red line anymore if (!conn.linked) { continue; } // start of the line Vector3 a = ScaledSpace.LocalToScaledSpace(v.GetWorldPos3D()); // determine end of line and color Vector3 b; Color color; if (conn.status == LinkStatus.direct_link) { b = home; color = Color.green; } else //< indirect link { // get link path var path = conn.path; // use relay position b = ScaledSpace.LocalToScaledSpace(path[path.Count - 1].GetWorldPos3D()); color = Color.yellow; } // commit the line LineRenderer.commit(a, b, color); // if transmitting or relaying science data if (vi.transmitting.Length > 0 || vi.relaying.Length > 0) { // deduce number of particles and distance between them Vector3 dir = b - a; float len = dir.magnitude; int particle_count = Lib.Clamp((int)(len / 80.0f), 1, 256); dir /= (float)particle_count; // used for 'moving' effect float k = Time.realtimeSinceStartup / 3.0f; k -= Mathf.Floor(k); // particle color // - fade to avoid overlapping Color clr = Color.cyan; clr.a = Mathf.Min(Lib.Clamp(1.0f - 0.01f * PlanetariumCamera.fetch.Distance / dir.magnitude, 0.0f, 1.0f) * 2.0f, 1.0f); // for each particle for (int i = 0; i < particle_count; ++i) { // commit particle ParticleRenderer.commit(a + dir * ((float)i + k), 8.0f, clr); } } } }