Пример #1
0
            public bool NewValueFromString(string stringValue)
            {
                if (string.IsNullOrEmpty(stringValue))
                {
                    return(false);
                }

                try
                {
                    if (NewValueType != typeof(string))
                    {
                        NewValue = Convert.ChangeType(NewValue, this.NewValueType, CultureInfo.InvariantCulture);
                    }
                    else
                    {
                        NewValue = stringValue;
                    }

                    return(true);
                }
                catch (Exception ex) when(ex is InvalidCastException || ex is FormatException || ex is OverflowException)
                {
                    RTLog.Notify("WrappedField.NewValueFromString() : can't convert {0} to new type: {1} ; for field name: {2}", stringValue, NewValueType, FieldInfo.Name);
                    return(false);
                }
            }
Пример #2
0
        public ProtoSignalProcessor(ProtoPartModuleSnapshot ppms, Vessel v)
        {
            Vessel  = v;
            Powered = ppms.GetBool("IsRTPowered");

            // get the crew count from the vessel
            var crewcount = v.GetVesselCrew().Count;

            // when the crew count is equal to 0 then look into the protoVessel
            if (crewcount == 0 && v.protoVessel.GetVesselCrew() != null)
            {
                crewcount = v.protoVessel.GetVesselCrew().Count;
            }

            RTLog.Notify("ProtoSignalProcessor crew count of {0} is {1}", v.vesselName, crewcount);

            int ppmsMinCrew;

            //try to get the RTCommandMinCrew value in the ProtoPartModuleSnapshot
            if (ppms.GetInt("RTCommandMinCrew", out ppmsMinCrew))
            {
                IsCommandStation = Powered && v.HasCommandStation() && crewcount >= ppmsMinCrew;
                RTLog.Notify("ProtoSignalProcessor(Powered: {0}, HasCommandStation: {1}, Crew: {2}/{3})",
                             Powered, v.HasCommandStation(), crewcount, ppmsMinCrew);
            }
            else
            {
                // there was no RTCommandMinCrew member in the ProtoPartModuleSnapshot
                IsCommandStation = false;

                RTLog.Notify("ProtoSignalProcessor(Powered: {0}, HasCommandStation: {1}, Crew: {2})",
                             Powered, v.HasCommandStation(), crewcount);
            }
        }
Пример #3
0
        /// <summary>
        /// Draws the content of the Presets section
        /// </summary>
        private void drawPresetsContent()
        {
            GUILayout.Label("A third-party mod can replace your current RemoteTech settings with its own settings (GameData/ExampleMod/RemoteTechSettings.cfg).\nAlso, you can revert to RemoteTech's default settings.\nHere you can see what presets are available:", this.mGuiRunningText);
            GUILayout.Space(15);

            List <String> presetList = this.mSettings.PreSets;

            if (this.mSettings.PreSets.Count <= 0)
            {
                GUILayout.Label("No presets are found", this.mGuiRunningText);
            }

            for (int i = presetList.Count - 1; i >= 0; --i)
            {
                GUILayout.BeginHorizontal("box", GUILayout.MaxHeight(15));
                {
                    string folderName = presetList[i];
                    int    index      = folderName.LastIndexOf("/RemoteTechSettings");
                    folderName = folderName.Substring(0, index) + folderName.Substring(index).Replace("/RemoteTechSettings", ".cfg").Trim();

                    GUILayout.Space(15);
                    GUILayout.Label("- " + folderName, this.mGuiListText, GUILayout.ExpandWidth(true));
                    if (GUILayout.Button("Overwrite", this.mGuiListButton, GUILayout.Width(70), GUILayout.Height(20)))
                    {
                        RTSettings.ReloadSettings(this.mSettings, presetList[i]);
                        ScreenMessages.PostScreenMessage(string.Format("Your RemoteTech settings are set to {0}", folderName), 15);
                        RTLog.Notify("Overwrote current settings with this cfg {0}", RTLogLevel.LVL3, presetList[i]);
                    }
                }
                GUILayout.EndHorizontal();
            }
        }
