Example #1
0
 public void UnregisterCrew(ProtoCrewMember astronaut)
 {
     if (crewData.Contains(astronaut.name))
     {
         crewData.Remove(astronaut.name);
     }
 }
 public void addAnomaly(DMAnomalyObject anom)
 {
     if (!anomalies.Contains(anom.Name))
     {
         anomalies.Add(anom.Name, anom);
     }
 }
Example #3
0
 public static void addAnomalyStorage(string body, DMAnomalyStorage anom)
 {
     if (!anomalies.Contains(body))
     {
         anomalies.Add(body, anom);
     }
 }
Example #4
0
        private void LateUpdate()
        {
            if (!FlightGlobals.ready)
            {
                return;
            }

            if (FlightGlobals.ActiveVessel == null)
            {
                return;
            }

            if (FlightGlobals.ActiveVessel.isEVA)
            {
                return;
            }

            if (reload)
            {
                reload = false;

                var crew = KerbalPortraitGallery.Instance.Portraits;

                for (int i = 0; i < crew.Count; i++)
                {
                    KerbalPortrait p = crew[i];

                    if (p == null)
                    {
                        continue;
                    }

                    Kerbal k = p.crewMember;

                    if (k == null)
                    {
                        return;
                    }

                    if (currentCrew.Contains(p.crewMemberName))
                    {
                        continue;
                    }

                    if (k.state == Kerbal.States.DEAD)
                    {
                        continue;
                    }

                    KerbalTrait K = new KerbalTrait(k, p);

                    if (K == null)
                    {
                        continue;
                    }

                    currentCrew.Add(p.crewMemberName, K);
                }
            }
        }
        public void updateVessel(Vessel v)
        {
            List <SEP_ExperimentHandler> modules =
                (from mod in v.FindPartModulesImplementing <ModuleSEPScienceExperiment>()
                 where mod.Handler != null
                 select mod.Handler).ToList();

            if (experiments.Contains(v))
            {
                if (modules.Count > 0)
                {
                    experiments[v] = modules;
                }
                else
                {
                    experiments.Remove(v);
                    SEP_AppLauncher.Instance.removeVesselSection(v);
                }
            }
            else if (modules.Count > 0)
            {
                if (VesselUtilities.VesselHasModuleName("ModuleSEPStation", v))
                {
                    experiments.Add(v, modules);
                    SEP_AppLauncher.Instance.addVesselSection(v);
                }
            }
        }
        public SEP_VesselSection getVesselSection(Vessel v)
        {
            if (vessels.Contains(v.id))
            {
                return(vessels[v.id]);
            }

            return(null);
        }
Example #7
0
 /// <summary>
 /// Other mods need to call this to start processing a ProtoVessel.
 /// Will write this into an API in future version.
 /// </summary>
 /// <param name="vessel"></param>
 public void AddInterestedVessel(ProtoVessel vessel)
 {
     if (!InterestedVessels.Contains(vessel))
     {
         InterestedVessel iVessel = new InterestedVessel(vessel.vesselRef, vessel);
         InterestedVessels.Add(vessel, iVessel);
         CacheResources.CreatecachedVesselResources(vessel);
     }
 }
Example #8
0
        public static void addPointOfInterest(ProgressNode n, string d, string name, string note, string r = "")
        {
            if (pointsOfInterest.Contains(name))
            {
                return;
            }

            progressStandard s = new progressStandard(null, ProgressType.POINTOFINTEREST, n, d, note, r);

            pointsOfInterest.Add(name, s);
        }
        public static contractContainer getFailedContract(Guid id, bool warn = false)
        {
            if (failedContracts.Contains(id))
            {
                return(failedContracts[id]);
            }
            else if (warn)
            {
                Debug.Log(string.Format("[Contract Parser] No Failed Contract Of ID: [{0}] Found", id));
            }

            return(null);
        }
        private void removeWaypoint(Vessel v)
        {
            if (wps.Contains(v))
            {
                Waypoint wp = wps[v];

                WaypointManager.RemoveWaypoint(wp);

                wps.Remove(v);
            }

            if (wps.Count <= 0)
            {
                waypointsOn = false;
            }
        }
