示例#1
0
        /*************************************************************************************************************************/
        public void fill_Vessels_list()
        {
#if DEBUG
            // if (Debug_Level_1_Active)
            Log.PushStackInfo("FMRS_Core.fill_Vessels_list", "entering fill_Vessels_list()");
#endif

            foreach (Vessel temp_vessel in FlightGlobals.Vessels)
            {
                if (!Vessels.Contains(temp_vessel.id))
                {
                    Vessels.Add(temp_vessel.id);
#if DEBUG
                    if (Debug_Active)
                    {
                        Log.Info("" + temp_vessel.vesselName + " Found");
                    }
#endif
                }
            }
#if DEBUG
            // if (Debug_Level_1_Active)
            Log.PopStackInfo("leaving fill_Vessels_list()");
#endif
        }
示例#2
0
        static Constants()
        {
            var    min_capacity = 30;
            var    max_capacity = 150;
            var    speed        = 100;
            Random r            = new Random();
            var    shipCount    = 10;

            for (int i = 0; i < shipCount; i++)
            {
                var shipname = "Ship" + i.ToString();

                var capacity = r.Next(min_capacity, max_capacity);
                Vessels.Add(new VesselConfig(shipname, capacity, speed));
            }
            var currentPortId = 0;
            var portCount     = PortIds.Count;

            for (int i = 0; i < shipCount; i++)
            {
                var shipname = "Ship" + i.ToString();
                if (portCount == currentPortId)
                {
                    currentPortId = 0;
                }
                PortIds[currentPortId].startingVessels.Add(shipname);
            }
            //or load configuration from files.
        }
示例#3
0
        /// <summary>
        /// Load all vessels from KML Tree.
        /// </summary>
        /// <param name="master">The GuiTreeManager that manages the loaded tree</param>
        public void Load(GuiTreeManager master)
        {
            Vessels.Clear();
            VesselsList.Items.Clear();
            VesselsDetails.Children.Clear();

            List <KmlVessel> list = master.GetFlatList <KmlVessel>();

            foreach (KmlVessel vessel in list)
            {
                if (vessel.Origin == KmlVessel.VesselOrigin.Flightstate)
                {
                    Vessels.Add(vessel);
                }
            }

            // Sort the list
            Vessels = Vessels.OrderBy(x => x.Name).ToList();

            foreach (KmlVessel vessel in Vessels)
            {
                GuiVesselsNode node = new GuiVesselsNode(vessel);
                node.MouseDoubleClick += VesselsNode_MouseDoubleClick;
                VesselsList.Items.Add(node);
            }

            // Apply current filter and count visible items
            UpdateVisibility();
        }
示例#4
0
 public void SubscribeAddVessel()
 {
     MessagingCenter.Subscribe <AddVesselPageViewModel, Vessel>(this, "addVessel", (s, param) =>
     {
         Vessels.Add(param);
         SetVesselBackground();
     });
 }
示例#5
0
        /*************************************************************************************************************************/
        public void main_vessel_changed(string save_file)
        {
#if DEBUG
            // if (Debug_Level_1_Active)
            Log.PushStackInfo("FMRS_Core.main_vessel_changed", "enter main_vessel_changed(string save_file) " + save_file);
            if (Debug_Active)
            {
                Log.Info("switching main vessel");
            }
#endif
            ProtoVessel temp_proto;
            Game        loadgame = GamePersistence.LoadGame(save_file, HighLogic.SaveFolder + "/FMRS", false, false);

            if (loadgame != null && loadgame.compatible && loadgame.flightState != null)
            {
                temp_proto = loadgame.flightState.protoVessels.Find(p => p.vesselID == _SAVE_Main_Vessel);
                if (temp_proto != null)
                {
                    if (Vessels_dropped.ContainsKey(temp_proto.vesselID))
                    {
                        delete_dropped_vessel(temp_proto.vesselID);
                    }

                    Vessels_dropped.Add(temp_proto.vesselID, quicksave_file_name);
                    Vessels_dropped_names.Add(temp_proto.vesselID, temp_proto.vesselName);
                    Vessels.Add(temp_proto.vesselID);
                }
#if DEBUG
                else
                if (Debug_Active)
                {
                    Log.Info("main vessel not found");
                }
#endif

                if (Vessels_dropped.ContainsKey(FlightGlobals.ActiveVessel.id))
                {
                    delete_dropped_vessel(FlightGlobals.ActiveVessel.id);
                }

                _SAVE_Main_Vessel = FlightGlobals.ActiveVessel.id;
            }
#if DEBUG
            else
            if (Debug_Active)
            {
                Log.Info("unable to load savefile");
            }

            // if (Debug_Level_1_Active)
            Log.PopStackInfo("leaving main_vessel_changed(string save_file)");
#endif
        }
