diff --git a/QuestMap/Filters.cs b/QuestMap/Filters.cs index 32f23ed..57a2960 100644 --- a/QuestMap/Filters.cs +++ b/QuestMap/Filters.cs @@ -1,7 +1,7 @@ -using Lumina.Excel.GeneratedSheets; -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; using FFXIVClientStructs.FFXIV.Client.Game; +using Lumina.Excel.Sheets; namespace QuestMap { diff --git a/QuestMap/IQuestInfo.cs b/QuestMap/IQuestInfo.cs new file mode 100644 index 0000000..dc2307e --- /dev/null +++ b/QuestMap/IQuestInfo.cs @@ -0,0 +1,28 @@ +using System.Collections.Generic; +using Lumina.Excel.Sheets; + +namespace QuestMap; + +public interface IQuestInfo +{ + public Quest Quest { get; } + public uint RowId { get; } + public string Name { get; } + public IEnumerable PreviousQuests(); +} + +public sealed class SheetQuestInfo(Quest quest) : IQuestInfo +{ + public Quest Quest => quest; + public uint RowId => quest.RowId; + public string Name => quest.Name.ToString(); + public IEnumerable PreviousQuests() => quest.PreviousQuests(); +} + +public sealed class ConsolidatedQuestInfo(IQuestInfo baseQuest, string name) : IQuestInfo +{ + public Quest Quest => baseQuest.Quest; + public uint RowId => baseQuest.RowId; + public string Name => name; + public IEnumerable PreviousQuests() => baseQuest.PreviousQuests(); +} diff --git a/QuestMap/Node.cs b/QuestMap/Node.cs index 3d76060..fc2fa81 100644 --- a/QuestMap/Node.cs +++ b/QuestMap/Node.cs @@ -1,10 +1,10 @@ using System; using System.Collections.Generic; using System.Linq; -using Lumina.Excel.GeneratedSheets; +using Lumina.Excel.Sheets; namespace QuestMap { - internal class Node { + internal class Node where T : IQuestInfo { internal uint Id { get; } internal List> Parents { get; set; } internal T Value { get; set; } @@ -101,16 +101,16 @@ namespace QuestMap { } } - internal static (List>, Dictionary>) BuildTree(Dictionary layouts) { - var lookup = new Dictionary>(); - var rootNodes = new List>(); - var allNodes = new Dictionary>(); + internal static (List>, Dictionary>) BuildTree(Dictionary layouts) { + var lookup = new Dictionary>(); + var rootNodes = new List>(); + var allNodes = new Dictionary>(); foreach (var item in layouts) { if (lookup.TryGetValue(item.Key, out var ourNode)) { ourNode.Value = item.Value; } else { - ourNode = new Node([], item.Key, item.Value); + ourNode = new Node([], item.Key, item.Value); lookup[item.Key] = ourNode; allNodes[item.Key] = ourNode; } @@ -122,7 +122,7 @@ namespace QuestMap { foreach (var prev in previous) { if (!lookup.TryGetValue(prev.RowId, out var parentNode)) { // create preliminary parent - parentNode = new Node(prev.RowId); + parentNode = new Node(prev.RowId); lookup[prev.RowId] = parentNode; allNodes[prev.RowId] = parentNode; } @@ -138,7 +138,8 @@ namespace QuestMap { } internal static class NodeExt { - internal static Node? Find(this IEnumerable> nodes, uint id) { + internal static Node? Find(this IEnumerable> nodes, uint id) + where T : IQuestInfo { foreach (var node in nodes) { var found = node.Find(id); @@ -152,7 +153,7 @@ namespace QuestMap { internal static IEnumerable PreviousQuests(this Quest quest) { foreach (var previous in quest.PreviousQuest) { - if (previous != null && previous.Row != 0) { + if (previous.RowId != 0) { yield return previous.Value!; } } diff --git a/QuestMap/PluginUi.cs b/QuestMap/PluginUi.cs index 8dcf54e..500a290 100644 --- a/QuestMap/PluginUi.cs +++ b/QuestMap/PluginUi.cs @@ -11,12 +11,14 @@ using Dalamud.Game.Text.SeStringHandling.Payloads; using Dalamud.Interface; using Dalamud.Interface.Textures; using Dalamud.Interface.Textures.TextureWraps; +using Dalamud.Utility; using FFXIVClientStructs.FFXIV.Client.Game; using FFXIVClientStructs.FFXIV.Client.UI.Agent; using ImGuiNET; using Lumina.Data; using Lumina.Excel; -using Lumina.Excel.GeneratedSheets; +using Lumina.Excel.Sheets; +using Lumina.Text.ReadOnly; using Microsoft.Msagl.Core.Geometry; using Microsoft.Msagl.Core.Geometry.Curves; using Microsoft.Msagl.Core.Layout; @@ -88,7 +90,7 @@ namespace QuestMap { return false; } - if (!this.Plugin.Config.ShowSeasonal && quest.Festival.Row != 0) { + if (!this.Plugin.Config.ShowSeasonal && quest.Festival.RowId != 0) { return false; } @@ -113,7 +115,7 @@ namespace QuestMap { return false; } - if (items.All(item => item.ItemUICategory.Row != 81)) { + if (items.All(item => item.ItemUICategory.RowId != 81)) { return false; } } @@ -154,7 +156,7 @@ namespace QuestMap { var allItems = this.Plugin.Config.ItemVis != Visibility.Hidden; var anyItemVisible = allItems || this.Plugin.Config.MinionVis != Visibility.Hidden; if (anyItemVisible && this.Plugin.Quests.ItemRewards.TryGetValue(quest.RowId, out var items)) { - var toShow = items.Where(item => allItems || item.ItemUICategory.Row == 81); + var toShow = items.Where(item => allItems || item.ItemUICategory.RowId == 81); drawItems.AddRange(toShow.Select(item => (quest, true, $"{this.Convert(item.Name)}##item-{quest.RowId}-{item.RowId}"))); } @@ -300,7 +302,7 @@ namespace QuestMap { ImGui.PushStyleColor(ImGuiCol.Text, disabled); } - var ret = ImGui.Selectable(name, this.Quest == quest); + var ret = ImGui.Selectable(name, this.Quest?.RowId == quest.RowId); if (completed) { ImGui.PopStyleColor(); @@ -352,7 +354,7 @@ namespace QuestMap { if (this._relayout && this.Quest != null) { this.Graph = null; this.CancellationTokenSource?.Cancel(); - this.CancellationTokenSource = this.Plugin.Quests.StartGraphRecalculation(this.Quest); + this.CancellationTokenSource = this.Plugin.Quests.StartGraphRecalculation(this.Quest.Value); this._relayout = false; } @@ -363,14 +365,14 @@ namespace QuestMap { var remove = 0u; foreach (var id in this.InfoWindows) { - var quest = this.Plugin.DataManager.GetExcelSheet()!.GetRow(id); + var quest = this.Plugin.DataManager.GetExcelSheet()!.GetRowOrDefault(id); if (quest == null) { remove = id; continue; } - if (this.DrawInfoWindow(quest)) { + if (this.DrawInfoWindow(quest.Value)) { remove = id; } } @@ -390,7 +392,7 @@ namespace QuestMap { var completed = QuestManager.IsQuestComplete(quest.RowId); - ImGui.TextUnformatted($"Level: {quest.ClassJobLevel0}"); + ImGui.TextUnformatted($"Level: {quest.ClassJobLevel[0]}"); if (completed) { ImGui.PushFont(UiBuilder.IconFont); @@ -416,10 +418,10 @@ namespace QuestMap { } var rewards = new List(); - var paramGrow = this.Plugin.DataManager.GetExcelSheet()!.GetRow(quest.ClassJobLevel0); + var paramGrow = this.Plugin.DataManager.GetExcelSheet()!.GetRowOrDefault(quest.ClassJobLevel[0]); var xp = 0; if (paramGrow != null) { - xp = quest.ExpFactor * paramGrow.ScaledQuestXP * paramGrow.QuestExpModifier / 100; + xp = quest.ExpFactor * paramGrow.Value.ScaledQuestXP * paramGrow.Value.QuestExpModifier / 100; } if (xp > 0) { @@ -486,16 +488,16 @@ namespace QuestMap { additionalRewards.Add((this.Convert(job.Name).ToString(), 62000 + job.RowId, 1)); } - for (var i = 0; i < quest.ItemCatalyst.Length; i++) { + for (var i = 0; i < quest.ItemCatalyst.Count; i++) { var catalyst = quest.ItemCatalyst[i]; var amount = quest.ItemCountCatalyst[i]; - if (catalyst.Row != 0) { + if (catalyst.RowId != 0) { additionalRewards.Add((this.Convert(catalyst.Value!.Name), catalyst.Value.Icon, amount)); } } - foreach (var generalAction in quest.GeneralActionReward.Where(row => row.Row != 0)) { + foreach (var generalAction in quest.GeneralActionReward.Where(row => row.RowId != 0)) { additionalRewards.Add((this.Convert(generalAction.Value!.Name), (uint) generalAction.Value.Icon, 1)); } @@ -507,34 +509,34 @@ namespace QuestMap { additionalRewards.Add((this.Convert(emote.Name), emote.Icon, 1)); } - if (quest.OtherReward.Row != 0) { + if (quest.OtherReward.RowId != 0) { additionalRewards.Add((this.Convert(quest.OtherReward.Value!.Name), quest.OtherReward.Value.Icon, 1)); } if (quest.ReputationReward > 0) { - var beastTribe = quest.BeastTribe.Value; + var beastTribe = quest.BeastTribe.ValueNullable; if (beastTribe != null) { - additionalRewards.Add((this.Convert(beastTribe.NameRelation), beastTribe.Icon, quest.ReputationReward)); + additionalRewards.Add((this.Convert(beastTribe.Value.NameRelation), beastTribe.Value.Icon, quest.ReputationReward)); } } if (quest.TomestoneReward > 0) { - var tomestone = this.Plugin.DataManager.GetExcelSheet()!.FirstOrDefault(row => row.Tomestones.Row == quest.TomestoneReward); - var item = tomestone?.Item?.Value; + var tomestone = this.Plugin.DataManager.GetExcelSheet().Cast().FirstOrDefault(row => row.Value.Tomestones.RowId == quest.TomestoneReward); + var item = tomestone?.Item.ValueNullable; if (item != null) { - additionalRewards.Add((this.Convert(item.Name), item.Icon, quest.TomestoneCountReward)); + additionalRewards.Add((this.Convert(item.Value.Name), item.Value.Icon, quest.TomestoneCountReward)); } } if (quest.ItemRewardType is 0 or 1 or 3 or 5) { DrawItemRewards( "Rewards", - quest.ItemReward - .Zip(quest.ItemCountReward, (id, qty) => (id, qty)) + quest.Reward + .Zip(quest.ItemCountReward, (id, qty) => (id: id.RowId, qty)) .Where(entry => entry.id != 0) - .Select(entry => (item: this.Plugin.DataManager.GetExcelSheet()!.GetRow(entry.id), entry.qty)) + .Select(entry => (item: this.Plugin.DataManager.GetExcelSheet()!.GetRowOrDefault(entry.id), entry.qty)) .Where(entry => entry.item != null) - .Select(entry => (this.Convert(entry.item!.Name), (uint) entry.item.Icon, entry.qty)) + .Select(entry => (this.Convert(entry.item.Value.Name), (uint) entry.item.Value.Icon, entry.qty)) .Concat(additionalRewards) ); @@ -542,10 +544,10 @@ namespace QuestMap { "Optional rewards", quest.OptionalItemReward .Zip(quest.OptionalItemCountReward, (row, qty) => (row, qty)) - .Where(entry => entry.row.Row != 0) - .Select(entry => (item: entry.row.Value, entry.qty)) + .Where(entry => entry.row.RowId != 0) + .Select(entry => (item: entry.row.ValueNullable, entry.qty)) .Where(entry => entry.item != null) - .Select(entry => (this.Convert(entry.item!.Name), (uint) entry.item.Icon, entry.qty)) + .Select(entry => (this.Convert(entry.item.Value.Name), (uint) entry.item.Value.Icon, entry.qty)) ); } @@ -553,7 +555,7 @@ namespace QuestMap { ImGui.TextUnformatted("Instances"); foreach (var instance in instances) { - var icon = instance.ContentType.Value?.Icon ?? 0; + var icon = instance.ContentType.ValueNullable?.Icon ?? 0; if (icon > 0) { var image = GetIcon(icon); if (image != null) { @@ -592,9 +594,9 @@ namespace QuestMap { ClientLanguage.French => Language.French, _ => Language.English, }; - var path = $"quest/{id.ToString("00000")[..3]}/{quest.Id.RawString.ToLowerInvariant()}"; + var path = $"quest/{id.ToString("00000")[..3]}/{quest.Id.ToString().ToLowerInvariant()}"; // FIXME: this is gross, but lumina caches incorrectly - this.Plugin.DataManager.Excel.RemoveSheetFromCache(); + // this.Plugin.DataManager.Excel.RemoveSheetFromCache(); var sheet = this.Plugin.DataManager.Excel.GetType() .GetMethod("GetSheet", BindingFlags.Instance | BindingFlags.NonPublic)? // ReSharper disable once ConstantConditionalAccessQualifier @@ -606,11 +608,11 @@ namespace QuestMap { null, ]) as ExcelSheet; // default to english if reflection failed - sheet ??= this.Plugin.DataManager.Excel.GetSheet(path); + sheet ??= this.Plugin.DataManager.Excel.GetSheet(name: path); var firstData = sheet?.GetRow(0); if (firstData != null) { ImGui.PushTextWrapPos(textWrap); - ImGui.TextUnformatted(this.Convert(firstData.Text).ToString()); + ImGui.TextUnformatted(this.Convert(firstData.Value.Text).ToString()); ImGui.PopTextWrapPos(); } @@ -622,24 +624,24 @@ namespace QuestMap { } var mapLink = new MapLinkPayload( - level.Territory.Row, - level.Map.Row, - (int) (level.X * 1_000f), - (int) (level.Z * 1_000f) + level.Value.Territory.RowId, + level.Value.Map.RowId, + (int) (level.Value.X * 1_000f), + (int) (level.Value.Z * 1_000f) ); this.Plugin.GameGui.OpenMapWithMapLink(mapLink); } - var issuer = this.Plugin.DataManager.GetExcelSheet()!.GetRow(quest.IssuerStart)?.Singular ?? "Unknown"; - var target = this.Plugin.DataManager.GetExcelSheet()!.GetRow(quest.TargetEnd)?.Singular ?? "Unknown"; - ImGui.TextUnformatted(issuer); + var issuer = this.Plugin.DataManager.GetExcelSheet()!.GetRowOrDefault(quest.IssuerStart.RowId)?.Singular ?? "Unknown"; + var target = this.Plugin.DataManager.GetExcelSheet()!.GetRowOrDefault(quest.TargetEnd.RowId)?.Singular ?? "Unknown"; + ImGui.TextUnformatted(issuer.ToString()); ImGui.PushFont(UiBuilder.IconFont); ImGui.SameLine(); ImGui.TextUnformatted(FontAwesomeIcon.ArrowRight.ToIconString()); ImGui.PopFont(); ImGui.SameLine(); - ImGui.TextUnformatted(target); + ImGui.TextUnformatted(target.ToString()); ImGui.Separator(); @@ -822,9 +824,10 @@ namespace QuestMap { continue; } - var quest = (Quest) node.UserData; + var questInfo = (IQuestInfo)node.UserData; + var quest = questInfo.Quest; - var colour = quest.EventIconType.Row switch { + var colour = quest.EventIconType.RowId switch { 1 => Colours.NormalQuest, // normal 3 => Colours.MsqQuest, // msq 8 => Colours.BlueQuest, // blue @@ -846,12 +849,12 @@ namespace QuestMap { drawn.Add((start, end, quest.RowId)); - if (quest == this.Quest) { + if (quest.RowId == this.Quest?.RowId) { drawList.AddRect(start - Vector2.One, end + Vector2.One, Colours.Line, 5, ImDrawFlags.RoundCornersAll); } drawList.AddRectFilled(start, end, ImGui.GetColorU32(colour), 5, ImDrawFlags.RoundCornersAll); - drawList.AddText(start + TextOffset, textColour, this.Convert(quest.Name).ToString()); + drawList.AddText(start + TextOffset, textColour, questInfo.Name); } // HOW ABOUT DRAGGING THE VIEW? @@ -905,8 +908,8 @@ namespace QuestMap { private static readonly byte[] NewLinePayload = [0x02, 0x10, 0x01, 0x03]; - private SeString Convert(Lumina.Text.SeString lumina) { - var se = (SeString) lumina; + private SeString Convert(ReadOnlySeString lumina) { + var se = lumina.ToDalamudString(); for (var i = 0; i < se.Payloads.Count; i++) { switch (se.Payloads[i].Type) { case PayloadType.Unknown: diff --git a/QuestMap/QuestData.cs b/QuestMap/QuestData.cs index c6ea11b..c804917 100644 --- a/QuestMap/QuestData.cs +++ b/QuestMap/QuestData.cs @@ -1,24 +1,20 @@ using System.Diagnostics.CodeAnalysis; -using Lumina; -using Lumina.Data; using Lumina.Excel; -using Lumina.Text; +using Lumina.Text.ReadOnly; namespace QuestMap { [SuppressMessage("ReSharper", "UnusedAutoPropertyAccessor.Global")] [SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] [SuppressMessage("ReSharper", "ClassNeverInstantiated.Global")] - internal class QuestData : ExcelRow { - #pragma warning disable 8618 - public string Id { get; set; } - public SeString Text { get; set; } - #pragma warning restore 8618 + [Sheet("")] + public readonly struct QuestData(ExcelPage page, uint offset, uint row) : IExcelRow + { + public uint RowId => row; - public override void PopulateData(RowParser parser, GameData gameData, Language language) { - base.PopulateData(parser, gameData, language); + public ReadOnlySeString Id => page.ReadString(offset, offset); + public ReadOnlySeString Text => page.ReadString(offset + 4, offset); - this.Id = parser.ReadColumn(0)!; - this.Text = parser.ReadColumn(1)!; - } + static QuestData IExcelRow.Create(ExcelPage page, uint offset, uint row) => + new(page, offset, row); } } diff --git a/QuestMap/QuestMap.csproj b/QuestMap/QuestMap.csproj index d194fed..b293e0a 100755 --- a/QuestMap/QuestMap.csproj +++ b/QuestMap/QuestMap.csproj @@ -49,7 +49,7 @@ - + diff --git a/QuestMap/Quests.cs b/QuestMap/Quests.cs index ad6a404..92c70ff 100644 --- a/QuestMap/Quests.cs +++ b/QuestMap/Quests.cs @@ -4,21 +4,21 @@ using System.Numerics; using System.Reflection; using System.Threading; using System.Threading.Channels; +using FFXIVClientStructs.FFXIV.Component.Excel; using ImGuiNET; -using Lumina.Excel; -using Lumina.Excel.GeneratedSheets; +using Lumina.Excel.Sheets; using Microsoft.Msagl.Core.Geometry; using Microsoft.Msagl.Core.Geometry.Curves; using Microsoft.Msagl.Core.Layout; using Microsoft.Msagl.Layout.Layered; using Microsoft.Msagl.Miscellaneous; -using Action = Lumina.Excel.GeneratedSheets.Action; +using Action = Lumina.Excel.Sheets.Action; namespace QuestMap { internal class Quests { private Plugin Plugin { get; } - private Dictionary> AllNodes { get; } + private Dictionary> AllNodes { get; } internal IReadOnlyDictionary> ItemRewards { get; } internal IReadOnlyDictionary EmoteRewards { get; } internal IReadOnlyDictionary ActionRewards { get; } @@ -40,20 +40,20 @@ namespace QuestMap { var jobRewards = new Dictionary(); var linkedInstances = new HashSet(); - var allQuests = new Dictionary(); + var allQuests = new Dictionary(); foreach (var quest in this.Plugin.DataManager.GetExcelSheet()!) { - if (quest.Name.RawString.Length == 0 || quest.RowId == 65536) { + if (quest.Name.ToString().Length == 0 || quest.RowId == 65536) { continue; } - allQuests[quest.RowId] = quest; + allQuests[quest.RowId] = new SheetQuestInfo(quest); - if (quest.EmoteReward.Row != 0) { + if (quest.EmoteReward.RowId != 0) { emoteRewards[quest.RowId] = quest.EmoteReward.Value!; } - foreach (var row in quest.ItemReward.Where(item => item != 0)) { - var item = this.Plugin.DataManager.GetExcelSheet()!.GetRow(row); + foreach (var row in quest.Reward.Where(item => item.RowId != 0)) { + var item = row.GetValueOrDefault(); if (item == null) { continue; } @@ -66,10 +66,10 @@ namespace QuestMap { itemRewards[quest.RowId] = rewards; } - rewards.Add(item); + rewards.Add(item.Value); } - foreach (var row in quest.OptionalItemReward.Where(item => item.Row != 0)) { + foreach (var row in quest.OptionalItemReward.Where(item => item.RowId != 0)) { var item = row.Value; List rewards; @@ -83,7 +83,7 @@ namespace QuestMap { rewards.Add(item!); } - if (quest.ActionReward.Row != 0) { + if (quest.ActionReward.RowId != 0) { actionRewards[quest.RowId] = quest.ActionReward.Value!; } @@ -95,13 +95,13 @@ namespace QuestMap { } } - if (quest.BeastTribe.Row != 0 && !quest.IsRepeatable && quest.BeastReputationRank.Row == 0) { + if (quest.BeastTribe.RowId != 0 && !quest.IsRepeatable && quest.BeastReputationRank.RowId == 0) { beastRewards[quest.RowId] = quest.BeastTribe.Value!; } var jobReward = this.JobUnlocks(quest); if (jobReward != null) { - jobRewards[quest.RowId] = jobReward; + jobRewards[quest.RowId] = jobReward.Value; } } @@ -112,13 +112,13 @@ namespace QuestMap { this.BeastRewards = beastRewards; this.JobRewards = jobRewards; - var (_, nodes) = Node.BuildTree(allQuests); + var (_, nodes) = Node.BuildTree(allQuests); this.AllNodes = nodes; } private static readonly Vector2 TextOffset = new(5, 2); - internal CancellationTokenSource StartGraphRecalculation(ExcelRow quest) { + internal CancellationTokenSource StartGraphRecalculation(Quest quest) { var cts = new CancellationTokenSource(); new Thread(async () => { var info = this.GetGraphInfo(quest, cts.Token); @@ -130,7 +130,7 @@ namespace QuestMap { return cts; } - private GraphInfo? GetGraphInfo(ExcelRow quest, CancellationToken cancel) { + private GraphInfo? GetGraphInfo(Quest quest, CancellationToken cancel) { if (!this.AllNodes.TryGetValue(quest.RowId, out var first)) { return null; } @@ -139,7 +139,7 @@ namespace QuestMap { var links = new List<(uint, uint)>(); var g = new GeometryGraph(); - void AddNode(Node node) { + void AddNode(Node node) { if (msaglNodes.ContainsKey(node.Id)) { return; } @@ -149,7 +149,7 @@ namespace QuestMap { g.Nodes.Add(graphNode); msaglNodes[node.Id] = graphNode; - IEnumerable> parents; + IEnumerable> parents; if (this.Plugin.Config.ShowRedundantArrows) { parents = node.Parents; } else { @@ -214,7 +214,7 @@ namespace QuestMap { : new GraphInfo(g, centre); } - private Quest? ConsolidateMsq(Quest quest) { + private IQuestInfo? ConsolidateMsq(IQuestInfo quest) { if (!this.Plugin.Config.CondenseMsq) { return null; } @@ -256,6 +256,7 @@ namespace QuestMap { 70286 => "Growing Light (6.5)", 70289 => "The Coming Dawn (6.55)", 70495 => "Dawntrail (7.0)", + 70786 => "Crossroads (7.1)", _ => null, }; @@ -263,13 +264,7 @@ namespace QuestMap { return null; } - var newQuest = new Quest(); - foreach (var property in newQuest.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public)) { - property.SetValue(newQuest, property.GetValue(quest)); - } - - newQuest.Name = new Lumina.Text.SeString($"{name} MSQ"); - return newQuest; + return new ConsolidatedQuestInfo(quest, $"{name} MSQ"); } private HashSet InstanceUnlocks(Quest quest, ICollection others) { @@ -279,52 +274,50 @@ namespace QuestMap { var unlocks = new HashSet(); - if (quest.InstanceContentUnlock.Row != 0) { - var cfc = this.Plugin.DataManager.GetExcelSheet()!.FirstOrDefault(cfc => cfc.Content == quest.InstanceContentUnlock.Row && cfc.ContentLinkType == 1); - if (cfc != null && cfc.UnlockQuest.Row == 0) { - unlocks.Add(cfc); + if (quest.InstanceContentUnlock.RowId != 0) { + var cfc = this.Plugin.DataManager.GetExcelSheet().Cast().FirstOrDefault(cfc => cfc.Value.Content.RowId == quest.InstanceContentUnlock.RowId && cfc.Value.ContentLinkType == 1); + if (cfc != null && cfc.Value.UnlockQuest.RowId == 0) { + unlocks.Add(cfc.Value); } } - var instanceRefs = quest.ScriptInstruction - .Zip(quest.ScriptArg, (ins, arg) => (ins, arg)) - .Where(x => x.ins.RawString.StartsWith("INSTANCEDUNGEON")); + var instanceRefs = quest.QuestParams + .Where(x => x.ScriptInstruction.ToString().StartsWith("INSTANCEDUNGEON")); foreach (var reference in instanceRefs) { - var key = reference.arg; + var key = reference.ScriptArg; // var content = this.Plugin.Interface.Data.GetExcelSheet().GetRow(key); - var cfc = this.Plugin.DataManager.GetExcelSheet()!.FirstOrDefault(cfc => cfc.Content == key && cfc.ContentLinkType == 1); - if (cfc == null || cfc.UnlockQuest.Row != 0 || others.Contains(cfc)) { + var cfc = this.Plugin.DataManager.GetExcelSheet().Cast().FirstOrDefault(cfc => cfc.Value.Content.RowId == key && cfc.Value.ContentLinkType == 1); + if (cfc == null || cfc.Value.UnlockQuest.RowId != 0 || others.Contains(cfc.Value)) { continue; } - if (!quest.ScriptInstruction.Any(i => i.RawString == "UNLOCK_ADD_NEW_CONTENT_TO_CF" || i.RawString.StartsWith("UNLOCK_DUNGEON"))) { - if (quest.ScriptInstruction.Any(i => i.RawString.StartsWith("LOC_ITEM"))) { + if (!quest.QuestParams.Any(i => i.ScriptInstruction.ToString() == "UNLOCK_ADD_NEW_CONTENT_TO_CF" || i.ScriptInstruction.ToString().StartsWith("UNLOCK_DUNGEON"))) { + if (quest.QuestParams.Any(i => i.ScriptInstruction.ToString().StartsWith("LOC_ITEM"))) { continue; } } - unlocks.Add(cfc); + unlocks.Add(cfc.Value); } return unlocks; } private ClassJob? JobUnlocks(Quest quest) { - if (quest.ClassJobUnlock.Row > 0) { + if (quest.ClassJobUnlock.RowId > 0) { return quest.ClassJobUnlock.Value; } - if (quest.ScriptInstruction.All(ins => ins.RawString.StartsWith("UNLOCK_IMAGE_CLASS"))) { + if (quest.QuestParams.All(ins => ins.ScriptInstruction.ToString().StartsWith("UNLOCK_IMAGE_CLASS"))) { return null; } - var jobId = quest.ScriptInstruction - .Zip(quest.ScriptArg, (ins, arg) => (ins, arg)) - .FirstOrDefault(entry => entry.ins.RawString.StartsWith("CLASSJOB")) - .arg; + var jobId = quest.QuestParams.Cast() + .FirstOrDefault(entry => entry.Value.ScriptInstruction.ToString().StartsWith("CLASSJOB")) + ?.ScriptArg ?? 0; return jobId == 0 ? null : this.Plugin.DataManager.GetExcelSheet()!.GetRow(jobId); diff --git a/QuestMap/packages.lock.json b/QuestMap/packages.lock.json index 64f3cfe..08c152b 100755 --- a/QuestMap/packages.lock.json +++ b/QuestMap/packages.lock.json @@ -10,9 +10,9 @@ }, "DalamudPackager": { "type": "Direct", - "requested": "[2.1.13, )", - "resolved": "2.1.13", - "contentHash": "rMN1omGe8536f4xLMvx9NwfvpAc9YFFfeXJ1t4P4PE6Gu8WCIoFliR1sh07hM+bfODmesk/dvMbji7vNI+B/pQ==" + "requested": "[11.0.0, )", + "resolved": "11.0.0", + "contentHash": "bjT7XUlhIJSmsE/O76b7weUX+evvGQctbQB8aKXt94o+oPWxHpCepxAGMs7Thow3AzCyqWs7cOpp9/2wcgRRQA==" }, "System.Threading.Channels": { "type": "Direct",