コード例 #1
0
        public bool IsFiltered(Func <TFilter, bool> predicate)
        {
            if ((!IncludeFilters.Any() || IncludeFilters.Any(predicate)) && !ExcludeFilters.Any(predicate))
            {
                return(false);
            }

            ++Count;
            return(true);
        }
コード例 #2
0
        public override bool Deploy()
        {
            if (!Available || !IsReadyOnboard)
            {
                return(false);
            }
            if (FlightGlobals.ActiveVessel == null)
            {
                return(false);
            }

            if (!FlightGlobals.ActiveVessel.isEVA)
            {
                if (FlightGlobals.getStaticPressure() > Settings.Instance.EvaAtmospherePressureWarnThreshold)
                {
                    if (FlightGlobals.ActiveVessel.GetSrfVelocity().magnitude > Settings.Instance.EvaAtmosphereVelocityWarnThreshold)
                    {
                        DialogGUIBase[] options = new DialogGUIBase[2]
                        {
                            new DialogGUIButton("Science is worth a little risk", OnConfirmEva),
                            new DialogGUIButton("No, it would be a PR nightmare", null)
                        };

                        var multiOptionDialog = new MultiOptionDialog(
                            "It looks dangerous out there. Are you sure you want to send someone out? They might lose their grip!",
                            "It looks dangerous out there. Are you sure you want to send someone out? They might lose their grip!",
                            "Dangerous Condition Alert",
                            HighLogic.UISkin, options);
                        PopupDialog.SpawnPopupDialog(multiOptionDialog, false, HighLogic.UISkin);
                        return(true);
                    }
                }
                return(ExpelCrewman());
            }

            var evas = FlightGlobals.ActiveVessel.FindPartModulesImplementing <ModuleScienceExperiment>();

            for (int i = evas.Count - 1; i >= 0; i--)
            {
                ModuleScienceExperiment exp = evas[i];
                if (!exp.Deployed && exp.experimentID == experiment.id && !ExcludeFilters.IsExcluded(exp))
                {
                    //exp.DeployExperiment();
                    if (!(DMagicFactory.DMagic_IsInstalled && DMagicFactory.RunExperiment(experiment.id, exp)) &&
                        !(DMagicFactory.DMagicScienceAnimateGeneric_IsInstalled && DMagicFactory.RunSciAnimGenExperiment(experiment.id, exp)))
                    {
                        exp.DeployExperiment();
                    }
                    break;
                }
            }
            return(true);
        }
コード例 #3
0
        /// <summary>
        /// Applies the filters to the a given source list
        /// </summary>
        /// <param name="sourceList">The source list</param>
        public IList <TItem> ApplyFilters(IList <TItem> sourceList)
        {
            IList <TItem> result = IncludeFilters.Any()
                ? sourceList.Where(a => IncludeFilters.All(f => f.Invoke(a)))
                                   .Except(sourceList.Where(a => ExcludeFilters.Any(f => f.Invoke(a))))
                                   .ToList()
                : new List <TItem>();

            return(result
                   .Concat(IncludedItems)
                   .Except(ExcludedItems)
                   .ToList());
        }
コード例 #4
0
        public virtual void Rescan()
        {
            modules = new ScienceModuleList();
            if (FlightGlobals.ActiveVessel == null)
            {
                return;
            }

            ScienceModuleList potentials = FlightGlobals.ActiveVessel
                                           .FindPartModulesImplementing <ModuleScienceExperiment>();

            for (int i = potentials.Count - 1; i >= 0; i--)
            {
                ModuleScienceExperiment potential = potentials[i];
                if (potential.experimentID == experiment.id && !ExcludeFilters.IsExcluded(potential))
                {
                    modules.Add(potential);
                }
            }
        }
コード例 #5
0
ファイル: VariableCommandBase.cs プロジェクト: zaxebo1/Pash
        protected internal bool IsExcluded(string variableName)
        {
            if (IncludeFilters != null)
            {
                if (!IncludeFilters.Any(name => IsMatch(name, variableName)))
                {
                    return(true);
                }
            }

            if (ExcludeFilters != null)
            {
                if (ExcludeFilters.Any(name => IsMatch(name, variableName)))
                {
                    return(true);
                }
            }

            return(false);
        }