示例#6
0
        void GetVessels()
        {
            var r = App.Database.GetItemsAsync().Result;

            if (r != null)
            {
                foreach (var item in r)
                {
                    Vessels.Add(item);
                }
                SetVesselBackground();
            }
        }
示例#7
0
        /*************************************************************************************************************************/
        public void fill_Vessels_list()
        {
            Log.PushStackInfo("FMRS_Core.fill_Vessels_list", "entering fill_Vessels_list()");

            foreach (Vessel temp_vessel in FlightGlobals.Vessels)
            {
                if (!Vessels.Contains(temp_vessel.id))
                {
                    Vessels.Add(temp_vessel.id);
                    Log.dbg("{0} Found", temp_vessel.vesselName);
                }
            }

            Log.PopStackInfo("leaving fill_Vessels_list()");
        }
示例#8
0
        /*************************************************************************************************************************/
        public bool search_for_new_vessels(string save_file_name)
        {
            bool new_vessel_found = false, controllable = false;

            Log.PushStackInfo("FMRS_Core.search_for_new_vessels(string)", "entering search_for_new_vessels(string save_file_name) {0}", save_file_name);

            foreach (Vessel temp_vessel in FlightGlobals.Vessels)
            {
                controllable = false;

                //Check if the stage was claimed by another mod or by this mod
                string controllingMod = RecoveryControllerWrapper.ControllingMod(temp_vessel);

                bool FMRSIsControllingMod = false;
                if (controllingMod != null)
                {
                    Log.info("RecoveryControllerWrapper.ControllingMod for vessel: {0} : {1}", temp_vessel.name, controllingMod);

                    FMRSIsControllingMod = string.Equals(controllingMod, "FMRS", StringComparison.OrdinalIgnoreCase);
                }

                if (controllingMod == null ||
                    string.Equals(controllingMod, "auto", StringComparison.OrdinalIgnoreCase) ||
                    FMRSIsControllingMod)
                {
                    if (!Vessels.Contains(temp_vessel.id))
                    {
                        if (FMRSIsControllingMod ||
                            (
                                ((temp_vessel.isCommandable && temp_vessel.IsControllable) || (_SETTING_Control_Uncontrollable && controllingMod == null)) &&
                                temp_vessel.vesselType != VesselType.EVA &&
                                temp_vessel.vesselType != VesselType.Flag &&
                                temp_vessel.vesselType != VesselType.SpaceObject &&
                                temp_vessel.vesselType != VesselType.Unknown
                            )
                            )
                        {
                            controllable = true;
                        }
                        else
                        {
                            foreach (ProtoPartSnapshot proto_part in temp_vessel.protoVessel.protoPartSnapshots)
                            {
                                List <ProtoPartModuleSnapshot> proto_modules = proto_part.modules;
                                ProtoPartModuleSnapshot        module        = null;

                                if (proto_modules != null &&
                                    (_SETTING_Parachutes &&
                                     ((controllingMod != null && string.Equals(controllingMod, "FMRS", StringComparison.OrdinalIgnoreCase)) ||
                                      !_SETTING_Defer_Parachutes_to_StageRecovery ||
                                      !stageRecoveryInstalled)
                                    )
                                    )
                                {
                                    //
                                    module = proto_part.modules.Find(p => p.moduleName == "RealChuteModule" ||
                                                                     p.moduleName == "ModuleParachute" ||
                                                                     p.moduleName == "ModuleKrKerbalParachute" ||
                                                                     p.moduleName == "RealChuteFAR");
                                    if (module != null)
                                    {
                                        controllable = true;
                                    }
                                }

                                if (proto_part.protoCrewNames.Count > 0)
                                {
                                    controllable = true;
                                }
                            }
                        }
                        foreach (Part p in temp_vessel.Parts)
                        {
                            foreach (PartModule pm in p.Modules)
                            {
                                if (pm.moduleName == "FMRS_PM")
                                {
                                    if ((pm as FMRS_PM).parent_vessel != "00000000-0000-0000-0000-000000000000")
                                    {
                                        controllable = false;
                                        break;
                                    }
                                }
                            }
                            break;
                        }

                        if (controllable)
                        {
                            Log.dbg("{0} Found and will be added to the dicts", temp_vessel.vesselName);

                            Vessels_dropped.Add(temp_vessel.id, save_file_name);
                            Vessels_dropped_names.Add(temp_vessel.id, temp_vessel.vesselName);
                            Vessel_State.Add(temp_vessel.id, vesselstate.FLY);
                            foreach (Part p in temp_vessel.Parts)
                            {
                                foreach (PartModule pm in p.Modules)
                                {
                                    if (pm.moduleName == "FMRS_PM")
                                    {
                                        pm.StartCoroutine("setid");
                                    }
                                }
                            }

                            foreach (ProtoPartSnapshot part_snapshot in temp_vessel.protoVessel.protoPartSnapshots)
                            {
                                foreach (ProtoCrewMember member in part_snapshot.protoModuleCrew)
                                {
                                    if (!Kerbal_dropped.ContainsKey(member.name))
                                    {
                                        Kerbal_dropped.Add(member.name, temp_vessel.id);
                                    }
                                }
                            }
                            new_vessel_found = true;
                        }
                        Vessels.Add(temp_vessel.id);
                    }
                }
            }

            Log.PopStackInfo("leaving search_for_new_vessels(string save_file_name)");

            return(new_vessel_found);
        }
