public static MissionObjective Read(BinaryReader br, Mission owner, XElement elem) { var mo = new MissionObjective { QuestId = br.ReadInt32(), ObjectiveId = br.ReadInt32(), Sequence = br.ReadByte(), Owner = owner, Requirements = new List<ObjectiveRequirement>(), }; br.ReadBytes(1); mo.ObjectiveName = br.ReadUnicodeString(65); mo.MapName = br.ReadUnicodeString(65); br.ReadBytes(2); mo.WorldPosition = br.ReadInt32(); mo.ContinentObject = br.ReadInt32(); mo.LayerIndex = br.ReadByte(); br.ReadBytes(3); mo.XP = br.ReadInt32(); mo.Credits = br.ReadInt32(); mo.AttribPoints = br.ReadInt32(); mo.SkillPoints = br.ReadInt32(); mo.ReturnToNPC = br.ReadInt32(); mo.XPIndex = br.ReadInt16(); mo.CreditsIndex = br.ReadInt16(); mo.XPScaler = br.ReadSingle(); mo.XPBalanceScaler = br.ReadSingle(); mo.CreditScaler = br.ReadSingle(); if (elem != null) { var obj = elem.Elements("Objective").SingleOrDefault(e => (UInt32)e.Attribute("sequence") == mo.Sequence); if (obj != null) { mo.ExternalMapText = (String)obj.Element("ExternalText"); mo.Title = (String)obj.Element("Title"); mo.DefaultMapText = (String)obj.Element("DefaultText"); var cCountElem = obj.Element("CompleteCount"); mo.CompleteCount = (cCountElem == null || String.IsNullOrEmpty((String)cCountElem)) ? 0 : (Int32)cCountElem; var req = obj.Elements("Requirement").ToList(); if (req.Any()) mo.Requirements.AddRange(req.Select(xElem => ObjectiveRequirement.Create(mo, xElem)).Where(requirement => requirement != null)); } } return mo; }
public static Mission Read(BinaryReader br) { var mi = new Mission { Id = br.ReadUInt32(), Name = br.ReadUnicodeString(65), Type = br.ReadByte(), Objectives = new Dictionary<Byte, MissionObjective>() }; br.ReadByte(); mi.NPC = br.ReadInt32(); mi.Priority = br.ReadInt32(); mi.ReqRace = br.ReadInt16(); mi.ReqClass = br.ReadInt16(); mi.ReqLevelMin = br.ReadInt32(); mi.ReqLevelMax = br.ReadInt32(); mi.ReqMissionId = br.Read<Int32>(4); mi.IsRepeatable = br.ReadInt16(); br.ReadBytes(2); mi.Item = br.Read<Int32>(4); mi.ItemTemplate = br.Read<Int32>(4); mi.ItemValue = br.Read<Single>(4); mi.ItemIsKit = br.Read<Int16>(4); mi.ItemQuantity = br.Read<Int32>(4); mi.AutoAssing = br.ReadInt16(); mi.ActiveObjectiveOverride = br.ReadInt16(); mi.Continent = br.ReadInt32(); mi.Achievement = br.ReadInt32(); mi.Discipline = br.ReadInt32(); mi.DisciplineValue = br.ReadInt32(); mi.RewardDiscipline = br.ReadInt32(); mi.RewardDisciplineValue = br.ReadInt32(); mi.RewardUnassignedDisciplinePoints = br.ReadInt32(); mi.RequirementEventId = br.ReadInt32(); mi.TargetLevel = br.ReadInt16(); br.ReadBytes(2); mi.RequirementsOred = br.ReadInt32(); mi.RequirementsNegative = br.ReadInt32(); mi.Region = br.ReadInt32(); mi.Pocket = br.ReadInt32(); mi.NumberOfObjectives = br.ReadByte(); br.ReadBytes(7); XElement element = null; var stream = AssetManager.GetStreamByName(String.Format("{0}.xml", mi.Name), "missions.glm") ?? AssetManager.GetStreamByName(String.Format("{0}.xml", mi.Name), "misc.glm"); if (stream != null) { using (stream) { var doc = XDocument.Load(stream); Debug.Assert(doc != null); element = doc.Element("Mission"); if (element != null) { mi.Title = (String)element.Element("Title"); mi.InternalName = (String)element.Element("Internal"); mi.Description = (String)element.Element("Description"); mi.OnLineAccept = (String)element.Element("OnLineAccept"); mi.OnLineReject = (String)element.Element("OnLineReject"); mi.NotCompleteText = (String)element.Element("NotCompleteText"); mi.CompleteText = (String)element.Element("CompleteText"); mi.FailText = (String)element.Element("FailText"); mi.CoreMission = (String)element.Element("CoreMission") != "0"; } } } var numOfObjective = br.ReadInt32(); for (var i = 0; i < numOfObjective; ++i) { var obj = MissionObjective.Read(br, mi, element); mi.Objectives.Add(obj.Sequence, obj); } return mi; }