Example #11
0
        public static void Add <T>(PartModule mod) where T : ModuleForces
        {
            if (ModuleDict.Contains(mod))
            {
                /* already with forces */
                return;
            }
            /* cloning might have created ModuleForces already, but is not yet in the dict */
            T mf;

            T[] mfList = mod.gameObject.GetComponents <T> ();
            for (int i = mfList.Length - 1; i >= 0; i--)
            {
                mf = mfList [i];
                if (mf.module == mod)
                {
                    return;
                }
            }
            /* add a new ModuleForces */
            mf        = mod.gameObject.AddComponent <T> ();
            mf.module = mod;
#if DEBUG
            Debug.Log(string.Format("[RCSBA, ModuleForces]: Adding {1} to {0}.", mod.part.name, typeof(T).Name));
#endif
        }
Example #12
0
        private static void addProgressInterval(ProgressType p, ProgressNode n, string d, string t, string u)
        {
            if (n == null)
            {
                return;
            }

            if (intervalNodes.Contains(n.Id))
            {
                return;
            }

            progressInterval i = null;

            switch (p)
            {
            case ProgressType.ALTITUDERECORD:
                i        = new progressInterval(ProgressType.ALTITUDERECORD, n, ((RecordsAltitude)n).record, getMaxAltitudeRecord, 500, ContractDefs.Progression.RecordSplit, d, t, u);
                altitude = i;
                break;

            case ProgressType.DEPTHRECORD:
                i     = new progressInterval(ProgressType.DEPTHRECORD, n, ((RecordsDepth)n).record, ContractDefs.Progression.MaxDepthRecord, 10, ContractDefs.Progression.RecordSplit, d, t, u);
                depth = i;
                break;

            case ProgressType.DISTANCERECORD:
                i        = new progressInterval(ProgressType.DISTANCERECORD, n, ((RecordsDistance)n).record, ContractDefs.Progression.MaxDistanceRecord, 1000, ContractDefs.Progression.RecordSplit, d, t, u);
                distance = i;
                break;

            case ProgressType.SPEEDRECORD:
                i     = new progressInterval(ProgressType.SPEEDRECORD, n, ((RecordsSpeed)n).record, ContractDefs.Progression.MaxSpeedRecord, 5, ContractDefs.Progression.RecordSplit, d, t, u);
                speed = i;
                break;

            default:
                return;
            }

            if (i == null)
            {
                return;
            }

            intervalNodes.Add(n.Id, i);
        }
Example #13
0
        private static void addProgressStandard(ProgressType p, ProgressNode n, string id = "", string d = "", string g = "", string r = "")
        {
            if (n == null)
            {
                return;
            }

            if (standardNodes.Contains(n.Id))
            {
                return;
            }

            progressStandard s = null;

            switch (p)
            {
            case ProgressType.CREWRECOVERY:
                s            = new progressStandard(null, ProgressType.CREWRECOVERY, n, d, g, r);
                crewRecovery = s;
                standardNodes.Add(n.Id, s);
                break;

            case ProgressType.FIRSTLAUNCH:
                s           = new progressStandard(null, ProgressType.FIRSTLAUNCH, n, d, r);
                firstLaunch = s;
                standardNodes.Add(n.Id, s);
                break;

            case ProgressType.REACHSPACE:
                s          = new progressStandard(null, ProgressType.REACHSPACE, n, d, g, r);
                reachSpace = s;
                standardNodes.Add(n.Id, s);
                break;

            case ProgressType.STUNT:
                addStunt(n, d, id, g, r);
                break;

            case ProgressType.POINTOFINTEREST:
                addPointOfInterest(n, d, id, g, r);
                break;

            default:
                return;
            }
        }
Example #14
0
 private void StageDestroy(StageGroup group)
 {
     if (panels.Contains(group))
     {
         panels[group].Destroy();
         panels[group] = null;
         panels.Remove(group);
     }
 }