Пример #4
0
        public ProtoAntenna(Vessel v, ProtoPartSnapshot p, ProtoPartModuleSnapshot ppms)
        {
            Name         = p.partInfo.title;
            Consumption  = 0;
            Guid         = v.id;
            mProtoPart   = p;
            mProtoModule = ppms;
            try
            {
                mDishTarget = new Guid(ppms.moduleValues.GetValue("RTAntennaTarget"));
            }
            catch (Exception ex) when(ex is ArgumentNullException || ex is FormatException || ex is OverflowException)
            {
                mDishTarget = Guid.Empty;
            }
            double temp_double;
            float  temp_float;
            bool   temp_bool;

            Dish      = Single.TryParse(ppms.moduleValues.GetValue("RTDishRange"), out temp_float) ? temp_float : 0.0f;
            CosAngle  = Double.TryParse(ppms.moduleValues.GetValue("RTDishCosAngle"), out temp_double) ? temp_double : 0.0;
            Omni      = Single.TryParse(ppms.moduleValues.GetValue("RTOmniRange"), out temp_float) ? temp_float : 0.0f;
            Powered   = Boolean.TryParse(ppms.moduleValues.GetValue("IsRTPowered"), out temp_bool) ? temp_bool : false;
            Activated = Boolean.TryParse(ppms.moduleValues.GetValue("IsRTActive"), out temp_bool) ? temp_bool : false;

            RTLog.Notify(ToString());
        }
Пример #5
0
        /// <summary>
        /// Change the Omni range of a ground station.
        /// Note that this change is temporary. For example it is overridden to the value written in the settings file if the tracking station is upgraded.
        /// </summary>
        /// <param name="stationId">The station ID for which to change the antenna range.</param>
        /// <param name="newRange">The new range in meters.</param>
        /// <returns>true if the ground station antenna range was changed, false otherwise.</returns>
        public static bool ChangeGroundStationRange(Guid stationId, float newRange)
        {
            RTLog.Notify("Trying to change ground station {0} Omni range to {1}", RTLogLevel.API, stationId.ToString(), newRange);

            if (RTSettings.Instance == null)
            {
                return(false);
            }

            if (RTSettings.Instance.GroundStations.Count > 0)
            {
                MissionControlSatellite groundStation = RTSettings.Instance.GroundStations.First(gs => gs.mGuid == stationId);
                if (groundStation == null)
                {
                    return(false);
                }

                IEnumerable <IAntenna> antennas = groundStation.MissionControlAntennas.ToArray();
                if (antennas.Count() > 0)
                {
                    // first antenna
                    IAntenna antenna = antennas.ToArray()[0];
                    if (antenna is MissionControlAntenna)
                    {
                        ((MissionControlAntenna)antenna).SetOmniAntennaRange(newRange);
                        RTLog.Notify("Ground station Omni range successfully changed.", RTLogLevel.API);
                        return(true);
                    }
                }
            }

            return(false);
        }
Пример #6
0
        public ProtoSignalProcessor(ProtoPartModuleSnapshot ppms, Vessel v)
        {
            mVessel = v;
            Powered = ppms.GetBool("IsRTPowered");

            // get the crew count from the vessel
            int crewcount = v.GetVesselCrew().Count;

            // when the crewcount is eq 0 than look into the protoVessel
            if (crewcount == 0 && v.protoVessel.GetVesselCrew() != null)
            {
                crewcount = v.protoVessel.GetVesselCrew().Count;
            }

            RTLog.Notify("ProtoSignalProcessor crew count of {0} is {1}", v.vesselName, crewcount);

            try {
                IsCommandStation = Powered && v.HasCommandStation() && crewcount >= ppms.GetInt("RTCommandMinCrew");
                RTLog.Notify("ProtoSignalProcessor(Powered: {0}, HasCommandStation: {1}, Crew: {2}/{3})",
                             Powered, v.HasCommandStation(), crewcount, ppms.GetInt("RTCommandMinCrew"));
            } catch (ArgumentException argexeception) {
                // I'm assuming this would get thrown by ppms.GetInt()... do the other functions have an exception spec?
                IsCommandStation = false;
                RTLog.Notify("ProtoSignalProcessor(Powered: {0}, HasCommandStation: {1}, Crew: {2})",
                             Powered, v.HasCommandStation(), crewcount);
                RTLog.Notify("ProtoSignalProcessor ", argexeception);
            }
        }
