Пример #1
0
 public bool AddItem(EiItem item)
 {
     if (item.MaxStacks > 1)
     {
         var size = itemList.Length;
         for (int i = 0; i < size; i++)
         {
             var tempItem = itemList [i];
             if (tempItem.ItemId == item.ItemId)
             {
                 var missingForFullStack = tempItem.MaxStacks - tempItem.Amount;
                 var itemsToAdd          = Math.Min(missingForFullStack, item.Amount);
                 tempItem.Amount += itemsToAdd;
                 item.Amount     -= itemsToAdd;
             }
             if (item.Amount <= 0)
             {
                 EiTask.RunUnityTask(InternalDestroyItem, item);
                 return(true);
             }
         }
     }
     // Default Add if possible
     if (itemList.Count < storageSize && (!useWeight || !item.UseWeightInStorage || (maxWeight >= cachedWeight + item.Weight)))
     {
         itemList.Add(item);
         EiTask.RunUnityTask(InternalHideItem, item);
         return(true);
     }
     return(false);
 }
Пример #2
0
 private void InternalHideItem(EiItem item)
 {
     item.gameObject.SetActive(false);
     item.transform.SetParent(this.transform);
     item.transform.localPosition = Vector3.zero;
 }
Пример #3
0
 private void InternalDestroyItem(EiItem item)
 {
     Destroy(item.gameObject);
 }