Exemplo n.º 1
0
        public void Update()
        {
            if (!ready)
            {
                return;
            }
            IEnumerable <Ship> baseships = Staff.Current.Homeport.Ships;

            if (baseships == null)
            {
                return;
            }
            int[] typeid = ShipTypes.Where(x => x.IsSelected).Select(x => x.ShipType.Id).ToArray();
            baseships = baseships.Where(x => typeid.Contains(x.ShipInfo.ShipType.Id));
            Filters.ForEach(x => baseships = x.Apply(baseships));
            Ship[] sortedships            = baseships.ToArray();
            MultiComparer <Ship> comparer = new MultiComparer <Ship> {
                Selectors = Selectors.TakeWhile(x => x.SelectedIndex != 0).Select(x => new Tuple <Func <Ship, int>, bool>(x.Sorter.KeySelector, x.IsDescend))
            };

            Array.Sort(sortedships, comparer);
            ShownShips = sortedships.Select(ItemWithIndex <Ship> .Generator).ToArray();
        }