Пример #7
0
        public ProtoAntenna(Vessel v, ProtoPartSnapshot p, ProtoPartModuleSnapshot ppms)
        {
            ConfigNode n = new ConfigNode();

            ppms.Save(n);
            Name         = p.partInfo.title;
            Consumption  = 0;
            Guid         = v.id;
            mProtoPart   = p;
            mProtoModule = ppms;
            try
            {
                mDishTarget = new Guid(n.GetValue("RTAntennaTarget"));
            }
            catch (ArgumentException)
            {
                mDishTarget = Guid.Empty;
            }
            double temp_double;
            float  temp_float;
            bool   temp_bool;

            Dish      = Single.TryParse(n.GetValue("RTDishRange"), out temp_float) ? temp_float : 0.0f;
            CosAngle  = Double.TryParse(n.GetValue("RTDishCosAngle"), out temp_double) ? temp_double : 0.0;
            Omni      = Single.TryParse(n.GetValue("RTOmniRange"), out temp_float) ? temp_float : 0.0f;
            Powered   = Boolean.TryParse(n.GetValue("IsRTPowered"), out temp_bool) ? temp_bool : false;
            Activated = Boolean.TryParse(n.GetValue("IsRTActive"), out temp_bool) ? temp_bool : false;

            RTLog.Notify(ToString());
        }
Пример #8
0
        public static Guid AddGroundStation(string name, double latitude, double longitude, double height, int body)
        {
            RTLog.Notify("Trying to add ground station {0}", RTLogLevel.API, name);
            Guid newStationId = RTSettings.Instance.AddGroundStation(name, latitude, longitude, height, body);

            return(newStationId);
        }
Пример #9
0
        /*
         * Unity engine overridden methods
         */

        public void OnDestroy()
        {
            if (vessel == null)
            {
                RTLog.Notify("ModuleSPU: OnDestroy: no vessel!", RTLogLevel.LVL2);
                FlightComputer?.Dispose();
                return;
            }

            RTLog.Notify($"ModuleSPU: OnDestroy [{VesselName}]");

            GameEvents.onVesselWasModified.Remove(OnVesselModified);
            GameEvents.onPartUndock.Remove(OnPartUndock);
            GameEvents.onPartActionUICreate.Remove(OnPartActionUiCreate);
            GameEvents.onPartActionUIDismiss.Remove(OnPartActionUiDismiss);

            if (RTCore.Instance == null)
            {
                return;
            }

            RTCore.Instance.Satellites.Unregister(VesselId, this);
            VesselId = Guid.Empty;

            FlightComputer?.Dispose();
        }
Пример #10
0
        /*
         * PartModule overridden methods
         */

        public override void OnStart(StartState state)
        {
            if (state != StartState.Editor)
            {
                if (vessel == null)
                {
                    RTLog.Notify("ModuleSPU: OnStart : No vessel!", RTLogLevel.LVL2);
                    return;
                }

                RTLog.Notify($"ModuleSPU: OnStart [{VesselName}]");

                GameEvents.onVesselWasModified.Add(OnVesselModified);
                GameEvents.onPartUndock.Add(OnPartUndock);
                GameEvents.onPartActionUICreate.Add(OnPartActionUiCreate);
                GameEvents.onPartActionUIDismiss.Add(OnPartActionUiDismiss);
                VesselId = vessel.id;
                if (RTCore.Instance != null)
                {
                    RTCore.Instance.Satellites.Register(vessel, this);
                    if (FlightComputer == null)
                    {
                        FlightComputer = new FlightComputer.FlightComputer(this);
                    }
                }
            }

            Fields["GUI_Status"].guiActive = ShowGUI_Status;
        }
