Exemple #1
0
 public void Add(T value)
 {
     if (!dictionary.ContainsKey(value))
     {
         if (free.Count > 0)
         {
             int pos = MyLinq.First(free.Keys);
             free.Remove(pos);
             list[pos]         = value;
             dictionary[value] = pos;
         }
         else
         {
             list.Add(value);
             dictionary[value] = list.Count - 1;
         }
     }
 }
Exemple #2
0
 public Item Stack(Item itemA, Item itemB)
 {
     if (itemA.ItemClass == ItemClass.Block &&
         itemB.ItemClass == ItemClass.Block)
     {
         int railcountA = MyLinq.Count(DirectionUtils.ToRailDirections(d_Data.Rail[itemA.BlockId]));
         int railcountB = MyLinq.Count(DirectionUtils.ToRailDirections(d_Data.Rail[itemB.BlockId]));
         if ((itemA.BlockId != itemB.BlockId) && (!(railcountA > 0 && railcountB > 0)))
         {
             return(null);
         }
         //todo stack size limit
         Item ret = new Item();
         ret.ItemClass  = itemA.ItemClass;
         ret.BlockId    = itemA.BlockId;
         ret.BlockCount = itemA.BlockCount + itemB.BlockCount;
         return(ret);
     }
     else
     {
         return(null);
     }
 }