63 lines
1.6 KiB
Python
63 lines
1.6 KiB
Python
import sys
|
|
import signal
|
|
|
|
from mission_control import ShuttleKerbin, ComsatKerbin
|
|
from mission import RescueMission, ComSatNetworkMission
|
|
|
|
from maneuver_scheduler import ManeuverScheduler
|
|
|
|
from connector import get_connexion
|
|
|
|
|
|
class Backlog:
|
|
missions = {
|
|
'Kerbin': [RescueMission('Rescue Rossby from orbit of Kerbin.'), ] # ComSatNetworkMission('Kerbin')]
|
|
}
|
|
kerbin_to_orbit = []
|
|
kerbin_to_ground = []
|
|
|
|
|
|
def signal_handler(signal, frame):
|
|
print("\nBye!")
|
|
sys.exit(0)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
signal.signal(signal.SIGINT, signal_handler)
|
|
ships = []
|
|
|
|
ships.append(ShuttleKerbin('KKS Gagarin'))
|
|
ships.append(ComsatKerbin('KKR Shepard'))
|
|
|
|
conn = get_connexion()
|
|
# conn.space_center.GameMode
|
|
space_center = conn.space_center
|
|
|
|
for s in ships:
|
|
s.pick_missions(Backlog)
|
|
|
|
while True:
|
|
for s in ships:
|
|
s.pick_missions(Backlog)
|
|
|
|
space_center.rails_warp_factor = 7
|
|
with conn.stream(getattr, space_center, 'rails_warp_factor') as rails_warp_factor:
|
|
with rails_warp_factor.condition:
|
|
while rails_warp_factor() > 0:
|
|
rails_warp_factor.wait()
|
|
|
|
alarm = ManeuverScheduler.get_last_alarm()
|
|
vessel = alarm.vessel
|
|
|
|
current_ship = None
|
|
for s in ships:
|
|
if s.vessel.name == vessel.name:
|
|
current_ship = s
|
|
break
|
|
|
|
if current_ship is None:
|
|
raise LookupError("Current ship {} not found".format(vessel.name))
|
|
current_ship.execute_mission(alarm)
|
|
alarm.remove()
|
|
print("turn")
|