Пример #11
0
        /// <summary>
        /// Find the maneuver node by the saved node id (index id of the meneuver list)
        /// </summary>
        /// <param name="n">Node with the command infos</param>
        /// <param name="fc">Current flightcomputer</param>
        /// <returns>true - loaded successfull</returns>
        public override bool Load(ConfigNode n, FlightComputer fc)
        {
            //Additional notes: Load() is never called when cold-launching KSP and resuming flight.
            if (base.Load(n, fc))
            {
                if (n.HasValue("NodeIndex"))
                {
                    this.NodeIndex = int.Parse(n.GetValue("NodeIndex"));

                    if (fc.Vessel.patchedConicSolver == null)
                    {
                        fc.Vessel.AttachPatchedConicsSolver();
                        fc.Vessel.patchedConicSolver.Update();
                    }

                    RTLog.Notify("Trying to get Maneuver {0} in the list of {1} maneuver nodes", this.NodeIndex, fc.Vessel.patchedConicSolver.maneuverNodes.Count);

                    if (this.NodeIndex >= 0 && fc.Vessel.patchedConicSolver.maneuverNodes.Count > 0)
                    {
                        // Set the ManeuverNode into this command
                        this.Node = fc.Vessel.patchedConicSolver.maneuverNodes[this.NodeIndex];
                        RTLog.Notify("Found Maneuver {0} with {1} dV", this.NodeIndex, this.Node.DeltaV);

                        return(true);
                    }
                }
            }

            return(false);
        }
Пример #12
0
        /// <summary>Called when the flight computer is disposed. This happens when the <see cref="ModuleSPU"/> is destroyed.</summary>
        public void Dispose()
        {
            RTLog.Notify("FlightComputer: Dispose");

            GameEvents.onVesselChange.Remove(OnVesselChange);
            GameEvents.onVesselSwitching.Remove(OnVesselSwitching);
            GameEvents.onGameSceneSwitchRequested.Remove(OnSceneSwitchRequested);

            if (Vessel != null)
            {
                // remove flight code controls.
                Vessel.OnFlyByWire -= OnFlyByWirePre;
                Vessel.OnFlyByWire -= OnFlyByWirePost;
            }

            _flightComputerWindow?.Hide();

            // Remove RT listeners from KSP Autopilot
            if (StockAutopilotCommand.UIreference != null)
            {
                for (var index = 0; index < StockAutopilotCommand.UIreference.modeButtons.Length; index++)
                {
                    var buttonIndex = index; // prevent compiler optimisation from assigning static final index value
                    StockAutopilotCommand.UIreference.modeButtons[index].onClick.RemoveListener(delegate { StockAutopilotCommand.AutopilotButtonClick(buttonIndex, this); });
                }
                StockAutopilotCommand.UIreference = null;
            }
        }
Пример #13
0
        public static bool ReceiveDataExec(ConfigNode data)
        {
            RTLog.Verbose("Received Data via Api.ReceiveDataExec", RTLogLevel.API);
            RTLog.Notify("Data: {0}", data);

            return(bool.Parse(data.GetValue("AbortCommand")));
        }
Пример #14
0
        public override void OnLoad(ConfigNode node)
        {
            base.OnLoad(node);
            if (node.HasNode("TRANSMITTER"))
            {
                RTLog.Notify("ModuleRTAntennaPassive: Found TRANSMITTER block.");
                mTransmitterConfig = node.GetNode("TRANSMITTER");
                mTransmitterConfig.AddValue("name", "ModuleRTDataTransmitter");

                // workarround for ksp 1.0
                if (mTransmitterConfig.HasValue("PacketInterval"))
                {
                    RTPacketInterval = float.Parse(mTransmitterConfig.GetValue("PacketInterval"));
                }

                if (mTransmitterConfig.HasValue("PacketSize"))
                {
                    RTPacketSize = float.Parse(mTransmitterConfig.GetValue("PacketSize"));
                }

                if (mTransmitterConfig.HasValue("PacketResourceCost"))
                {
                    RTPacketResourceCost = float.Parse(mTransmitterConfig.GetValue("PacketResourceCost"));
                }
            }
        }
