Пример #1
0
 public void UpdateMaterials()
 {
     if (!_init)
     {
         return;
     }
     try
     {
         lock (materialLocker)
         {
             _materialList.Clear();
             List <CastSpellAction> castSpellList = CastSpellAction.GetCastSpellActionList(Branch);
             if (castSpellList != null)
             {
                 foreach (CastSpellAction ca in castSpellList)
                 {
                     if (ca.IsRecipe && ca.RepeatType != CastSpellAction.RepeatCalculationType.Craftable)
                     {
                         foreach (Ingredient ingred in ca.Recipe.Ingredients)
                         {
                             _materialList[ingred.ID] = _materialList.ContainsKey(ingred.ID)
                                                                         ? _materialList[ingred.ID] +
                                                        (ca.CalculatedRepeat > 0 ? (int)ingred.Required * (ca.CalculatedRepeat - ca.Casted) : 0)
                                                                         : (ca.CalculatedRepeat > 0 ? (int)ingred.Required * (ca.CalculatedRepeat - ca.Casted) : 0);
                         }
                     }
                 }
             }
         }
     }
     catch (Exception ex)
     {
         PBLog.Warn(ex.ToString());
     }
 }
        public void UpdateMaterials()
        {
            try
            {
                lock (MaterialList)
                {
                    MaterialList.Clear();
                    List <CastSpellAction> castSpellList =
                        CastSpellAction.GetCastSpellActionList(CurrentProfile.Branch);
                    if (castSpellList != null)
                    {
                        foreach (CastSpellAction ca in castSpellList)
                        {
                            if (ca.IsRecipe)
                            {
                                foreach (var ingred in ca.Recipe.Ingredients)
                                {
                                    MaterialList[ingred.ID] = MaterialList.ContainsKey(ingred.ID) ?
                                                              MaterialList[ingred.ID] + (ca.CalculatedRepeat > 0 ?
                                                                                         (int)ingred.Required * (ca.CalculatedRepeat - ca.Casted) : 0) :

                                                              (ca.CalculatedRepeat > 0 ? (int)ingred.Required * (ca.CalculatedRepeat - ca.Casted) : 0);
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            { Err(ex.ToString()); }
        }