Exemplo n.º 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);
 }
Exemplo n.º 2
0
 public override void UpdateComponent(float time)
 {
     if (!isRunning && Input.GetKeyDown(KeyCode.Space))
     {
         isRunning = true;
         EiTask.Run(GenerateMesh, null, ApplyMesh);
     }
 }