Aura.Channel.Skills.Base.ProductionSkill.Prepare C# (CSharp) Метод

Prepare() публичный Метод

Starts production, finished in Complete.
public Prepare ( Creature creature, Skill skill, Packet packet ) : bool
creature Aura.Channel.World.Entities.Creature
skill Skill
packet Packet
Результат bool
		public bool Prepare(Creature creature, Skill skill, Packet packet)
		{
			var unkByte = packet.GetByte();
			var propEntityId = 0L;
			var unkInt = 0;
			if (packet.Peek() == PacketElementType.Long) // Rule unknown
			{
				propEntityId = packet.GetLong();
				unkInt = packet.GetInt();
			}
			var productId = packet.GetInt();
			var unkShort1 = packet.GetShort();
			var category = (ProductionCategory)packet.GetShort();
			var amountToProduce = packet.GetShort();
			var count = packet.GetByte();
			var materials = new List<ProductionMaterial>(count);
			for (int i = 0; i < count; ++i)
			{
				var entityId = packet.GetLong();
				var amount = packet.GetShort();

				// Check item
				var item = creature.Inventory.GetItem(entityId);
				if (item == null)
				{
					Log.Warning("ProductionSkill.Prepare: Creature '{0:X16}' tried to use non-existent item as material.", creature.EntityId);
					return false;
				}

				materials.Add(new ProductionMaterial(item, amount));
			}

			// Get product data
			var potentialProducts = AuraData.ProductionDb.Find(category, productId);
			if (potentialProducts.Length == 0)
			{
				Send.ServerMessage(creature, "Unknown product.");
				return false;
			}
			var productData = potentialProducts[0];

			// Check tools
			if (!this.CheckTools(creature, skill, productData))
				return false;

			// Check prop
			if (!this.CheckProp(creature, propEntityId))
				return false;

			// Check mana
			if (!this.CheckMana(creature, productData))
				return false;

			// Give skills the ability to use motions and other things.
			this.OnUse(creature, skill);

			// Response
			Send.Echo(creature, Op.SkillUse, packet);
			skill.State = SkillState.Used;

			return true;
		}