示例#9
0
        /*************************************************************************************************************************/
        public bool search_for_new_vessels(string save_file_name)
        {
            bool new_vessel_found = false, controllable = false;

#if DEBUG
            // if (Debug_Level_1_Active)
            Log.PushStackInfo("FMRS_Core.search_for_new_vessels(string)", "entering search_for_new_vessels(string save_file_name) " + save_file_name);
#endif
            foreach (Vessel temp_vessel in FlightGlobals.Vessels)
            {
                controllable = false;

                if (!Vessels.Contains(temp_vessel.id))
                {
                    if (temp_vessel.isCommandable &&
                        temp_vessel.IsControllable &&
                        temp_vessel.vesselType != VesselType.EVA &&
                        temp_vessel.vesselType != VesselType.Flag &&
                        temp_vessel.vesselType != VesselType.SpaceObject &&
                        temp_vessel.vesselType != VesselType.Unknown)
                    {
                        controllable = true;
                    }
                    else
                    {
                        foreach (ProtoPartSnapshot proto_part in temp_vessel.protoVessel.protoPartSnapshots)
                        {
                            List <ProtoPartModuleSnapshot> proto_modules = proto_part.modules;
                            ProtoPartModuleSnapshot        module        = null;

                            if (proto_modules != null && (_SETTING_Parachutes && (!_SETTING_Defer_Parachutes_to_StageRecovery || !stageRecoveryInstalled)))
                            {
                                //
                                module = proto_part.modules.Find(p => p.moduleName == "RealChuteModule" ||
                                                                 p.moduleName == "ModuleParachute" ||
                                                                 p.moduleName == "ModuleKrKerbalParachute" ||
                                                                 p.moduleName == "RealChuteFAR");
                                if (module != null)
                                {
                                    controllable = true;
                                }
                            }

                            if (proto_part.protoCrewNames.Count > 0)
                            {
                                controllable = true;
                            }
                        }
                    }
                    foreach (Part p in temp_vessel.Parts)
                    {
                        foreach (PartModule pm in p.Modules)
                        {
                            if (pm.moduleName == "FMRS_PM")
                            {
                                if ((pm as FMRS_PM).parent_vessel != "00000000-0000-0000-0000-000000000000")
                                {
                                    controllable = false;
                                    break;
                                }
                            }
                        }
                        break;
                    }

                    if (controllable)
                    {
#if DEBUG
                        if (Debug_Active)
                        {
                            Log.Info("" + temp_vessel.vesselName + " Found and will be added to the dicts");
                        }
#endif

                        Vessels_dropped.Add(temp_vessel.id, save_file_name);
                        Vessels_dropped_names.Add(temp_vessel.id, temp_vessel.vesselName);
                        Vessel_State.Add(temp_vessel.id, vesselstate.FLY);
                        foreach (Part p in temp_vessel.Parts)
                        {
                            foreach (PartModule pm in p.Modules)
                            {
                                if (pm.moduleName == "FMRS_PM")
                                {
                                    pm.StartCoroutine("setid");
                                }
                            }
                        }

                        foreach (ProtoPartSnapshot part_snapshot in temp_vessel.protoVessel.protoPartSnapshots)
                        {
                            foreach (ProtoCrewMember member in part_snapshot.protoModuleCrew)
                            {
                                if (!Kerbal_dropped.ContainsKey(member.name))
                                {
                                    Kerbal_dropped.Add(member.name, temp_vessel.id);
                                }
                            }
                        }
                        new_vessel_found = true;
                    }
                    Vessels.Add(temp_vessel.id);
                }
            }
#if DEBUG
            // if (Debug_Level_1_Active)
            Log.PopStackInfo("leaving search_for_new_vessels(string save_file_name)");
#endif
            return(new_vessel_found);
        }