Exemple #1
0
 public StuffItem(StuffItem source)
 {
     this.CategoryID     = source.CategoryID;
     this.ID             = source.ID;
     this.Count          = source.Count;
     this.LatestDateTime = source.LatestDateTime;
 }
Exemple #2
0
 public static int RemoveStorages(
     StuffItem item,
     int count,
     IReadOnlyCollection <List <StuffItem> > items)
 {
     foreach (List <StuffItem> self in (IEnumerable <List <StuffItem> >)items)
     {
         self.RemoveItem(item, ref count);
         if (count <= 0)
         {
             break;
         }
     }
     return(count);
 }
        public static void OrganizeItemList(this List <StuffItem> itemList)
        {
            // ISSUE: object of a compiler-generated type is created
            \u003C\u003E__AnonType10 <StuffItem, int>[] array = itemList.Select <StuffItem, \u003C\u003E__AnonType10 <StuffItem, int> >((Func <StuffItem, int, \u003C\u003E__AnonType10 <StuffItem, int> >)((value, index) => new \u003C\u003E__AnonType10 <StuffItem, int>(value, index))).ToArray <\u003C\u003E__AnonType10 <StuffItem, int> >();
            List <Tuple <int, StuffItem> > source             = ListPool <Tuple <int, StuffItem> > .Get();

            foreach (\u003C\u003E__AnonType10 <StuffItem, int> anonType10 in array)
            {
                // ISSUE: variable of a compiler-generated type
                \u003C\u003E__AnonType10 <StuffItem, int> item = anonType10;
                Tuple <int, StuffItem> tuple = source.Find((Predicate <Tuple <int, StuffItem> >)(x => x.Item2.CategoryID == item.value.CategoryID && x.Item2.ID == item.value.ID));
                if (tuple == null)
                {
                    source.Add(new Tuple <int, StuffItem>(item.index, new StuffItem(item.value)));
                }
                else
                {
                    tuple.Item2.Count += item.value.Count;
                    if (tuple.Item2.Count > Singleton <Resources> .Instance.DefinePack.MapDefines.ItemStackUpperLimit)
                    {
                        int count = tuple.Item2.Count - 99;
                        tuple.Item2.Count -= count;
                        StuffItem stuffItem = new StuffItem(tuple.Item2.CategoryID, tuple.Item2.ID, count);
                        int       num       = ((IEnumerable <\u003C\u003E__AnonType10 <StuffItem, int> >)array).Last <\u003C\u003E__AnonType10 <StuffItem, int> >().index + 1;
                        source.Add(new Tuple <int, StuffItem>(num, stuffItem));
                    }
                }
            }
            List <Tuple <int, StuffItem> > list = source.OrderBy <Tuple <int, StuffItem>, int>((Func <Tuple <int, StuffItem>, int>)(x => x.Item2.ID)).ToList <Tuple <int, StuffItem> >();
            List <StuffItem> toRelease          = ListPool <StuffItem> .Get();

            foreach (Tuple <int, StuffItem> tuple in list)
            {
                toRelease.Add(tuple.Item2);
            }
            itemList.Clear();
            itemList.AddRange((IEnumerable <StuffItem>)toRelease.ToArray());
            ListPool <StuffItem> .Release(toRelease);

            ListPool <Tuple <int, StuffItem> > .Release(list);
        }
Exemple #4
0
 public static int RemoveStorages(StuffItem item, IReadOnlyCollection <List <StuffItem> > items)
 {
     return(StuffItem.RemoveStorages(item, item.Count, items));
 }