Aura.Channel.Skills.Music.Composing.Prepare C# (CSharp) Method

Prepare() public method

Prepares the skill, called after entering the MML, goes straight to Use.
public Prepare ( Creature creature, Skill skill, Aura.Shared.Network.Packet packet ) : bool
creature Aura.Channel.World.Entities.Creature
skill Skill
packet Aura.Shared.Network.Packet
return bool
		public bool Prepare(Creature creature, Skill skill, Packet packet)
		{
			var scrollId = packet.GetLong();
			var title = packet.GetString();
			var author = packet.GetString();
			var mml = packet.GetString();
			var song = packet.GetString(); // [180300, NA166 (18.09.2013)] Singing
			var hidden = packet.GetByte(); // bool, but the meta data is a byte

			// Get item
			var item = creature.Inventory.GetItem(scrollId);
			if (item == null) goto L_Fail;

			// Get all parts of the MML (Melody, Haromony 1+2)
			var mmlParts = mml.Split(',');

			// Check lengths
			if (mml.Length > MmlMaxLength || song.Length > MmlMaxLength) goto L_Fail; // Total
			if (mmlParts.Length > 0 && mmlParts[0].Length > skill.RankData.Var1) goto L_Fail; // Melody
			if (mmlParts.Length > 1 && mmlParts[1].Length > skill.RankData.Var2) goto L_Fail; // Harmony 1
			if (mmlParts.Length > 2 && mmlParts[2].Length > skill.RankData.Var3) goto L_Fail; // Harmony 2

			// Score level = Musical Knowledge rank
			var level = SkillRank.Novice;
			var knowledge = creature.Skills.Get(SkillId.MusicalKnowledge);
			if (knowledge != null) level = knowledge.Info.Rank;

			// Update item and send skill complete from Complete
			creature.Skills.Callback(SkillId.Composing, () =>
			{
				// Skill training
				if (skill.Info.Rank == SkillRank.Novice)
					skill.Train(1); // Try the skill.

				// Scroll information
				item.MetaData1.SetString("TITLE", title);
				item.MetaData1.SetString("AUTHOR", author);
				item.MetaData1.SetString("SCORE", MabiZip.Compress(mml));
				item.MetaData1.SetString("SCSING", MabiZip.Compress(song)); // [180300, NA166 (18.09.2013)] Singing
				item.MetaData1.SetByte("HIDDEN", hidden);
				item.MetaData1.SetShort("LEVEL", (short)level);

				// Update
				Send.ItemUpdate(creature, item);
				Send.SkillCompleteEntity(creature, skill.Info.Id, item.EntityId);
			});

			// Finish
			Send.SkillUseEntity(creature, skill.Info.Id, scrollId);
			skill.State = SkillState.Used;
			return true;

		L_Fail:
			return false;
		}