11using System ;
22using System . Collections . Generic ;
33using System . Linq ;
4- using System . Text ;
5- using RemoteTech ;
6- using UnityEngine ;
74
85namespace RemoteTech
96{
@@ -13,7 +10,9 @@ public static bool HasFlightComputer(Guid id)
1310 {
1411 var satellite = RTCore . Instance . Satellites [ id ] ;
1512 if ( satellite == null ) return false ;
16- return satellite . FlightComputer != null ;
13+ var hasFlightComputer = satellite . FlightComputer != null ;
14+ RTLog . Verbose ( "Flight: {0} HasFlightComputer: {1}" , id , hasFlightComputer ) ;
15+ return hasFlightComputer ;
1716 }
1817
1918 public static void AddSanctionedPilot ( Guid id , Action < FlightCtrlState > autopilot )
@@ -24,6 +23,7 @@ public static void AddSanctionedPilot(Guid id, Action<FlightCtrlState> autopilot
2423 {
2524 if ( spu . FlightComputer == null ) continue ;
2625 if ( spu . FlightComputer . SanctionedPilots . Contains ( autopilot ) ) continue ;
26+ RTLog . Verbose ( "Flight: {0} Adding Sanctioned Pilot" , id ) ;
2727 spu . FlightComputer . SanctionedPilots . Add ( autopilot ) ;
2828 }
2929 }
@@ -35,48 +35,59 @@ public static void RemoveSanctionedPilot(Guid id, Action<FlightCtrlState> autopi
3535 foreach ( var spu in satellite . SignalProcessors )
3636 {
3737 if ( spu . FlightComputer == null ) continue ;
38+ RTLog . Verbose ( "Flight: {0} Removing Sanctioned Pilot" , id ) ;
3839 spu . FlightComputer . SanctionedPilots . Remove ( autopilot ) ;
3940 }
4041 }
4142
4243 public static bool HasAnyConnection ( Guid id )
4344 {
4445 var satellite = RTCore . Instance . Satellites [ id ] ;
45- return RTCore . Instance . Network [ satellite ] . Any ( ) ;
46+ var hasConnection = RTCore . Instance . Network [ satellite ] . Any ( ) ;
47+ RTLog . Verbose ( "Flight: {0} Has Connection: {1}" , id , hasConnection ) ;
48+ return hasConnection ;
4649 }
4750
4851 public static bool HasConnectionToKSC ( Guid id )
4952 {
5053 var satellite = RTCore . Instance . Satellites [ id ] ;
51- return RTCore . Instance . Network [ satellite ] . Any ( r => RTCore . Instance . Network . GroundStations . ContainsKey ( r . Goal . Guid ) ) ;
54+ var connectedToKerbin = RTCore . Instance . Network [ satellite ] . Any ( r => RTCore . Instance . Network . GroundStations . ContainsKey ( r . Goal . Guid ) ) ;
55+ RTLog . Verbose ( "Flight: {0} Has Connection to Kerbin: {1}" , id , connectedToKerbin ) ;
56+ return connectedToKerbin ;
5257 }
5358
5459 public static double GetShortestSignalDelay ( Guid id )
5560 {
5661 var satellite = RTCore . Instance . Satellites [ id ] ;
5762 if ( ! RTCore . Instance . Network [ satellite ] . Any ( ) ) return Double . PositiveInfinity ;
58- return RTCore . Instance . Network [ satellite ] . Min ( ) . Delay ;
63+ var shortestDelay = RTCore . Instance . Network [ satellite ] . Min ( ) . Delay ;
64+ RTLog . Verbose ( "Flight: Shortest signal delay from {0} to {1}" , id , shortestDelay ) ;
65+ return shortestDelay ;
5966 }
6067
6168 public static double GetSignalDelayToKSC ( Guid id )
6269 {
6370 var satellite = RTCore . Instance . Satellites [ id ] ;
6471 if ( ! RTCore . Instance . Network [ satellite ] . Any ( r => RTCore . Instance . Network . GroundStations . ContainsKey ( r . Goal . Guid ) ) ) return Double . PositiveInfinity ;
65- return RTCore . Instance . Network [ satellite ] . Where ( r => RTCore . Instance . Network . GroundStations . ContainsKey ( r . Goal . Guid ) ) . Min ( ) . Delay ;
72+ var signalDelaytoKerbin = RTCore . Instance . Network [ satellite ] . Where ( r => RTCore . Instance . Network . GroundStations . ContainsKey ( r . Goal . Guid ) ) . Min ( ) . Delay ;
73+ RTLog . Verbose ( "Connection from {0} to Kerbin Delay: {1}" , id , signalDelaytoKerbin ) ;
74+ return signalDelaytoKerbin ;
6675 }
6776
6877 public static double GetSignalDelayToSatellite ( Guid a , Guid b )
6978 {
70- var sat_a = RTCore . Instance . Satellites [ a ] ;
71- var sat_b = RTCore . Instance . Satellites [ b ] ;
72- if ( sat_a == null || sat_b == null ) return Double . PositiveInfinity ;
79+ var satelliteA = RTCore . Instance . Satellites [ a ] ;
80+ var satelliteB = RTCore . Instance . Satellites [ b ] ;
81+ if ( satelliteA == null || satelliteB == null ) return Double . PositiveInfinity ;
7382
7483 Func < ISatellite , IEnumerable < NetworkLink < ISatellite > > > neighbors = RTCore . Instance . Network . FindNeighbors ;
7584 Func < ISatellite , NetworkLink < ISatellite > , double > cost = RangeModelExtensions . DistanceTo ;
7685 Func < ISatellite , ISatellite , double > heuristic = RangeModelExtensions . DistanceTo ;
7786
78- var path = NetworkPathfinder . Solve ( sat_a , sat_b , neighbors , cost , heuristic ) ;
79- return path . Delay ;
87+ var path = NetworkPathfinder . Solve ( satelliteA , satelliteB , neighbors , cost , heuristic ) ;
88+ var delayBetween = path . Delay ;
89+ RTLog . Verbose ( "Connection from {0} to {1} Delay: {2}" , a , b , delayBetween ) ;
90+ return delayBetween ;
8091 }
8192 }
8293}
0 commit comments