// Token: 0x06002AFA RID: 11002 RVA: 0x0009FB10 File Offset: 0x0009DD10
    public void Bind(global::BlueprintDataBlock.IngredientEntry ingredient, int needAmount, int haveAmount)
    {
        global::ItemDataBlock ingredient2 = ingredient.Ingredient;
        Color color;

        if (needAmount <= haveAmount)
        {
            this.checkIcon.enabled = true;
            this.xIcon.enabled     = false;
            color = Color.green;
        }
        else
        {
            this.checkIcon.enabled = false;
            this.xIcon.enabled     = true;
            color = Color.red;
        }
        global::UIWidget uiwidget = this.need;
        Color            color2   = color;

        this.have.color    = color2;
        uiwidget.color     = color2;
        this.itemName.text = ingredient2.name;
        this.need.text     = needAmount.ToString("N0");
        this.have.text     = haveAmount.ToString("N0");
    }
    // Token: 0x06003CEC RID: 15596 RVA: 0x000DA044 File Offset: 0x000D8244
    public bool CanRepair(global::Inventory ingredientInv)
    {
        global::IInventoryItem repairItem = this.GetRepairItem();

        if (repairItem == null || !repairItem.datablock.isRepairable)
        {
            return(false);
        }
        if (!repairItem.IsDamaged())
        {
            return(false);
        }
        global::BlueprintDataBlock blueprintDataBlock;

        if (global::BlueprintDataBlock.FindBlueprintForItem <global::BlueprintDataBlock>(repairItem.datablock, out blueprintDataBlock))
        {
            for (int i = 0; i < blueprintDataBlock.ingredients.Length; i++)
            {
                global::BlueprintDataBlock.IngredientEntry ingredientEntry = blueprintDataBlock.ingredients[i];
                int num = Mathf.CeilToInt((float)blueprintDataBlock.ingredients[i].amount * this.GetResourceScalar());
                if (num > 0 && ingredientInv.CanConsume(blueprintDataBlock.ingredients[i].Ingredient, num) <= 0)
                {
                    return(false);
                }
            }
            return(true);
        }
        return(false);
    }
    // Token: 0x06003CED RID: 15597 RVA: 0x000DA0FC File Offset: 0x000D82FC
    public bool CompleteRepair(global::Inventory ingredientInv)
    {
        if (!this.CanRepair(ingredientInv))
        {
            return(false);
        }
        global::IInventoryItem     repairItem = this.GetRepairItem();
        global::BlueprintDataBlock blueprintDataBlock;

        if (!global::BlueprintDataBlock.FindBlueprintForItem <global::BlueprintDataBlock>(repairItem.datablock, out blueprintDataBlock))
        {
            return(false);
        }
        for (int i = 0; i < blueprintDataBlock.ingredients.Length; i++)
        {
            global::BlueprintDataBlock.IngredientEntry ingredientEntry = blueprintDataBlock.ingredients[i];
            int j = Mathf.RoundToInt((float)blueprintDataBlock.ingredients[i].amount * this.GetResourceScalar());
            if (j > 0)
            {
                while (j > 0)
                {
                    int num = 0;
                    global::IInventoryItem inventoryItem = ingredientInv.FindItem(ingredientEntry.Ingredient, out num);
                    if (inventoryItem == null)
                    {
                        return(false);
                    }
                    if (inventoryItem.Consume(ref j))
                    {
                        ingredientInv.RemoveItem(inventoryItem.slot);
                    }
                }
            }
        }
        float num2 = repairItem.maxcondition - repairItem.condition;
        float num3 = num2 * 0.2f + 0.05f;

        repairItem.SetMaxCondition(repairItem.maxcondition - num3);
        repairItem.SetCondition(repairItem.maxcondition);
        return(true);
    }
Пример #4
0
 // Token: 0x06002A63 RID: 10851 RVA: 0x0009D890 File Offset: 0x0009BA90
 public void UpdateGUIAmounts()
 {
     if (this._benchItem == null)
     {
         foreach (global::UILabel uilabel in this._amountLabels)
         {
             uilabel.text  = string.Empty;
             uilabel.color = Color.white;
         }
         this.needsLabel.enabled     = false;
         this.conditionLabel.enabled = false;
         this.repairButton.gameObject.SetActive(false);
     }
     else
     {
         global::Controllable controllable = global::PlayerClient.GetLocalPlayer().controllable;
         if (controllable == null)
         {
             return;
         }
         global::Inventory component = controllable.GetComponent <global::Inventory>();
         int num = 0;
         if (this._benchItem.IsDamaged())
         {
             global::BlueprintDataBlock blueprintDataBlock;
             if (global::BlueprintDataBlock.FindBlueprintForItem <global::BlueprintDataBlock>(this._benchItem.datablock, out blueprintDataBlock))
             {
                 for (int j = 0; j < blueprintDataBlock.ingredients.Length; j++)
                 {
                     if (num >= this._amountLabels.Length)
                     {
                         break;
                     }
                     global::BlueprintDataBlock.IngredientEntry ingredientEntry = blueprintDataBlock.ingredients[j];
                     int num2 = Mathf.CeilToInt((float)blueprintDataBlock.ingredients[j].amount * this._bench.GetResourceScalar());
                     if (num2 > 0)
                     {
                         bool flag = component.CanConsume(blueprintDataBlock.ingredients[j].Ingredient, num2) > 0;
                         this._amountLabels[num].text  = num2 + " " + blueprintDataBlock.ingredients[j].Ingredient.name;
                         this._amountLabels[num].color = ((!flag) ? Color.red : Color.green);
                         num++;
                     }
                 }
             }
             this.needsLabel.color       = Color.white;
             this.needsLabel.enabled     = true;
             this.conditionLabel.enabled = true;
             this.repairButton.gameObject.SetActive(true);
             string str  = (this._benchItem.condition * 100f).ToString("0");
             string str2 = (this._benchItem.maxcondition * 100f).ToString("0");
             this.conditionLabel.text  = "Condition : " + str + "/" + str2;
             this.conditionLabel.color = ((this._benchItem.condition >= 0.6f) ? Color.green : Color.yellow);
             if (this._benchItem.IsBroken())
             {
                 this.conditionLabel.color = Color.red;
             }
         }
         else
         {
             this.needsLabel.text    = "Does not need repairs";
             this.needsLabel.color   = Color.green;
             this.needsLabel.enabled = true;
             string str3 = (this._benchItem.condition * 100f).ToString("0");
             string str4 = (this._benchItem.maxcondition * 100f).ToString("0");
             this.conditionLabel.text    = "Condition : " + str3 + "/" + str4;
             this.conditionLabel.color   = Color.green;
             this.conditionLabel.enabled = true;
             this.repairButton.gameObject.SetActive(false);
             foreach (global::UILabel uilabel2 in this._amountLabels)
             {
                 uilabel2.text  = string.Empty;
                 uilabel2.color = Color.white;
             }
         }
     }
 }