コード例 #1
0
 public virtual bool CanWork(int amount, Inventory workbenchInv)
 {
     if (this.lastCanWorkResult != null)
     {
         this.lastCanWorkResult.Clear();
     }
     else
     {
         this.lastCanWorkResult = new List <int>();
     }
     if (this.lastCanWorkIngredientCount != null)
     {
         this.lastCanWorkIngredientCount.Clear();
     }
     else
     {
         this.lastCanWorkIngredientCount = new List <int>((int)this.ingredients.Length);
     }
     if (this.RequireWorkbench)
     {
         CraftingInventory component = workbenchInv.GetComponent <CraftingInventory>();
         if (!component || !component.AtWorkBench())
         {
             return(false);
         }
     }
     BlueprintDataBlock.IngredientEntry[] ingredientEntryArray = this.ingredients;
     for (int i = 0; i < (int)ingredientEntryArray.Length; i++)
     {
         BlueprintDataBlock.IngredientEntry ingredientEntry = ingredientEntryArray[i];
         if (ingredientEntry.amount != 0)
         {
             int num = workbenchInv.CanConsume(ingredientEntry.Ingredient, ingredientEntry.amount * amount, this.lastCanWorkResult);
             if (num <= 0)
             {
                 this.lastCanWorkResult.Clear();
                 this.lastCanWorkIngredientCount.Clear();
                 return(false);
             }
             this.lastCanWorkIngredientCount.Add(num);
         }
     }
     return(true);
 }
コード例 #2
0
 public virtual bool CanWork(int amount, Inventory workbenchInv)
 {
     if (this.lastCanWorkResult == null)
     {
         this.lastCanWorkResult = new List <int>();
     }
     else
     {
         this.lastCanWorkResult.Clear();
     }
     if (this.lastCanWorkIngredientCount == null)
     {
         this.lastCanWorkIngredientCount = new List <int>(this.ingredients.Length);
     }
     else
     {
         this.lastCanWorkIngredientCount.Clear();
     }
     if (this.RequireWorkbench)
     {
         CraftingInventory component = workbenchInv.GetComponent <CraftingInventory>();
         if ((component == null) || !component.AtWorkBench())
         {
             return(false);
         }
     }
     foreach (IngredientEntry entry in this.ingredients)
     {
         if (entry.amount != 0)
         {
             int item = workbenchInv.CanConsume(entry.Ingredient, entry.amount * amount, this.lastCanWorkResult);
             if (item <= 0)
             {
                 this.lastCanWorkResult.Clear();
                 this.lastCanWorkIngredientCount.Clear();
                 return(false);
             }
             this.lastCanWorkIngredientCount.Add(item);
         }
     }
     return(true);
 }