void FixedUpdate() { // RemoteTech not loaded, don't do anything if (RTCore.Instance == null) { return; } Initialize(); // Check if time to update bool priorityUpdate = false; if (tick++ % UPDATE_INTERVAL != 0) { if (priorityList.Count > 0 && tick % UPDATE_INTERVAL == UPDATE_INTERVAL / 2) { priorityUpdate = true; } else { return; } } // Get the celestial body and index we'll be checking CelestialBody body = null; int i = 0; if (priorityUpdate) { body = priorityList[nextPriorityCheck++ % priorityList.Count]; i = (nextPriorityCheck / priorityList.Count) % POINT_COUNT; } else { body = FlightGlobals.Bodies[nextCheck++ % FlightGlobals.Bodies.Count]; i = (nextCheck / FlightGlobals.Bodies.Count) % POINT_COUNT; } LoggingUtil.LogVerbose(this, "OnFixedUpdate check ({0}): {1}, point = {2}", priorityUpdate, body.name, i); // Set the position fakeSatellite.Position = body.GetWorldSurfacePosition(Math.Sin((i * LAT_OFFSET) / POINT_COUNT * 2.0 * Math.PI) * 45.0, (i * LON_OFFSET) / POINT_COUNT * 360.0, 10000.0); // Attempt to find a path Func <ISatellite, IEnumerable <NetworkLink <ISatellite> > > neighbors = fakeSatellite.FindNeighbors; Func <ISatellite, NetworkLink <ISatellite>, double> cost = FakeSatellite.DistanceTo; Func <ISatellite, ISatellite, double> heuristic = FakeSatellite.DistanceTo; var path = NetworkPathfinder.Solve(fakeSatellite, RTSettings.Instance.GroundStations[0], neighbors, cost, heuristic); // Get the masks for our value UInt32 mask = (UInt32)1 << i; // Get the coverage info CelestialBodyInfo cbi = celestialBodies[body]; // Update our value cbi.coverage = path.Exists ? (cbi.coverage | mask) : (cbi.coverage & ~mask); }
public static double GetSignalDelayToSatellite(Guid a, Guid b) { var satelliteA = RTCore.Instance.Satellites[a]; var satelliteB = RTCore.Instance.Satellites[b]; if (satelliteA == null || satelliteB == null) { return(Double.PositiveInfinity); } Func <ISatellite, IEnumerable <NetworkLink <ISatellite> > > neighbors = RTCore.Instance.Network.FindNeighbors; Func <ISatellite, NetworkLink <ISatellite>, double> cost = RangeModelExtensions.DistanceTo; Func <ISatellite, ISatellite, double> heuristic = RangeModelExtensions.DistanceTo; var path = NetworkPathfinder.Solve(satelliteA, satelliteB, neighbors, cost, heuristic); var delayBetween = path.Delay; RTLog.Verbose("Connection from {0} to {1} Delay: {2}", RTLogLevel.API, a, b, delayBetween); return(delayBetween); }