Пример #15
0
 void IScienceDataTransmitter.TransmitData(List <ScienceData> dataQueue)
 {
     RTLog.Notify("ModuleRTDataTransmitter::TransmitData(2p)");
     scienceDataQueue.AddRange(dataQueue);
     if (!isBusy)
     {
         StartCoroutine(Transmit());
     }
 }
Пример #16
0
 // Compatible with ModuleDataTransmitter
 public override void OnLoad(ConfigNode node)
 {
     RTLog.Notify("ModuleRTDataTransmitter::OnLoad");
     foreach (ConfigNode data in node.GetNodes("CommsData"))
     {
         scienceDataQueue.Add(new ScienceData(data));
     }
     GUIStatus = Localizer.Format("#RT_ModuleUI_Comms_Status");//"Idle"
 }
Пример #17
0
 private void RemoveTransmitter()
 {
     RTLog.Notify("ModuleRTAntenna: Remove TRANSMITTER success.");
     if (mTransmitter == null)
     {
         return;
     }
     part.RemoveModule((PartModule)mTransmitter);
     mTransmitter = null;
 }
Пример #18
0
 public override void OnLoad(ConfigNode node)
 {
     base.OnLoad(node);
     if (node.HasNode("TRANSMITTER"))
     {
         RTLog.Notify("ModuleRTAntennaPassive: Found TRANSMITTER block.");
         mTransmitterConfig = node.GetNode("TRANSMITTER");
         mTransmitterConfig.AddValue("name", "ModuleRTDataTransmitter");
     }
 }
Пример #19
0
        public override void OnLoad(ConfigNode node)
        {
            base.OnLoad(node);
            if (node.HasValue("RTAntennaTarget"))
            {
                try
                {
                    Target = new Guid(node.GetValue("RTAntennaTarget"));
                }
                catch (FormatException)
                {
                    Target = Guid.Empty;
                }
            }
            // Have RTDishRadians as a fallback to avoid corrupting save games
            if (node.HasValue("RTDishRadians"))
            {
                double temp_double;
                RTDishCosAngle = Double.TryParse(node.GetValue("RTDishRadians"), out temp_double) ? temp_double : 1.0;
            }
            if (node.HasValue("DishAngle"))
            {
                RTDishCosAngle = Math.Cos(DishAngle / 2 * Math.PI / 180);
            }
            if (node.HasValue("DeployFxModules"))
            {
                mDeployFxModuleIndices = KSPUtil.ParseArray <Int32>(node.GetValue("DeployFxModules"), new ParserMethod <Int32>(Int32.Parse));
            }
            if (node.HasValue("ProgressFxModules"))
            {
                mProgressFxModuleIndices = KSPUtil.ParseArray <Int32>(node.GetValue("ProgressFxModules"), new ParserMethod <Int32>(Int32.Parse));
            }
            if (node.HasNode("TRANSMITTER"))
            {
                RTLog.Notify("ModuleRTAntenna: Found TRANSMITTER block.");
                mTransmitterConfig = node.GetNode("TRANSMITTER");
                mTransmitterConfig.AddValue("name", "ModuleRTDataTransmitter");

                // workarround for ksp 1.0
                if (mTransmitterConfig.HasValue("PacketInterval"))
                {
                    RTPacketInterval = float.Parse(mTransmitterConfig.GetValue("PacketInterval"));
                }

                if (mTransmitterConfig.HasValue("PacketSize"))
                {
                    RTPacketSize = float.Parse(mTransmitterConfig.GetValue("PacketSize"));
                }

                if (mTransmitterConfig.HasValue("PacketResourceCost"))
                {
                    RTPacketResourceCost = float.Parse(mTransmitterConfig.GetValue("PacketResourceCost"));
                }
            }
        }
Пример #20
0
 public void OnDestroy()
 {
     RTLog.Notify("ModuleSPUPassive: OnDestroy");
     GameEvents.onVesselWasModified.Remove(OnVesselModified);
     GameEvents.onPartUndock.Remove(OnPartUndock);
     if (RTCore.Instance != null)
     {
         RTCore.Instance.Satellites.Unregister(VesselId, this);
         VesselId = Guid.Empty;
     }
 }
