From 2a4ce09cda15ad09f7431c92271c7119d2c279a5 Mon Sep 17 00:00:00 2001 From: Liza Carvelli Date: Mon, 26 Aug 2024 11:11:44 +0200 Subject: [PATCH] Handle specific dialogue interactions while in a duty --- .../Controller/GameUi/InteractionUiController.cs | 7 ++++++- Questionable/Data/TerritoryData.cs | 10 ++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/Questionable/Controller/GameUi/InteractionUiController.cs b/Questionable/Controller/GameUi/InteractionUiController.cs index 64c178328..e630d7d6d 100644 --- a/Questionable/Controller/GameUi/InteractionUiController.cs +++ b/Questionable/Controller/GameUi/InteractionUiController.cs @@ -42,6 +42,7 @@ internal sealed class InteractionUiController : IDisposable private readonly GatheringPointRegistry _gatheringPointRegistry; private readonly QuestRegistry _questRegistry; private readonly QuestData _questData; + private readonly TerritoryData _territoryData; private readonly IGameGui _gameGui; private readonly ITargetManager _targetManager; private readonly IClientState _clientState; @@ -61,6 +62,7 @@ internal sealed class InteractionUiController : IDisposable GatheringPointRegistry gatheringPointRegistry, QuestRegistry questRegistry, QuestData questData, + TerritoryData territoryData, IGameGui gameGui, ITargetManager targetManager, IPluginLog pluginLog, @@ -77,6 +79,7 @@ internal sealed class InteractionUiController : IDisposable _gatheringPointRegistry = gatheringPointRegistry; _questRegistry = questRegistry; _questData = questData; + _territoryData = territoryData; _gameGui = gameGui; _targetManager = targetManager; _clientState = clientState; @@ -101,7 +104,9 @@ internal sealed class InteractionUiController : IDisposable } } - private bool ShouldHandleUiInteractions => _isInitialCheck || _questController.IsRunning; + private bool ShouldHandleUiInteractions => _isInitialCheck || + _questController.IsRunning || + _territoryData.IsQuestBattleInstance(_clientState.TerritoryType); internal unsafe void HandleCurrentDialogueChoices() { diff --git a/Questionable/Data/TerritoryData.cs b/Questionable/Data/TerritoryData.cs index 0175cf6de..0b20d9a9e 100644 --- a/Questionable/Data/TerritoryData.cs +++ b/Questionable/Data/TerritoryData.cs @@ -12,7 +12,7 @@ internal sealed class TerritoryData { private readonly ImmutableDictionary _territoryNames; private readonly ImmutableHashSet _territoriesWithMount; - private readonly ImmutableHashSet _dutyTerritories; + private readonly ImmutableDictionary _dutyTerritories; private readonly ImmutableDictionary _instanceNames; public TerritoryData(IDataManager dataManager) @@ -35,8 +35,7 @@ internal sealed class TerritoryData _dutyTerritories = dataManager.GetExcelSheet()! .Where(x => x.RowId > 0 && x.ContentFinderCondition.Row != 0) - .Select(x => (ushort)x.RowId) - .ToImmutableHashSet(); + .ToImmutableDictionary(x => (ushort)x.RowId, x => x.ContentFinderCondition.Value!.ContentType.Row); _instanceNames = dataManager.GetExcelSheet()! .Where(x => x.RowId > 0 && x.Content != 0 && x.ContentLinkType == 1 && x.ContentType.Row != 6) @@ -56,7 +55,10 @@ internal sealed class TerritoryData public bool CanUseMount(ushort territoryId) => _territoriesWithMount.Contains(territoryId); - public bool IsDutyInstance(ushort territoryId) => _dutyTerritories.Contains(territoryId); + public bool IsDutyInstance(ushort territoryId) => _dutyTerritories.ContainsKey(territoryId); + + public bool IsQuestBattleInstance(ushort territoryId) => + _dutyTerritories.TryGetValue(territoryId, out uint contentType) && contentType == 7; public string? GetInstanceName(ushort instanceId) => _instanceNames.GetValueOrDefault(instanceId); }