Example #15
0
        public static void addBodySubTree(CelestialBodySubtree body)
        {
            if (body == null)
            {
                return;
            }

            if (body.Body == null)
            {
                return;
            }

            if (bodySubTrees.Contains(body.Body.displayName.LocalizeBodyName()))
            {
                return;
            }

            bodySubTrees.Add(body.Body.displayName.LocalizeBodyName(), new progressBodyCollection(body));
        }
        private void addVessel(Vessel v)
        {
            if (!suitableVessels.Contains(v.id))
            {
                suitableVessels.Add(v.id, v);
            }
            else
            {
                DMUtils.Logging("Vessel: [{0}] Already Included In DM Part Request List", v.name);
            }

            if (!useWaypoints)
            {
                return;
            }

            if (HighLogic.LoadedSceneIsFlight || HighLogic.LoadedScene == GameScenes.TRACKSTATION)
            {
                if (!wps.Contains(v))
                {
                    wps.Add(v, setupNewWaypoint(v));
                }
            }
        }
        public static void loadAntennaParts()
        {
            antennaModulesLoaded = true;

            for (int i = PartLoader.LoadedPartsList.Count - 1; i >= 0; i--)
            {
                AvailablePart part = PartLoader.LoadedPartsList[i];

                if (part == null)
                {
                    continue;
                }

                if (part.partPrefab == null)
                {
                    continue;
                }

                for (int j = part.partPrefab.Modules.Count - 1; j >= 0; j--)
                {
                    PartModule mod = part.partPrefab.Modules[j];

                    if (mod == null)
                    {
                        continue;
                    }

                    if (!mod.IsValidContractObjective("Antenna"))
                    {
                        continue;
                    }

                    //log("Logging Antenna Module: {0}", logLevels.log, part.title);

                    AntennaModules.Add(mod);

                    if (!AntennaParts.Contains(part.name))
                    {
                        AntennaParts.Add(part.name, part);
                    }
                }
            }
        }
        private void populateExperiments()
        {
            experiments = new DictionaryValueList <Vessel, List <SEP_ExperimentHandler> >();

            int l = FlightGlobals.Vessels.Count;

            for (int i = 0; i < l; i++)
            {
                Vessel v = FlightGlobals.Vessels[i];

                if (v == null)
                {
                    continue;
                }

                if (v.vesselType == VesselType.Debris)
                {
                    continue;
                }

                if (experiments.Contains(v))
                {
                    continue;
                }

                List <SEP_ExperimentHandler> handlers = new List <SEP_ExperimentHandler>();

                if (v.loaded)
                {
                    handlers =
                        (from mod in v.FindPartModulesImplementing <ModuleSEPScienceExperiment>()
                         where mod.Handler != null && mod.IsDeployed
                         select mod.Handler).ToList();
                }
                else
                {
                    var snaps = v.protoVessel.protoPartSnapshots;

                    int s = snaps.Count;

                    for (int j = 0; j < s; j++)
                    {
                        ProtoPartSnapshot p = snaps[j];

                        if (!p.modules.Any(m => m.moduleName == "ModuleSEPScienceExperiment"))
                        {
                            continue;
                        }

                        var mods = p.modules;

                        int d = mods.Count;

                        for (int k = 0; k < d; k++)
                        {
                            ProtoPartModuleSnapshot mod = mods[k];

                            if (mod.moduleName != "ModuleSEPScienceExperiment")
                            {
                                continue;
                            }

                            if (!mod.moduleValues.HasValue("IsDeployed") || mod.moduleValues.GetValue("IsDeployed") != "True")
                            {
                                continue;
                            }

                            SEP_ExperimentHandler handler = new SEP_ExperimentHandler(mod, v);

                            if (handler.loaded)
                            {
                                handlers.Add(handler);
                            }
                        }
                    }
                }

                if (handlers.Count > 0)
                {
                    if (VesselUtilities.VesselHasModuleName("ModuleSEPStation", v))
                    {
                        experiments.Add(v, handlers);
                    }
                }
            }

            setup = true;
        }