コード例 #6
0
        public int RebuildObserverList()
        {
            //Log.Write("ExperimentManager.RebuildObserverList", Log.LEVEL.INFO);
            observers.Clear();
            if (!HighLogic.LoadedSceneIsFlight)
            {
                return(0);
            }
            ScanInterface scanInterface = GetComponent <ScanInterface>();

            if (scanInterface == null)
            {
                Log.Error("ExperimentManager.RebuildObserverList: No ScanInterface component found"); // this is bad; things won't break if the scan interface
            }
            // construct the experiment observer list ...
            for (int i = ResearchAndDevelopment.GetExperimentIDs().Count - 1; i >= 0; i--)
            {
                string expid = ResearchAndDevelopment.GetExperimentIDs()[i];

                if (expid != "evaReport" && expid != "surfaceSample") // special cases
                {
                    var m = FlightGlobals.ActiveVessel.FindPartModulesImplementing <ModuleScienceExperiment>().Where(mse => mse.experimentID == expid).ToList();
                    if (m.Count > 0)
                    {
                        if (!ExcludeFilters.IsExcluded(m[0]))
                        {
                            observers.Add(new ExperimentObserver(vesselStorage, ProfileManager.ActiveProfile[expid], biomeFilter, scanInterface, expid, m[0]));
                        }
                    }
                }
            }
            observers.Add(new SurfaceSampleObserver(vesselStorage, ProfileManager.ActiveProfile["surfaceSample"], biomeFilter, scanInterface));

            try
            {
                if (ProfileManager.ActiveProfile["evaReport"].Enabled)
                {
                    if (Settings.Instance.EvaReportOnTop)
                    {
                        observers = observers.OrderBy(obs => obs.ExperimentTitle).ToList();
                        observers.Insert(0, new EvaReportObserver(vesselStorage, ProfileManager.ActiveProfile["evaReport"], biomeFilter, scanInterface));
                    }
                    else
                    {
                        observers.Add(new EvaReportObserver(vesselStorage, ProfileManager.ActiveProfile["evaReport"], biomeFilter, scanInterface));
                        observers = observers.OrderBy(obs => obs.ExperimentTitle).ToList();
                    }
                }
                else
                {
                    observers = observers.OrderBy(obs => obs.ExperimentTitle).ToList();
                }
            }
            catch (NullReferenceException e)
            {
                Log.Error("ExperimentManager.RebuildObserverList: Active profile does not seem to have an \"evaReport\" entry; {0}", e);
            }

            watcher = UpdateObservers(); // to prevent any problems by rebuilding in the middle of enumeration
            OnObserversRebuilt();

            return(observers.Count);
        }
コード例 #7
0
        private bool ShouldBrowseDirectory(IDirectoryInfo directory)
        {
            var result = true;

            if (!directory.Exists)
            {
                _log.DebugFormat("Skipping scanning directory {0}.", directory.FullName);
                result = false;
            }
            else if (directory.Parent == null)
            {
// ReSharper disable RedundantAssignment
                result = true;
// ReSharper restore RedundantAssignment
            }
            else if (_defautExclussions.Contains(directory.Name) &&
                     (directory.Attributes & FileAttributes.System) == FileAttributes.System)
            {
                _log.DebugFormat("Skipping scanning directory {0} because it is directory that is a part of default exclusion.", directory.FullName);
                result = false;
            }
            else if ((directory.Attributes & FileAttributes.Offline) == FileAttributes.Offline ||
                     (directory.Attributes & FileAttributes.Device) == FileAttributes.Device)
            {
                _log.DebugFormat("Skipping scanning directory {0} because it is a Offline or a Device.", directory.FullName);
                result = false;
            }
            else if (!ScanSystem && (directory.Attributes & FileAttributes.System) == FileAttributes.System)
            {
                _log.DebugFormat("Skipping scanning directory {0} because it is a System directory.", directory.FullName);
                result = false;
            }
            else if (!ScanHidden && (directory.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden)
            {
                _log.DebugFormat("Skipping scanning directory {0} because it is a Hidden directory.", directory.FullName);
                result = false;
            }

            if (IncludeFilters.Count > 0 && !FindFilesRegEx.MatchesFilePattern(directory.FullName, IncludeFilters.ToArray()))
            {
                return(false);
            }

            if (ExcludeFilters.Count > 0 && FindFilesRegEx.MatchesFilePattern(directory.FullName, ExcludeFilters.ToArray()))
            {
                return(false);
            }
            return(result);
        }
コード例 #8
0
        private bool ShouldAddFile(IFileSystemInfo fileInfo)
        {
            var result = true;

            if (!ScanHidden && (fileInfo.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden)
            {
                _log.DebugFormat("Skipping scanning file {0}.", fileInfo.FullName);
                result = false;
            }
            else if (!ScanSystem && (fileInfo.Attributes & FileAttributes.System) == FileAttributes.System)
            {
                _log.DebugFormat("Skipping scanning file {0}.", fileInfo.FullName);
                result = false;
            }
            else if (IncludeFilters.Count > 0 && !FindFilesRegEx.MatchesFilePattern(fileInfo.FullName, IncludeFilters.ToArray()))
            {
                return(false);
            }
            else if (ExcludeFilters.Count > 0 && FindFilesRegEx.MatchesFilePattern(fileInfo.FullName, ExcludeFilters.ToArray()))
            {
                return(false);
            }
            return(result);
        }