Example #1
0
        public void OnDestroy()
        {
            if (RotationChannel != null)
            {
                RotationChannel.Remove(vesselRotationCallback);
            }
            if (TranslationChannel != null)
            {
                TranslationChannel.Remove(vesselTranslationCallback);
            }
            if (WheelChannel != null)
            {
                WheelChannel.Remove(wheelCallback);
            }
            if (ThrottleChannel != null)
            {
                ThrottleChannel.Remove(throttleCallback);
            }
            if (AutopilotChannel != null)
            {
                AutopilotChannel.Remove(autopilotModeCallback);
            }

            FlightGlobals.ActiveVessel.OnPostAutopilotUpdate -= AutopilotUpdater;
        }
Example #2
0
        public void Start()
        {
            RotationChannel = GameEvents.FindEvent <EventData <byte, object> >("onSerialReceived16");
            if (RotationChannel != null)
            {
                RotationChannel.Add(vesselRotationCallback);
            }
            TranslationChannel = GameEvents.FindEvent <EventData <byte, object> >("onSerialReceived17");
            if (TranslationChannel != null)
            {
                TranslationChannel.Add(vesselTranslationCallback);
            }
            WheelChannel = GameEvents.FindEvent <EventData <byte, object> >("onSerialReceived18");
            if (WheelChannel != null)
            {
                WheelChannel.Add(wheelCallback);
            }
            ThrottleChannel = GameEvents.FindEvent <EventData <byte, object> >("onSerialReceived19");
            if (ThrottleChannel != null)
            {
                ThrottleChannel.Add(throttleCallback);
            }
            AutopilotChannel = GameEvents.FindEvent <EventData <byte, object> >("onSerialReceived28");
            if (AutopilotChannel != null)
            {
                AutopilotChannel.Add(autopilotModeCallback);
            }

            FlightGlobals.ActiveVessel.OnPostAutopilotUpdate += AutopilotUpdater;
        }
        public void OnDestroy()
        {
            if (RotationChannel != null)
            {
                RotationChannel.Remove(vesselRotationCallback);
            }
            if (TranslationChannel != null)
            {
                TranslationChannel.Remove(vesselTranslationCallback);
            }
            if (WheelChannel != null)
            {
                WheelChannel.Remove(wheelCallback);
            }
            if (ThrottleChannel != null)
            {
                ThrottleChannel.Remove(throttleCallback);
            }
            if (CustomAxisChannel != null)
            {
                CustomAxisChannel.Remove(customAxisCallback);
            }
            if (AutopilotChannel != null)
            {
                AutopilotChannel.Remove(autopilotModeCallback);
            }

            KSPit.RemoveToDeviceHandler(SASInfoProvider);

            lastActiveVessel.OnPostAutopilotUpdate -= AutopilotUpdater;
            GameEvents.onVesselChange.Remove(OnVesselChange);
        }
        public void Start()
        {
            RotationChannel = GameEvents.FindEvent <EventData <byte, object> >("onSerialReceived" + InboundPackets.VesselRotation);
            if (RotationChannel != null)
            {
                RotationChannel.Add(vesselRotationCallback);
            }
            TranslationChannel = GameEvents.FindEvent <EventData <byte, object> >("onSerialReceived" + InboundPackets.VesselTranslation);
            if (TranslationChannel != null)
            {
                TranslationChannel.Add(vesselTranslationCallback);
            }
            WheelChannel = GameEvents.FindEvent <EventData <byte, object> >("onSerialReceived" + InboundPackets.WheelControl);
            if (WheelChannel != null)
            {
                WheelChannel.Add(wheelCallback);
            }
            ThrottleChannel = GameEvents.FindEvent <EventData <byte, object> >("onSerialReceived" + InboundPackets.VesselThrottle);
            if (ThrottleChannel != null)
            {
                ThrottleChannel.Add(throttleCallback);
            }
            CustomAxisChannel = GameEvents.FindEvent <EventData <byte, object> >("onSerialReceived" + InboundPackets.VesselCustomAxis);
            if (CustomAxisChannel != null)
            {
                CustomAxisChannel.Add(customAxisCallback);
            }
            AutopilotChannel = GameEvents.FindEvent <EventData <byte, object> >("onSerialReceived" + InboundPackets.AutopilotMode);
            if (AutopilotChannel != null)
            {
                AutopilotChannel.Add(autopilotModeCallback);
            }

            SASInfoChannel = GameEvents.FindEvent <EventData <byte, object> >("toSerial" + OutboundPackets.SASInfo);
            KSPit.AddToDeviceHandler(SASInfoProvider);
            mySASInfo.currentSASMode      = 255; // value for not enabled
            mySASInfo.SASModeAvailability = 0;

            lastActiveVessel = FlightGlobals.ActiveVessel;
            FlightGlobals.ActiveVessel.OnPostAutopilotUpdate += AutopilotUpdater;
            GameEvents.onVesselChange.Add(OnVesselChange);
        }