Пример #1
0
    public bool CompleteRepair(Inventory ingredientInv)
    {
        BlueprintDataBlock block;

        if (!this.CanRepair(ingredientInv))
        {
            return(false);
        }
        IInventoryItem repairItem = this.GetRepairItem();

        if (!BlueprintDataBlock.FindBlueprintForItem <BlueprintDataBlock>(repairItem.datablock, out block))
        {
            return(false);
        }
        for (int i = 0; i < block.ingredients.Length; i++)
        {
            BlueprintDataBlock.IngredientEntry entry = block.ingredients[i];
            int count = Mathf.RoundToInt(block.ingredients[i].amount * this.GetResourceScalar());
            if (count > 0)
            {
                while (count > 0)
                {
                    int            totalNum = 0;
                    IInventoryItem item2    = ingredientInv.FindItem(entry.Ingredient, out totalNum);
                    if (item2 != null)
                    {
                        if (item2.Consume(ref count))
                        {
                            ingredientInv.RemoveItem(item2.slot);
                        }
                    }
                    else
                    {
                        return(false);
                    }
                }
            }
        }
        float num4 = repairItem.maxcondition - repairItem.condition;
        float num5 = (num4 * 0.2f) + 0.05f;

        repairItem.SetMaxCondition(repairItem.maxcondition - num5);
        repairItem.SetCondition(repairItem.maxcondition);
        return(true);
    }
Пример #2
0
    public bool CompleteRepair(Inventory ingredientInv)
    {
        BlueprintDataBlock blueprintDataBlock;

        if (!this.CanRepair(ingredientInv))
        {
            return(false);
        }
        IInventoryItem repairItem = this.GetRepairItem();

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

        repairItem.SetMaxCondition(repairItem.maxcondition - single1);
        repairItem.SetCondition(repairItem.maxcondition);
        return(true);
    }
Пример #3
0
 public virtual void InstallData(IInventoryItem item)
 {
     item.SetUses(1);
     item.SetMaxCondition(1f);
     item.SetCondition(1f);
 }