Пример #21
0
 private void OnDestroy()
 {
     RTLog.Notify("ModuleRTAntenna: OnDestroy");
     GameEvents.onVesselWasModified.Remove(OnVesselModified);
     GameEvents.onPartUndock.Remove(OnPartUndock);
     if (RTCore.Instance != null && mRegisteredId != Guid.Empty)
     {
         RTCore.Instance.Antennas.Unregister(mRegisteredId, this);
         mRegisteredId = Guid.Empty;
     }
 }
Пример #22
0
        public override bool Pop(FlightComputer f)
        {
            if (BaseField != null)
            {
                try
                {
                    var field = (BaseField as WrappedField);
                    if (field == null) // we lost the Wrapped field instance, this is due to the fact that the command was loaded from a save
                    {
                        if (NewValue != null)
                        {
                            var newfield = new WrappedField(BaseField, WrappedField.KspFieldFromBaseField(BaseField));
                            if (newfield.NewValueFromString(NewValueString))
                            {
                                newfield.Invoke();
                            }
                        }
                    }
                    else
                    {
                        // invoke the field value change
                        field.Invoke();
                    }

                    if (UIPartActionController.Instance != null)
                    {
                        UIPartActionController.Instance.UpdateFlight();
                    }

#if !KSP131
                    for (int i = 0; i < f.Vessel.parts.Count; i++)
                    {
                        for (int j = 0; j < f.Vessel.parts[i].Modules.Count; j++)
                        {
                            if (f.Vessel.parts[i].Modules[j] is ModuleRoboticServoPiston)
                            {
                                // stock bug: targetExtension set by player in PartActionMenu is not passed to targetPosition unlike other robotic parts like hinge
                                var agModule = f.Vessel.parts[i].Modules[j] as ModuleRoboticServoPiston;
                                RTUtil.SetInstanceField(typeof(ModuleRoboticServoPiston), agModule, "targetPosition", agModule.targetExtension);
                            }
                        }
                    }
#endif
                }
                catch (Exception invokeException)
                {
                    RTLog.Notify("BaseField InvokeAction() by '{0}' with message: {1}",
                                 RTLogLevel.LVL1, this.BaseField.guiName, invokeException.Message);
                }
            }

            return(false);
        }
Пример #23
0
        // Compatible with ModuleDataTransmitter
        public override void OnLoad(ConfigNode node)
        {
            RTLog.Notify("ModuleRTDataTransmitter::OnLoad");
            foreach (ConfigNode data in node.GetNodes("CommsData"))
            {
                scienceDataQueue.Add(new ScienceData(data));
            }

            var antennas = part.FindModulesImplementing <ModuleRTAntenna>();

            GUIStatus = "Idle";
        }
Пример #24
0
        /// <summary>
        /// Draw the information for the target, set by the setTarget()
        /// </summary>
        public void Draw()
        {
            if (target != null)
            {
                KeyValuePair <string, Color> infos = target.TargetInfos;

                GUILayout.Label(target.TargetEntry.Text, guiHeadline);

                // Split the given informations from the target.targetInfos. Each ; is one row
                var diagnostic = infos.Key.Split(';');
                // Loop the rows
                foreach (var diagnosticTextLines in diagnostic)
                {
                    try
                    {
                        GUILayout.BeginHorizontal();
                        // If the text contains a 'label' so we also split this text into to
                        // seperated text parts
                        if (diagnosticTextLines.Trim().Contains(':'))
                        {
                            var tableString = diagnosticTextLines.Trim().Split(':');
                            // draw the label
                            GUILayout.Label(tableString[0] + ':', guiTableRow, GUILayout.Width(110));
                            // if the label is 'status' so change the textcolor to the color
                            // given by the NetworkFeedback class.
                            if (tableString[0].ToLower() == "status")
                            {
                                guiTableRow.normal.textColor = infos.Value;
                            }
                            // print the value for this row
                            GUILayout.Label(tableString[1], guiTableRow);
                            // restore the text color
                            guiTableRow.normal.textColor = Color.white;
                        }
                        else
                        {
                            // if we do not have a table style information so print the complete text
                            GUILayout.Label(diagnosticTextLines.Trim(), guiTableRow);
                        }
                        GUILayout.EndHorizontal();
                    }
                    catch (Exception ex)
                    {
                        RTLog.Notify("Exception {0}", ex);
                        // I got one exception, thrown from Unity and i don't know how to deal with it

                        // Exception System.ArgumentException: Getting control 4's
                        // position in a group with only 4 controls when doing Repaint
                    }
                }
            }
        }
