Merge pull request 'ipc: fix GetActiveEvents and add StartSingleQuest' (#134) from croizat/Questionable:fixy into master
Reviewed-on: #134
This commit is contained in:
commit
2abf567e9f
14
Questionable/External/QuestionableIpc.cs
vendored
14
Questionable/External/QuestionableIpc.cs
vendored
@ -15,11 +15,13 @@ internal sealed class QuestionableIpc : IDisposable
|
||||
private const string IpcGetCurrentQuestId = "Questionable.GetCurrentQuestId";
|
||||
private const string IpcGetCurrentlyActiveEventQuests = "Questionable.GetCurrentlyActiveEventQuests";
|
||||
private const string IpcStartQuest = "Questionable.StartQuest";
|
||||
private const string IpcStartSingleQuest = "Questionable.StartSingleQuest";
|
||||
|
||||
private readonly ICallGateProvider<bool> _isRunning;
|
||||
private readonly ICallGateProvider<string?> _getCurrentQuestId;
|
||||
private readonly ICallGateProvider<List<string>> _getCurrentlyActiveEventQuests;
|
||||
private readonly ICallGateProvider<string, bool> _startQuest;
|
||||
private readonly ICallGateProvider<string, bool> _startSingleQuest;
|
||||
|
||||
public QuestionableIpc(
|
||||
QuestController questController,
|
||||
@ -39,15 +41,21 @@ internal sealed class QuestionableIpc : IDisposable
|
||||
eventInfoComponent.GetCurrentlyActiveEventQuests().Select(q => q.ToString()).ToList());
|
||||
|
||||
_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))
|
||||
{
|
||||
qc.SetNextQuest(quest);
|
||||
qc.Start("IPCQuestSelection");
|
||||
if (single)
|
||||
qc.StartSingleQuest("IPCQuestSelection");
|
||||
else
|
||||
qc.Start("IPCQuestSelection");
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -139,7 +139,7 @@ internal sealed class EventInfoComponent
|
||||
public IEnumerable<QuestId> GetCurrentlyActiveEventQuests()
|
||||
{
|
||||
return _eventQuests
|
||||
.Where(x => x.EndsAtUtc <= DateTime.UtcNow)
|
||||
.Where(x => x.EndsAtUtc >= DateTime.UtcNow)
|
||||
.SelectMany(x => x.QuestIds);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user