예제 #1
0
        public EditPatternForm(FilterRule rule, string property, FilterTarget target) : this(property, target)
        {
            Pattern                = rule;
            searchTextBox.Text     = rule.SearchString;
            negateCheckBox.Checked = rule.Negate;

            typeSelection.ChangeSelection((PatternSelectionType)rule.FilterType);
        }
예제 #2
0
        public void Main()
        {
            object eval;

            if (PropertyName == "$item")
            {
                eval = FilterTarget;
            }
            else
            {
                var evalProp = FilterTarget.GetType().GetProperty(PropertyName);
                if (evalProp == null)
                {
                    return;
                }
                if (evalProp.GetGetMethod() == null)
                {
                    return;
                }

                eval = evalProp.GetValue(FilterTarget, null);
                if (eval == null)
                {
                    return;
                }
            }

            if (eval is string == false && (Operator == FilterOperators.Contains || Operator == FilterOperators.NotContains))
            {
                throw new ArgException("The Contains and NotContains operators can only be applied to properties of type string");
            }

            object comparison = Value;

            try
            {
                if (eval.GetType() != typeof(string))
                {
                    if (ArgRevivers.CanRevive(eval.GetType()))
                    {
                        comparison = ArgRevivers.Revive(eval.GetType(), "", comparison + "");
                    }
                }
            }
            catch (Exception ex)
            {
                PowerLogger.LogLine("Unable to convert a string to:" + eval.GetType().FullName);
                return;
            }

            if (FilterLogic.FilterAcceptsObject(eval, Operator, comparison))
            {
                ArgPipeline.Push(FilterTarget);
            }
        }
예제 #3
0
        public EditPatternForm(string property, FilterTarget target)
        {
            Eto.Serialization.Xaml.XamlReader.Load(this);

            propertyLabel.Text = property;

            typeSelection = new SelectionUI <PatternSelectionType>(null, typeSelectionStack);
            if (target == FilterTarget.Train)
            {
                typeSelection.DisableOption(PatternSelectionType.StationType);
            }
        }
예제 #4
0
    /// <summary>
    /// 通过filter以及param, 将container中不满足的对象删除.
    /// </summary>
    public static void FilterTargetsBy(ArrayList container, FilterTarget filter, params object[] param)
    {
        int firstUnmatched = 0;

        // firstUnmatched及之后的所有battleunit都无效.
        for (int i = 0; i < container.Count; ++i)
        {
            BattleUnit target = (BattleUnit)container[i];
            if (filter(target, param))
            {
                container[firstUnmatched++] = container[i];
            }
        }

        // 移除该位置及之后的所有battleunit.
        container.RemoveRange(firstUnmatched, container.Count - firstUnmatched);
    }
예제 #5
0
        public void ExecuteOutFilter(IFilter filter, Action <Entity> callback, FilterTarget target)
        {
            switch (target)
            {
            case FilterTarget.All:
                for (int i = 0; i < this.Components.Count; i++)
                {
                    if (this.Components[i] is Entity && !filter.Contains(this.Components[i] as Entity))
                    {
                        callback(this.Components[i] as Entity);
                    }
                }
                break;

            case FilterTarget.AlwaysUpdate:
                for (int i = 0; i < this.AlwaysUpdate.Count; i++)
                {
                    if (this.AlwaysUpdate[i] is Entity && !filter.Contains(this.AlwaysUpdate[i] as Entity))
                    {
                        callback(this.AlwaysUpdate[i] as Entity);
                    }
                }
                break;

            case FilterTarget.OnScreen:
                EntityRenderer r = this.renderer as EntityRenderer;
                if (r != null)
                {
                    foreach (Entity e in this.integrator.GetEntitiesInRect(r.TopLeft, r.BottomRight, true))
                    {
                        if (!filter.Contains(e))
                        {
                            callback(e);
                        }
                    }
                }
                break;
            }
        }
예제 #6
0
        public IEnumerable <Entity> GetEntitiesByFilter(IFilter filter, FilterTarget target)
        {
            switch (target)
            {
            case FilterTarget.All:
                for (int i = 0; i < this.Components.Count; i++)
                {
                    if (this.Components[i] is Entity && filter.Contains(this.Components[i] as Entity))
                    {
                        yield return(this.Components[i] as Entity);
                    }
                }
                break;

            case FilterTarget.AlwaysUpdate:
                for (int i = 0; i < this.AlwaysUpdate.Count; i++)
                {
                    if (this.AlwaysUpdate[i] is Entity && filter.Contains(this.AlwaysUpdate[i] as Entity))
                    {
                        yield return(this.Components[i] as Entity);
                    }
                }
                break;

            case FilterTarget.OnScreen:
                EntityRenderer r = this.renderer as EntityRenderer;
                if (r != null)
                {
                    foreach (Entity e in this.integrator.GetEntitiesInRect(r.TopLeft, r.BottomRight, true))
                    {
                        if (filter.Contains(e))
                        {
                            yield return(e);
                        }
                    }
                }
                break;
            }
        }