Пример #25
0
        public static bool RemoveGroundStation(Guid stationid)
        {
            RTLog.Notify("Trying to remove ground station {0}", RTLogLevel.API, stationid);

            // do not allow to remove the default mission control
            if (stationid.ToString("N").Equals("5105f5a9d62841c6ad4b21154e8fc488"))
            {
                RTLog.Notify("Cannot remove KSC Mission Control!", RTLogLevel.API);
                return(false);
            }

            return(RTSettings.Instance.RemoveGroundStation(stationid));
        }
Пример #26
0
        private void RemoveTransmitter()
        {
            RTLog.Notify("ModuleRTAntenna: Remove TRANSMITTER success.");
            if (mTransmitter == null)
            {
                return;
            }

            part.RemoveModule((PartModule)mTransmitter);
            mTransmitter = null;
            // Trigger onVesselWasModified after removing the transmitter
            GameEvents.onVesselWasModified.Fire(this.part.vessel);
        }
Пример #27
0
        /// <summary>Called when there's a vessel switch, switching from `fromVessel` to `toVessel`.</summary>
        /// <param name="fromVessel">The vessel we switch from.</param>
        /// <param name="toVessel">The vessel we're switching to.</param>
        private void OnVesselSwitching(Vessel fromVessel, Vessel toVessel)
        {
            RTLog.Notify("OnVesselSwitching - from: " + (fromVessel != null ? fromVessel.vesselName : "N/A") + " to: " + toVessel.vesselName);

            if (fromVessel != null)
            {
                // remove flight code controls.
                fromVessel.OnFlyByWire -= OnFlyByWirePre;
                fromVessel.OnFlyByWire -= OnFlyByWirePost;
            }

            _flightComputerWindow?.Hide();
        }
Пример #28
0
        protected AddOn(string assemblyName, string assemblyType)
        {
            RTLog.Verbose("Connecting with {0} ...", RTLogLevel.Assembly, assemblyName);

            var loadedAssembly = AssemblyLoader.loadedAssemblies.FirstOrDefault(a => a.assembly.GetName().Name.Equals(assemblyName));

            if (loadedAssembly != null)
            {
                RTLog.Notify("Successfull connected to Assembly {0}", RTLogLevel.Assembly, assemblyName);
                this.assemblyType = loadedAssembly.assembly.GetTypes().FirstOrDefault(t => t.FullName.Equals(assemblyType));

                this.loaded = true;
            }
        }
Пример #29
0
 public void OnDestroy()
 {
     RTLog.Notify("ModuleSPU: OnDestroy");
     GameEvents.onVesselWasModified.Remove(OnVesselModified);
     GameEvents.onPartUndock.Remove(OnPartUndock);
     if (RTCore.Instance != null)
     {
         RTCore.Instance.Satellites.Unregister(mRegisteredId, this);
         mRegisteredId = Guid.Empty;
     }
     if (FlightComputer != null)
     {
         FlightComputer.Dispose();
     }
 }
Пример #30
0
        public void Dispose()
        {
            RTLog.Notify("FlightComputer: Dispose");

            GameEvents.onVesselChange.Remove(OnVesselChange);

            if (Vessel != null)
            {
                Vessel.OnFlyByWire -= OnFlyByWirePre;
                Vessel.OnFlyByWire -= OnFlyByWirePost;
            }
            if (mWindow != null)
            {
                mWindow.Hide();
            }
        }