Example #19
0
        protected override void OnLoad(ConfigNode node)
        {
            TargetBody = node.parse("Body", (CelestialBody)null);
            if (TargetBody == null)
            {
                DMUtils.Logging("Failed To Load Target Body; DM Part Request Parameter Removed");
                this.Unregister();
                this.Parent.RemoveParameter(this);
                return;
            }

            if (Root.GetType() == typeof(DMReconContract))
            {
                useWaypoints = DMContractDefs.DMRecon.useVesselWaypoints;
            }
            else if (Root.GetType() == typeof(DMMagneticSurveyContract))
            {
                useWaypoints = DMContractDefs.DMMagnetic.useVesselWaypoints;
            }
            else
            {
                useWaypoints = false;
            }

            string parts = node.parse("Requested_Parts", "");

            if (string.IsNullOrEmpty(parts))
            {
                DMUtils.Logging("Failed To Required Parts List; DM Part Request Parameter Removed");
                this.Unregister();
                this.Parent.RemoveParameter(this);
                return;
            }

            requiredParts = DMUtils.stringSplit(parts);

            getPartTitles();

            vesselNames = node.parse("Vessels", "");

            if (!HighLogic.LoadedSceneIsEditor && this.Root.ContractState == Contract.State.Active)
            {
                if (!string.IsNullOrEmpty(vesselNames))
                {
                    List <Guid> ids = node.parse("Vessels", new List <Guid>());
                    if (ids.Count > 0)
                    {
                        foreach (Guid id in ids)
                        {
                            try
                            {
                                Vessel V = FlightGlobals.Vessels.FirstOrDefault(v => v.id == id);
                                addVessel(V);
                                DMUtils.DebugLog("Vessel {0} Loaded", V.vesselName);
                            }
                            catch
                            {
                                DMUtils.Logging("Failed To Load Vessel; DM Part Request Parameter Reset");
                                if (HighLogic.LoadedSceneIsFlight)
                                {
                                    DMUtils.Logging("Checking If Currently Loaded Vessel Is Appropriate");
                                    if (vesselEquipped(FlightGlobals.ActiveVessel))
                                    {
                                        addVessel(FlightGlobals.ActiveVessel);
                                    }
                                }
                            }
                        }
                    }
                }
                else
                {
                    for (int i = 0; i < FlightGlobals.Vessels.Count; i++)
                    {
                        Vessel V = FlightGlobals.Vessels[i];

                        if (V == null)
                        {
                            continue;
                        }

                        if (V.mainBody == null)
                        {
                            continue;
                        }

                        if (V.mainBody != TargetBody)
                        {
                            continue;
                        }

                        if (!vesselEquipped(V))
                        {
                            continue;
                        }

                        if (!suitableVessels.Contains(V.id))
                        {
                            addVessel(V);
                        }
                    }
                }
            }

            this.disableOnStateChange = false;
        }
        //Convert all of our saved strings into the appropriate arrays for each game scene
        public override void OnLoad(ConfigNode node)
        {
            instance = this;

            try
            {
                //The first step is manually checking for active contracts from the Game ConfigNode (ie persistent.sfs file); the count of active contracts will be used later when the window is loading
                ConfigNode gameNode = HighLogic.CurrentGame.config;
                if (gameNode != null)
                {
                    ConfigNode contractSystemNode = gameNode.GetNodes("SCENARIO").FirstOrDefault(c => c.GetValue("name") == "ContractSystem");
                    if (contractSystemNode != null)
                    {
                        ConfigNode cNode = contractSystemNode.GetNode("CONTRACTS");
                        if (cNode != null)
                        {
                            foreach (ConfigNode C in cNode.GetNodes("CONTRACT"))
                            {
                                if (C == null)
                                {
                                    continue;
                                }

                                if (C.HasValue("autoAccept"))
                                {
                                    if (C.GetValue("autoAccept") == "True")
                                    {
                                        continue;
                                    }
                                }

                                if (C.HasValue("state"))
                                {
                                    if (C.GetValue("state") == "Active")
                                    {
                                        contractCount++;
                                    }
                                }
                            }
                        }
                        else
                        {
                            DMC_MBE.LogFormatted("Contract System Can't Be Checked... Node Invalid");
                        }
                    }
                }

                ConfigNode scenes = node.GetNode("Contracts_Window_Parameters");
                if (scenes != null)
                {
                    windowPos     = stringSplit(scenes.GetValue("WindowPosition"));
                    windowVisible = stringSplitBool(scenes.GetValue("WindowVisible"));
                    int[] winPos = new int[4] {
                        windowPos[4 * currentScene(HighLogic.LoadedScene)], windowPos[(4 * currentScene(HighLogic.LoadedScene)) + 1], windowPos[(4 * currentScene(HighLogic.LoadedScene)) + 2], windowPos[(4 * currentScene(HighLogic.LoadedScene)) + 3]
                    };

                    //All saved contract missions are loaded here
                    //Each mission has a separate contract list
                    foreach (ConfigNode m in scenes.GetNodes("Contracts_Window_Mission"))
                    {
                        if (m == null)
                        {
                            continue;
                        }

                        string name;
                        string activeString = "";
                        string hiddenString = "";
                        string vesselString = "";
                        bool   ascending, showActive;
                        int    sortMode;
                        bool   master = false;

                        if (m.HasValue("MissionName"))
                        {
                            name = m.GetValue("MissionName");
                        }
                        else
                        {
                            continue;
                        }

                        if (name == "MasterMission")
                        {
                            master = true;
                        }

                        if (m.HasValue("ActiveListID"))
                        {
                            activeString = m.GetValue("ActiveListID");
                        }
                        if (m.HasValue("HiddenListID"))
                        {
                            hiddenString = m.GetValue("HiddenListID");
                        }
                        if (m.HasValue("VesselIDs"))
                        {
                            vesselString = m.GetValue("VesselIDs");
                        }

                        if (!bool.TryParse(m.GetValue("AscendingSort"), out ascending))
                        {
                            ascending = true;
                        }
                        if (!bool.TryParse(m.GetValue("ShowActiveList"), out showActive))
                        {
                            showActive = true;
                        }
                        if (!int.TryParse(m.GetValue("SortMode"), out sortMode))
                        {
                            sortMode = 0;
                        }

                        contractMission mission = new contractMission(name, activeString, hiddenString, vesselString, ascending, showActive, sortMode, master);

                        if (master)
                        {
                            masterMission = mission;
                            DMC_MBE.LogFormatted_DebugOnly("Setting Master Mission During Load");
                        }

                        if (!missionList.Contains(name))
                        {
                            missionList.Add(name, mission);
                        }
                    }
                    loadWindow(winPos);
                }
            }
            catch (Exception e)
            {
                DMC_MBE.LogFormatted("Contracts Window Settings Cannot Be Loaded: {0}", e);
            }
        }
        public void addProgressStandard(ProgressType p, CelestialBody b, ProgressNode n, string d = "", string g = "", string r = "")
        {
            if (n == null)
            {
                return;
            }

            if (bodyNodes.Contains(n.Id))
            {
                return;
            }

            progressStandard s = null;

            switch (p)
            {
            case ProgressType.FLYBYRETURN:
                s           = new progressStandard(b, ProgressType.FLYBYRETURN, n, d, g, r);
                flybyReturn = s;
                break;

            case ProgressType.LANDINGRETURN:
                s             = new progressStandard(b, ProgressType.LANDINGRETURN, n, d, g, r);
                landingReturn = s;
                break;

            case ProgressType.ORBITRETURN:
                s           = new progressStandard(b, ProgressType.ORBITRETURN, n, d, g, r);
                orbitReturn = s;
                break;

            case ProgressType.BASECONSTRUCTION:
                s             = new progressStandard(b, ProgressType.BASECONSTRUCTION, n, d, g, r);
                baseConstruct = s;
                break;

            case ProgressType.CREWTRANSFER:
                s        = new progressStandard(b, ProgressType.CREWTRANSFER, n, d, g, r);
                transfer = s;
                break;

            case ProgressType.DOCKING:
                s       = new progressStandard(b, ProgressType.DOCKING, n, d, g, r);
                docking = s;
                break;

            case ProgressType.ESCAPE:
                s      = new progressStandard(b, ProgressType.ESCAPE, n, d, g, r);
                escape = s;
                break;

            case ProgressType.FLAGPLANT:
                s    = new progressStandard(b, ProgressType.FLAGPLANT, n, d, g, r);
                flag = s;
                break;

            case ProgressType.FLIGHT:
                s      = new progressStandard(b, ProgressType.FLIGHT, n, d, g, r);
                flight = s;
                break;

            case ProgressType.FLYBY:
                s     = new progressStandard(b, ProgressType.FLYBY, n, d, g, r);
                flyby = s;
                break;

            case ProgressType.LANDING:
                s       = new progressStandard(b, ProgressType.LANDING, n, d, g, r);
                landing = s;
                break;

            case ProgressType.ORBIT:
                s     = new progressStandard(b, ProgressType.ORBIT, n, d, g, r);
                orbit = s;
                break;

            case ProgressType.RENDEZVOUS:
                s          = new progressStandard(b, ProgressType.RENDEZVOUS, n, d, g, r);
                rendezvous = s;
                break;

            case ProgressType.SCIENCE:
                s       = new progressStandard(b, ProgressType.SCIENCE, n, d, g, r);
                science = s;
                break;

            case ProgressType.SPACEWALK:
                s         = new progressStandard(b, ProgressType.SPACEWALK, n, d, g, r);
                spacewalk = s;
                break;

            case ProgressType.SPLASHDOWN:
                s          = new progressStandard(b, ProgressType.SPLASHDOWN, n, d, g, r);
                splashdown = s;
                break;

            case ProgressType.STATIONCONSTRUCTION:
                s       = new progressStandard(b, ProgressType.STATIONCONSTRUCTION, n, d, g, r);
                station = s;
                break;

            case ProgressType.SUBORBIT:
                s        = new progressStandard(b, ProgressType.SUBORBIT, n, d, g, r);
                suborbit = s;
                break;

            case ProgressType.SURFACEEVA:
                s          = new progressStandard(b, ProgressType.SURFACEEVA, n, d, g, r);
                surfaceEVA = s;
                break;

            default:
                return;
            }

            if (s == null)
            {
                return;
            }

            bodyNodes.Add(n.Id, s);
        }