public void Write(BioQuestTask task) { if (task == null) { throw new ArgumentNullException(nameof(task)); } Write(task.InstanceVersion); Write(task.QuestCompleteTask.ToInt32()); Write(task.Name); Write(task.Description); Write(task.PlotItemIndices.Count); foreach (var itemIndex in task.PlotItemIndices) { Write(itemIndex); } Write(task.PlanetNameFlags); Write(task.PlanetName); // Waypoint Tag Write(task.WaypointTag.Length); if (task.WaypointTag.Length > 0) { Write(task.WaypointTag); } }
public BioQuestTask ReadQuestTask() { var task = new BioQuestTask { InstanceVersion = ReadInt32(), QuestCompleteTask = ReadInt32().ToBoolean(), Name = ReadInt32(), Description = ReadInt32() }; var plotItemIndicesCount = ReadInt32(); task.PlotItemIndices = new List <int>(); for (var i = 0; i < plotItemIndicesCount; i++) { task.PlotItemIndices.Add(ReadInt32()); } task.PlanetNameFlags = ReadInt32(); task.PlanetName = ReadInt32(); var waypointTagSize = ReadInt32(); if (waypointTagSize < 0) { return(task); } var chars = ReadChars(waypointTagSize); task.WaypointTag = new string(chars); return(task); }
/// <summary> /// </summary> /// <param name="other"></param> public BioQuestTask(BioQuestTask other) : base(other) { Description = other.Description; Name = other.Name; PlanetName = other.PlanetName; PlanetNameFlags = other.PlanetNameFlags; PlotItemIndices = other.PlotItemIndices != null ? other.PlotItemIndices.ToList() : new List<int>(); QuestCompleteTask = other.QuestCompleteTask; WaypointTag = other.WaypointTag; }
/// <summary> /// </summary> /// <param name="other"></param> public BioQuestTask(BioQuestTask other) : base(other) { Description = other.Description; Name = other.Name; PlanetName = other.PlanetName; PlanetNameFlags = other.PlanetNameFlags; PlotItemIndices = other.PlotItemIndices != null?other.PlotItemIndices.ToList() : new List <int>(); QuestCompleteTask = other.QuestCompleteTask; WaypointTag = other.WaypointTag; }
public static IDictionary <int, BioQuest> ReadQuests(XElement root) { if (root == null) { ThrowHelper.ThrowArgumentNullException(nameof(root)); } var quests = new Dictionary <int, BioQuest>(); var questsElement = root.Element("Quests"); if (questsElement == null) { return(quests); } var xQuests = from el in questsElement.Elements("Quest") select el; foreach (var xQuest in xQuests) { var id = (int?)xQuest.Attribute("Id"); if (id == null) { continue; } var quest = new BioQuest { InstanceVersion = (int?)xQuest.Attribute("InstanceVersion") ?? BioQuest.DefaultInstanceVersion, IsMission = (bool?)xQuest.Attribute("IsMission") ?? BioQuest.DefaultIsMission }; var questGoalsElement = questsElement.Element("Goals"); var questPlotItemsElement = questsElement.Element("PlotItems"); var questTasksElement = questsElement.Element("Tasks"); if (questGoalsElement != null) { var xQuestGoals = from el in questsElement.Elements("Goal") select el; foreach (var questGoal in xQuestGoals .Select(xQuestGoal => new BioQuestGoal { Conditional = (int?)xQuestGoal.Attribute("Conditional") ?? BioQuestGoal.DefaultConditional, Description = (int?)xQuestGoal.Attribute("Description") ?? BioQuestGoal.DefaultDescription, InstanceVersion = (int?)xQuestGoal.Attribute("InstanceVersion") ?? BioQuestGoal.DefaultInstanceVersion, Name = (int?)xQuestGoal.Attribute("Name") ?? BioQuestGoal.DefaultName, State = (int?)xQuestGoal.Attribute("State") ?? BioQuestGoal.DefaultState })) { quest.Goals.Add(questGoal); } } if (questPlotItemsElement != null) { var xQuestPlotItems = from el in questsElement.Elements("PlotItem") select el; foreach (var questPlotItem in xQuestPlotItems .Select(xQuestPlotItem => new BioQuestPlotItem { Conditional = (int?)xQuestPlotItem.Attribute("Conditional") ?? BioQuestPlotItem.DefaultConditional, IconIndex = (int?)xQuestPlotItem.Attribute("IconIndex") ?? BioQuestPlotItem.DefaultIconIndex, InstanceVersion = (int?)xQuestPlotItem.Attribute("InstanceVersion") ?? BioQuestPlotItem.DefaultInstanceVersion, Name = (int?)xQuestPlotItem.Attribute("Name") ?? BioQuestPlotItem.DefaultName, State = (int?)xQuestPlotItem.Attribute("State") ?? BioQuestPlotItem.DefaultState, TargetItems = (int?)xQuestPlotItem.Attribute("TargetItems") ?? BioQuestPlotItem.DefaultTargetItems })) { quest.PlotItems.Add(questPlotItem); } } if (questTasksElement != null) { var xQuestTasks = from el in questsElement.Elements("Task") select el; foreach (var xQuestTask in xQuestTasks) { var questTask = new BioQuestTask { Description = (int?)xQuestTask.Attribute("Conditional") ?? BioQuestTask.DefaultDescription, Name = (int?)xQuestTask.Attribute("Name") ?? BioQuestTask.DefaultName, InstanceVersion = (int?)xQuestTask.Attribute("InstanceVersion") ?? BioQuestTask.DefaultInstanceVersion, PlanetName = (int?)xQuestTask.Attribute("IconIndex") ?? BioQuestTask.DefaultPlanetName, PlanetNameFlags = (int?)xQuestTask.Attribute("IconIndex") ?? BioQuestTask.DefaultPlanetNameFlags, QuestCompleteTask = (bool?)xQuestTask.Attribute("State") ?? BioQuestTask.DefaultQuestCompleteTask, // ReSharper disable once ConstantNullCoalescingCondition WaypointTag = (string)xQuestTask.Attribute("TargetItems") ?? BioQuestTask.DefaultWaypointTag }; var questTaskPlotItemIndicesElement = questsElement.Element("PlotItemIndices"); if (questTaskPlotItemIndicesElement != null) { var xQuestTaskPlotItemIndices = from el in questsElement.Elements("PlotItemIndex") select el; foreach (var xQuestTaskPlotItemIndex in xQuestTaskPlotItemIndices.Where(xQuestTaskPlotItemIndex => !string.IsNullOrEmpty(xQuestTaskPlotItemIndex.Value))) { questTask.PlotItemIndices.Add(xQuestTaskPlotItemIndex.Value.ToInt32()); } } quest.Tasks.Add(questTask); } } quests.Add((int)id, quest); } return(quests); }
public void Write(BioQuestTask task) { if (task == null) { throw new ArgumentNullException(nameof(task)); } Write(task.InstanceVersion); Write(task.QuestCompleteTask.ToInt32()); Write(task.Name); Write(task.Description); Write(task.PlotItemIndices.Count); foreach (var itemIndex in task.PlotItemIndices) { Write(itemIndex); } Write(task.PlanetNameFlags); Write(task.PlanetName); // Waypoint Tag Write(task.WaypointTag.Length); if (task.WaypointTag.Length > 0) { Write(task.WaypointTag); } }
public BioQuestTask ReadQuestTask() { var task = new BioQuestTask { InstanceVersion = ReadInt32(), QuestCompleteTask = ReadInt32().ToBoolean(), Name = ReadInt32(), Description = ReadInt32() }; var plotItemIndicesCount = ReadInt32(); task.PlotItemIndices = new List<int>(); for (var i = 0; i < plotItemIndicesCount; i++) { task.PlotItemIndices.Add(ReadInt32()); } task.PlanetNameFlags = ReadInt32(); task.PlanetName = ReadInt32(); var waypointTagSize = ReadInt32(); if (waypointTagSize < 0) { return task; } var chars = ReadChars(waypointTagSize); task.WaypointTag = new string(chars); return task; }
public static IDictionary<int, BioQuest> ReadQuests(XElement root) { if (root == null) { ThrowHelper.ThrowArgumentNullException(nameof(root)); } var quests = new Dictionary<int, BioQuest>(); var questsElement = root.Element("Quests"); if (questsElement == null) { return quests; } var xQuests = from el in questsElement.Elements("Quest") select el; foreach (var xQuest in xQuests) { var id = (int?) xQuest.Attribute("Id"); if (id == null) { continue; } var quest = new BioQuest { InstanceVersion = (int?) xQuest.Attribute("InstanceVersion") ?? BioQuest.DefaultInstanceVersion, IsMission = (bool?) xQuest.Attribute("IsMission") ?? BioQuest.DefaultIsMission }; var questGoalsElement = questsElement.Element("Goals"); var questPlotItemsElement = questsElement.Element("PlotItems"); var questTasksElement = questsElement.Element("Tasks"); if (questGoalsElement != null) { var xQuestGoals = from el in questsElement.Elements("Goal") select el; foreach (var questGoal in xQuestGoals .Select(xQuestGoal => new BioQuestGoal { Conditional = (int?) xQuestGoal.Attribute("Conditional") ?? BioQuestGoal.DefaultConditional, Description = (int?) xQuestGoal.Attribute("Description") ?? BioQuestGoal.DefaultDescription, InstanceVersion = (int?) xQuestGoal.Attribute("InstanceVersion") ?? BioQuestGoal.DefaultInstanceVersion, Name = (int?) xQuestGoal.Attribute("Name") ?? BioQuestGoal.DefaultName, State = (int?) xQuestGoal.Attribute("State") ?? BioQuestGoal.DefaultState })) { quest.Goals.Add(questGoal); } } if (questPlotItemsElement != null) { var xQuestPlotItems = from el in questsElement.Elements("PlotItem") select el; foreach (var questPlotItem in xQuestPlotItems .Select(xQuestPlotItem => new BioQuestPlotItem { Conditional = (int?) xQuestPlotItem.Attribute("Conditional") ?? BioQuestPlotItem.DefaultConditional, IconIndex = (int?) xQuestPlotItem.Attribute("IconIndex") ?? BioQuestPlotItem.DefaultIconIndex, InstanceVersion = (int?) xQuestPlotItem.Attribute("InstanceVersion") ?? BioQuestPlotItem.DefaultInstanceVersion, Name = (int?) xQuestPlotItem.Attribute("Name") ?? BioQuestPlotItem.DefaultName, State = (int?) xQuestPlotItem.Attribute("State") ?? BioQuestPlotItem.DefaultState, TargetItems = (int?) xQuestPlotItem.Attribute("TargetItems") ?? BioQuestPlotItem.DefaultTargetItems })) { quest.PlotItems.Add(questPlotItem); } } if (questTasksElement != null) { var xQuestTasks = from el in questsElement.Elements("Task") select el; foreach (var xQuestTask in xQuestTasks) { var questTask = new BioQuestTask { Description = (int?) xQuestTask.Attribute("Conditional") ?? BioQuestTask.DefaultDescription, Name = (int?) xQuestTask.Attribute("Name") ?? BioQuestTask.DefaultName, InstanceVersion = (int?) xQuestTask.Attribute("InstanceVersion") ?? BioQuestTask.DefaultInstanceVersion, PlanetName = (int?) xQuestTask.Attribute("IconIndex") ?? BioQuestTask.DefaultPlanetName, PlanetNameFlags = (int?) xQuestTask.Attribute("IconIndex") ?? BioQuestTask.DefaultPlanetNameFlags, QuestCompleteTask = (bool?) xQuestTask.Attribute("State") ?? BioQuestTask.DefaultQuestCompleteTask, // ReSharper disable once ConstantNullCoalescingCondition WaypointTag = (string) xQuestTask.Attribute("TargetItems") ?? BioQuestTask.DefaultWaypointTag }; var questTaskPlotItemIndicesElement = questsElement.Element("PlotItemIndices"); if (questTaskPlotItemIndicesElement != null) { var xQuestTaskPlotItemIndices = from el in questsElement.Elements("PlotItemIndex") select el; foreach (var xQuestTaskPlotItemIndex in xQuestTaskPlotItemIndices.Where(xQuestTaskPlotItemIndex => !xQuestTaskPlotItemIndex.Value.IsNullOrWhiteSpace())) { questTask.PlotItemIndices.Add(xQuestTaskPlotItemIndex.Value.ToInt32()); } } quest.Tasks.Add(questTask); } } quests.Add((int) id, quest); } return quests; }