Exemplo n.º 1
0
        /// <summary>
        /// Checks if a collection of mods contains a mod that satisfies this dependency.
        /// </summary>
        public bool IsPresent(ModCollection mods, Version factorioVersion)
        {
            bool result = false;

            if (IsBase || IsInverted)
            {
                result = true;
            }
            else if (HasRestriction)
            {
                var comparison = comparisonFunctions[RestrictionComparison];

                var candidates = mods.Find(ModName, factorioVersion);
                foreach (var candidate in candidates)
                {
                    if (comparison(candidate.Version, RestrictionVersion))
                    {
                        result = true;
                        break;
                    }
                }
            }
            else
            {
                result = mods.ContainsbyFactorioVersion(ModName, factorioVersion);
            }

            Unsatisfied = !result;
            return(result);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Checks if a collection of mods satisfies this dependency.
        /// </summary>
        public bool IsMet(ModCollection mods, Version factorioVersion)
        {
            bool result;

            if (IsBase || IsInverted)
            {
                result = true;
            }
            else
            {
                if (HasVersionRestriction)
                {
                    if (ExactRestriction)
                    {
                        result = mods.Contains(ModName, ModVersion);
                    }
                    else
                    {
                        var candidates = mods.Find(ModName, factorioVersion);
                        result = candidates.Any(item => item.Version >= ModVersion);
                    }
                }
                else
                {
                    result = mods.ContainsbyFactorioVersion(ModName, factorioVersion);
                }
            }

            Unsatisfied = !result;
            OnPropertyChanged(new PropertyChangedEventArgs(nameof(Unsatisfied)));

            return(result);
        }