diff --git a/Questionable/Controller/GameUi/InteractionUiController.cs b/Questionable/Controller/GameUi/InteractionUiController.cs index 1ea84928..20148073 100644 --- a/Questionable/Controller/GameUi/InteractionUiController.cs +++ b/Questionable/Controller/GameUi/InteractionUiController.cs @@ -98,7 +98,6 @@ internal sealed class InteractionUiController : IDisposable _addonLifecycle.RegisterListener(AddonEvent.PostSetup, "SelectYesno", SelectYesnoPostSetup); _addonLifecycle.RegisterListener(AddonEvent.PostSetup, "PointMenu", PointMenuPostSetup); _addonLifecycle.RegisterListener(AddonEvent.PostSetup, "HousingSelectBlock", HousingSelectBlockPostSetup); - _addonLifecycle.RegisterListener(AddonEvent.PostSetup, "TelepotTown", TeleportTownPostSetup); unsafe { @@ -848,46 +847,6 @@ internal sealed class InteractionUiController : IDisposable addon->FireCallbackInt(0); } - private void TeleportTownPostSetup(AddonEvent type, AddonArgs args) - { - if (ShouldHandleUiInteractions && - _questController.HasCurrentTaskMatching(out AethernetShortcut.Task? aethernetShortcut) && - aethernetShortcut.From.IsFirmamentAetheryte()) - { - // this might be better via atkvalues; but this works for now - uint toIndex = aethernetShortcut.To switch - { - EAetheryteLocation.FirmamentMendicantsCourt => 0, - EAetheryteLocation.FirmamentMattock => 1, - EAetheryteLocation.FirmamentNewNest => 2, - EAetheryteLocation.FirmanentSaintRoellesDais => 3, - EAetheryteLocation.FirmamentFeatherfall => 4, - EAetheryteLocation.FirmamentHoarfrostHall => 5, - EAetheryteLocation.FirmamentWesternRisensongQuarter => 6, - EAetheryteLocation.FIrmamentEasternRisensongQuarter => 7, - _ => uint.MaxValue, - }; - - if (toIndex == uint.MaxValue) - return; - - _logger.LogInformation("Teleporting to {ToName} with menu index {ToIndex}", aethernetShortcut.From, - toIndex); - unsafe - { - var teleportToDestination = stackalloc AtkValue[] - { - new() { Type = ValueType.Int, Int = 11 }, - new() { Type = ValueType.UInt, UInt = toIndex } - }; - - var addon = (AtkUnitBase*)args.Addon; - addon->FireCallback(2, teleportToDestination); - addon->FireCallback(2, teleportToDestination, true); - } - } - } - private StringOrRegex? ResolveReference(Quest? quest, string? excelSheet, ExcelRef? excelRef, bool isRegExp) { if (excelRef == null) @@ -905,7 +864,6 @@ internal sealed class InteractionUiController : IDisposable public void Dispose() { - _addonLifecycle.UnregisterListener(AddonEvent.PostSetup, "TelepotTown", TeleportTownPostSetup); _addonLifecycle.UnregisterListener(AddonEvent.PostSetup, "HousingSelectBlock", HousingSelectBlockPostSetup); _addonLifecycle.UnregisterListener(AddonEvent.PostSetup, "PointMenu", PointMenuPostSetup); _addonLifecycle.UnregisterListener(AddonEvent.PostSetup, "SelectYesno", SelectYesnoPostSetup); diff --git a/Questionable/Controller/Steps/Shared/AethernetShortcut.cs b/Questionable/Controller/Steps/Shared/AethernetShortcut.cs index a1a066f0..bfb2cc3f 100644 --- a/Questionable/Controller/Steps/Shared/AethernetShortcut.cs +++ b/Questionable/Controller/Steps/Shared/AethernetShortcut.cs @@ -205,17 +205,9 @@ internal static class AethernetShortcut private void DoTeleport() { - if (Task.From.IsFirmamentAetheryte()) - { - logger.LogInformation("Using manual teleport interaction"); - _teleported = gameFunctions.InteractWith((uint)Task.From, ObjectKind.EventObj); - } - else - { - logger.LogInformation("Using lifestream to teleport to {Destination}", Task.To); - lifestreamIpc.Teleport(Task.To); - _teleported = true; - } + logger.LogInformation("Using lifestream to teleport to {Destination}", Task.To); + lifestreamIpc.Teleport(Task.To); + _teleported = true; } public override ETaskResult Update() diff --git a/Questionable/External/LifestreamIpc.cs b/Questionable/External/LifestreamIpc.cs index f5bd4544..443d1409 100644 --- a/Questionable/External/LifestreamIpc.cs +++ b/Questionable/External/LifestreamIpc.cs @@ -1,5 +1,9 @@ -using Dalamud.Plugin; +using System.Collections.Generic; +using Dalamud.Plugin; using Dalamud.Plugin.Ipc; +using Dalamud.Plugin.Services; +using Lumina.Excel.Sheets; +using Microsoft.Extensions.Logging; using Questionable.Data; using Questionable.Model.Common; @@ -8,25 +12,40 @@ namespace Questionable.External; internal sealed class LifestreamIpc { private readonly AetheryteData _aetheryteData; + private readonly IDataManager _dataManager; + private readonly ILogger _logger; private readonly ICallGateSubscriber _aethernetTeleport; - public LifestreamIpc(IDalamudPluginInterface pluginInterface, AetheryteData aetheryteData) + public LifestreamIpc(IDalamudPluginInterface pluginInterface, AetheryteData aetheryteData, IDataManager dataManager, ILogger logger) { _aetheryteData = aetheryteData; + _dataManager = dataManager; + _logger = logger; _aethernetTeleport = pluginInterface.GetIpcSubscriber("Lifestream.AethernetTeleport"); } public bool Teleport(EAetheryteLocation aetheryteLocation) { - if (aetheryteLocation == EAetheryteLocation.IshgardFirmament) + string? name = aetheryteLocation switch { - // TODO does this even work on non-EN clients? - return _aethernetTeleport.InvokeFunc("Firmament"); - } + EAetheryteLocation.IshgardFirmament => "Firmament", + EAetheryteLocation.FirmamentMendicantsCourt => GetPlaceName(3436), + EAetheryteLocation.FirmamentMattock => GetPlaceName(3473), + EAetheryteLocation.FirmamentNewNest => GetPlaceName(3475), + EAetheryteLocation.FirmanentSaintRoellesDais => GetPlaceName(3474), + EAetheryteLocation.FirmamentFeatherfall => GetPlaceName(3525), + EAetheryteLocation.FirmamentHoarfrostHall => GetPlaceName(3528), + EAetheryteLocation.FirmamentWesternRisensongQuarter => GetPlaceName(3646), + EAetheryteLocation.FIrmamentEasternRisensongQuarter => GetPlaceName(3645), + _ => _aetheryteData.AethernetNames.GetValueOrDefault(aetheryteLocation), + }; - if (!_aetheryteData.AethernetNames.TryGetValue(aetheryteLocation, out string? name)) + if (name == null) return false; + _logger.LogInformation("Teleporting to '{Name}'", name); return _aethernetTeleport.InvokeFunc(name); } + + private string GetPlaceName(uint rowId) => _dataManager.GetExcelSheet().GetRow(rowId).Name.ToString(); }