Add retry to opening the journal for initiating leves

pull/15/head
Liza 2024-08-08 15:09:19 +02:00
parent f7886d5969
commit 3f07ae797b
Signed by: liza
GPG Key ID: 7199F8D727D55F67
2 changed files with 16 additions and 7 deletions

View File

@ -36,6 +36,7 @@ internal static class InitiateLeve
{
private ElementId _elementId = null!;
private uint _questType;
private DateTime _openedAt = DateTime.MinValue;
public ITask With(ElementId elementId)
{
@ -47,19 +48,25 @@ internal static class InitiateLeve
public bool Start()
{
AgentQuestJournal.Instance()->OpenForQuest(_elementId.Value, _questType);
_openedAt = DateTime.Now;
return true;
}
public ETaskResult Update()
{
AgentQuestJournal* agentQuestJournal = AgentQuestJournal.Instance();
if (!agentQuestJournal->IsAgentActive())
return ETaskResult.StillRunning;
if (agentQuestJournal->IsAgentActive() &&
agentQuestJournal->SelectedQuestId == _elementId.Value &&
agentQuestJournal->SelectedQuestType == _questType)
return ETaskResult.TaskComplete;
return agentQuestJournal->SelectedQuestId == _elementId.Value &&
agentQuestJournal->SelectedQuestType == _questType
? ETaskResult.TaskComplete
: ETaskResult.StillRunning;
if (DateTime.Now > _openedAt.AddSeconds(3))
{
AgentQuestJournal.Instance()->OpenForQuest(_elementId.Value, _questType);
_openedAt = DateTime.Now;
}
return ETaskResult.StillRunning;
}
public override string ToString() => $"OpenJournal({_elementId})";
@ -118,5 +125,7 @@ internal static class InitiateLeve
return ETaskResult.StillRunning;
}
public override string ToString() => "SelectLeveDifficulty";
}
}

View File

@ -1,6 +1,6 @@
<Project Sdk="Dalamud.NET.Sdk/10.0.0">
<PropertyGroup>
<Version>2.3</Version>
<Version>2.4</Version>
<OutputPath>dist</OutputPath>
<PathMap Condition="$(SolutionDir) != ''">$(SolutionDir)=X:\</PathMap>
<Platforms>x64</Platforms>