Aura.Channel.Skills.Base.CreationSkill.GetItemsToDecrement C# (CSharp) Метод

GetItemsToDecrement() защищенный Метод

Returns list of items that have to be decremented to satisfy the manual's required materials. Actual return value is whether this process was successful, or if materials are missing. Handles necessary messages and logs.
protected GetItemsToDecrement ( Creature creature, Stage stage, ManualData manualData, List requiredMaterials, List materials, List &toDecrement ) : bool
creature Aura.Channel.World.Entities.Creature
stage Stage
manualData ManualData
requiredMaterials List
materials List List of materials the client supplies.
toDecrement List
Результат bool
		protected bool GetItemsToDecrement(Creature creature, Stage stage, ManualData manualData, List<ProductionMaterialData> requiredMaterials, List<ProductionMaterial> materials, out List<ProductionMaterial> toDecrement)
		{
			toDecrement = new List<ProductionMaterial>();

			var inUse = new HashSet<long>();
			foreach (var reqMat in requiredMaterials)
			{
				// Check all selected items for tag matches
				foreach (var material in materials)
				{
					// Satisfy requirement with item, up to the max amount
					// needed or available
					if (material.Item.HasTag(reqMat.Tag))
					{
						// Cancel if one item matches multiple materials.
						// It's unknown how this would be handled, can it even
						// happen? Can one item maybe only be used as one material?
						if (inUse.Contains(material.Item.EntityId))
						{
							Send.ServerMessage(creature, Localization.Get("Unable to handle request, please report, with this information: ({0}/{1}:{2})."), material.Item.Info.Id, manualData.Category, manualData.Id);
							Log.Warning("CreationSkill.GetItemsToDecrement: Item '{0}' matches multiple materials for manual '{1}:{2}'.", material.Item.Info.Id, manualData.Category, manualData.Id);
							return false;
						}

						var amount = Math.Min(reqMat.Amount, material.Item.Amount);
						reqMat.Amount -= amount;
						toDecrement.Add(new ProductionMaterial(material.Item, amount));
						inUse.Add(material.Item.EntityId);
					}

					// Break once we got what we need
					if (reqMat.Amount == 0)
						break;
				}
			}

			if (requiredMaterials.Any(a => a.Amount != 0))
			{
				// Unofficial, the client should normally prevent this.
				Send.ServerMessage(creature, Localization.Get("Insufficient materials."));
				return false;
			}

			return true;
		}