protected override void OnStart() { base.OnStart(); try { vesselAsst = new PilotAssistant(this); vesselData = new VesselData(this); PilotAssistantFlightCore.Instance.AddVessel(this); vesselAsst.Start(); Vessel.OnPreAutopilotUpdate += new FlightInputCallback(PreAutoPilotUpdate); Vessel.OnPostAutopilotUpdate += new FlightInputCallback(PostAutoPilotUpdate); GameEvents.onVesselChange.Add(VesselSwitch); GameEvents.onTimeWarpRateChanged.Add(WarpHandler); if (FlightGlobals.ActiveVessel == Vessel) { VesselSwitch(Vessel); } } catch (Exception ex) { Logger.Log("Startup error", Logger.LogLevel.Error); Logger.Log(ex.Message, Logger.LogLevel.Error); Logger.Log(ex.InnerException, Logger.LogLevel.Error); Logger.Log(ex.StackTrace, Logger.LogLevel.Error); } }
public void Start() { try { vesselRef = GetComponent <Vessel>(); if (vesselRef == null || vesselRef.isEVA || !vesselRef.isCommandable) { vesselRef = null; Destroy(this); return; } else { vesselAsst = new PilotAssistant(this); vesselSSAS = new SurfSAS(this); vesselStockSAS = new Stock_SAS(this); vesselData = new VesselData(this); } PilotAssistantFlightCore.Instance.addVessel(this); vesselAsst.Start(); vesselSSAS.Start(); vesselStockSAS.Start(); } catch (Exception ex) { Debug.LogError("Pilot Assistant: Startup error"); Debug.LogError(ex.InnerException); } vesselRef.OnPreAutopilotUpdate += new FlightInputCallback(preAutoPilotUpdate); vesselRef.OnPostAutopilotUpdate += new FlightInputCallback(postAutoPilotUpdate); GameEvents.onPartCouple.Add(docking); GameEvents.onVesselChange.Add(vesselSwitch); GameEvents.onTimeWarpRateChanged.Add(warpHandler); }