add startsinglequest too

this is probably more useful for my usecases anyway after a bit of testing
This commit is contained in:
Jackson 2025-02-06 00:28:34 +01:00
parent f72fafbf6a
commit e24c28b4a4

View File

@ -15,11 +15,13 @@ internal sealed class QuestionableIpc : IDisposable
private const string IpcGetCurrentQuestId = "Questionable.GetCurrentQuestId"; private const string IpcGetCurrentQuestId = "Questionable.GetCurrentQuestId";
private const string IpcGetCurrentlyActiveEventQuests = "Questionable.GetCurrentlyActiveEventQuests"; private const string IpcGetCurrentlyActiveEventQuests = "Questionable.GetCurrentlyActiveEventQuests";
private const string IpcStartQuest = "Questionable.StartQuest"; private const string IpcStartQuest = "Questionable.StartQuest";
private const string IpcStartSingleQuest = "Questionable.StartSingleQuest";
private readonly ICallGateProvider<bool> _isRunning; private readonly ICallGateProvider<bool> _isRunning;
private readonly ICallGateProvider<string?> _getCurrentQuestId; private readonly ICallGateProvider<string?> _getCurrentQuestId;
private readonly ICallGateProvider<List<string>> _getCurrentlyActiveEventQuests; private readonly ICallGateProvider<List<string>> _getCurrentlyActiveEventQuests;
private readonly ICallGateProvider<string, bool> _startQuest; private readonly ICallGateProvider<string, bool> _startQuest;
private readonly ICallGateProvider<string, bool> _startSingleQuest;
public QuestionableIpc( public QuestionableIpc(
QuestController questController, QuestController questController,
@ -39,14 +41,20 @@ internal sealed class QuestionableIpc : IDisposable
eventInfoComponent.GetCurrentlyActiveEventQuests().Select(q => q.ToString()).ToList()); eventInfoComponent.GetCurrentlyActiveEventQuests().Select(q => q.ToString()).ToList());
_startQuest = pluginInterface.GetIpcProvider<string, bool>(IpcStartQuest); _startQuest = pluginInterface.GetIpcProvider<string, bool>(IpcStartQuest);
_startQuest.RegisterFunc((string questId) => StartQuest(questController, questRegistry, questId)); _startQuest.RegisterFunc((string questId) => StartQuest(questController, questRegistry, questId, false));
_startSingleQuest = pluginInterface.GetIpcProvider<string, bool>(IpcStartSingleQuest);
_startSingleQuest.RegisterFunc((string questId) => StartQuest(questController, questRegistry, questId, true));
} }
private static bool StartQuest(QuestController qc, QuestRegistry qr, string questId) private static bool StartQuest(QuestController qc, QuestRegistry qr, string questId, bool single)
{ {
if (ElementId.TryFromString(questId, out var elementId) && elementId != null && qr.TryGetQuest(elementId, out var quest)) if (ElementId.TryFromString(questId, out var elementId) && elementId != null && qr.TryGetQuest(elementId, out var quest))
{ {
qc.SetNextQuest(quest); qc.SetNextQuest(quest);
if (single)
qc.StartSingleQuest("IPCQuestSelection");
else
qc.Start("IPCQuestSelection"); qc.Start("IPCQuestSelection");
return true; return true;
} }