Add a (dev) option to not load certain quests

This commit is contained in:
Liza 2024-07-15 23:09:09 +02:00
parent d20a768996
commit 202abcf3a8
Signed by: liza
GPG Key ID: 7199F8D727D55F67
4 changed files with 18 additions and 2 deletions

View File

@ -79,6 +79,9 @@ public class QuestSourceGenerator : ISourceGenerator
}
var quest = questNode.Deserialize<QuestRoot>()!;
if (quest.Disabled)
continue;
quests.Add((id, quest));
}

View File

@ -19,6 +19,9 @@
"type": "string"
}
},
"Disabled": {
"type": "boolean"
},
"Comment": {
"type": "string"
},

View File

@ -6,6 +6,7 @@ public sealed class QuestRoot
{
public string Author { get; set; } = null!;
public List<string> Contributors { get; set; } = new();
public bool Disabled { get; set; }
public string? Comment { get; set; }
public List<ushort> TerritoryBlacklist { get; set; } = new();
public List<QuestSequence> QuestSequence { get; set; } = new();

View File

@ -130,7 +130,8 @@ internal sealed class QuestRegistry
var distinctSequenceCount = quest.Root.QuestSequence.Select(x => x.Sequence).Distinct().Count();
if (totalSequenceCount != distinctSequenceCount)
{
_logger.LogWarning("Quest has duplicate sequence numbers: {QuestId} / {QuestName}", quest.QuestId,
_logger.LogWarning("Quest has duplicate sequence numbers: {QuestId} / {QuestName}",
quest.QuestId,
quest.Info.Name);
++foundProblems;
}
@ -196,7 +197,8 @@ internal sealed class QuestRegistry
{
_logger.LogWarning(
"Quest step has duplicate completion flags: {QuestId} / {QuestName} → {Sequence} → {Flags}",
quest.QuestId, quest.Info.Name, sequence.Sequence, string.Join(", ", duplicate.First()));
quest.QuestId, quest.Info.Name, sequence.Sequence,
string.Join(", ", duplicate.First()));
++foundProblems;
}
}
@ -231,6 +233,13 @@ internal sealed class QuestRegistry
Root = JsonSerializer.Deserialize<QuestRoot>(stream)!,
Info = _questData.GetQuestInfo(questId.Value),
};
if (quest.Root.Disabled)
{
_logger.LogWarning("Quest {QuestId} / {QuestName} is disabled and won't be loaded", questId,
quest.Info.Name);
return;
}
_quests[questId.Value] = quest;
}