using System; using System.Runtime.CompilerServices; using Dalamud.Game.ClientState.Objects.Types; using Dalamud.Plugin.Services; using FFXIVClientStructs.FFXIV.Client.Game; using FFXIVClientStructs.FFXIV.Client.Game.UI; using LLib.GameData; using Lumina.Excel.Sheets; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using Questionable.Model.Questing; using SmartNav.Model; namespace Questionable.Functions; internal sealed class AetheryteFunctions { private const uint TeleportAction = 5u; private const uint ReturnAction = 6u; private readonly IServiceProvider _serviceProvider; private readonly ILogger _logger; private readonly IDataManager _dataManager; private readonly IObjectTable _objectTable; public long ReturnRequestedAt { get; set; } public AetheryteFunctions(IServiceProvider serviceProvider, ILogger logger, IDataManager dataManager, IObjectTable objectTable) { _serviceProvider = serviceProvider; _logger = logger; _dataManager = dataManager; _objectTable = objectTable; } public unsafe bool IsAetheryteUnlocked(uint aetheryteId, out byte subIndex) { subIndex = 0; UIState* ptr = UIState.Instance(); int num = ((ptr == null) ? 1947729333 : 1947729332); while (true) { int num2 = num; int num3 = 1947729333; int num4 = num2; int num5 = num4 + num3; int num6 = num4 & num3; switch (num5 - (num6 + num6)) { case 0: return false; case 1: return ptr->IsAetheryteUnlocked(aetheryteId); case 2: goto IL_0058; } continue; IL_0058: num = 1947729332; } } public bool IsAetheryteUnlocked(EAetheryteLocation aetheryteLocation) { int num = ((!_206E_206D_200F_200B_200E_202C_206B_206B_202E_200C_200B_200E_206B_206D_206C_200B_200C_206C_202C_202B_202C_206D_206C_200E_200B_202B_206E_206D_202B_206E_200B_206F_200B_206E_202E_206B_200B_200F_202D_202B_202E(aetheryteLocation)) ? (-1602388833) : (-1602388834)); while (true) { int num2 = num; int num3 = -1602388833; int num4 = num2; int num5 = num4 + num3; int num6 = num4 & num3; switch (num5 - (num6 + num6)) { case 2: goto IL_0048; case 0: { byte subIndex; return IsAetheryteUnlocked((uint)aetheryteLocation, out subIndex); } case 1: return _serviceProvider.GetRequiredService().IsQuestComplete(_206B_206E_206B_206B_206D_200D_200E_200B_202B_206D_202E_202C_200B_202D_202A_206D_206C_206E_200D_206C_200C_206A_200C_206E_202D_200C_200D_200F_202A_202D_200F_206D_202A_206D_206E_200B_206F_206F_202D_202E_202E((ushort)3672)); } continue; IL_0048: num = -1602388834; } } public unsafe bool CanTeleport(EAetheryteLocation aetheryteLocation) { int num = (((ushort)aetheryteLocation != _200E_202E_200F_206B_206A_206D_200D_206F_206F_206A_206B_206C_200E_202E_206D_200C_202C_206F_206E_200E_206B_206E_206A_200E_202E_200D_200C_200C_202B_200B_206D_206E_206D_200D_202B_206E_206C_200E_206B_202E_202E()) ? 508143747 : 508143745); while (true) { int num2 = num; int num3 = 508143746; int num4 = num2; int num5 = num4 + num3; int num6 = num4 & num3; switch (num5 - (num6 + num6)) { case 1: return ActionManager.Instance()->GetActionStatus(ActionType.Action, 5u, 3758096384uL, checkRecastActive: true, checkCastingActive: true, null) == 0; case 3: num = ((ActionManager.Instance()->GetActionStatus(ActionType.Action, 6u, 3758096384uL, checkRecastActive: true, checkCastingActive: true, null) != 0) ? 508143747 : 508143746); break; case 0: return true; case 2: num = 508143745; break; } } } public unsafe bool IsTeleportUnlocked() { uint rowId = _dataManager.GetExcelSheet().GetRow(5u).UnlockLink.RowId; UIState* ptr = UIState.Instance(); int num = ((ptr == null) ? 126078724 : 126078727); while (true) { int num2 = num; int num3 = 126078725; int num4 = num2; int num5 = num4 + num3; int num6 = num4 & num3; switch (num5 - (num6 + num6)) { case 1: return false; case 2: return ptr->IsUnlockLinkUnlocked(rowId); case 0: goto IL_008b; } continue; IL_008b: num = 126078727; } } public unsafe bool IsReturnAvailable() { return ActionManager.Instance()->GetActionStatus(ActionType.Action, 6u, 3758096384uL, checkRecastActive: true, checkCastingActive: true, null) == 0; } [MethodImpl(MethodImplOptions.NoInlining)] public unsafe bool TeleportAetheryte(uint aetheryteId) { _202A_206C_206B_200C_200F_202D_206A_200D_200C_202A_200D_206E_206B_206B_202D_202D_200C_206A_202C_206B_206D_206B_202A_202C_200E_200C_206B_200E_206D_206C_200C_202A_206F_200E_200B_202E_206B_202B_200B_202D_202E((ILogger)_logger, global::_003CModule_003E._206C_202A_206D_206A_206E_202A_202B_206F_206D_200F_202D_200F_202D_206A_202C_202B_206D_206A_200E_200E_202D_202D_200D_200C_200D_200D_206D_206E_202A_200F_206E_206C_206D_206A_206D_202B_200F_200D_206E_200C_202E(762406754), new object[1] { aetheryteId }); byte subIndex; int num = ((!IsAetheryteUnlocked(aetheryteId, out subIndex)) ? 1620747025 : 1620747027); while (true) { int num2 = num; int num3 = 1620747030; int num4 = num2; int num5 = num4 + num3; int num6 = num4 & num3; switch (num5 - (num6 + num6)) { case 7: return false; case 6: ReturnRequestedAt = _206C_200F_206F_206E_206C_200D_206F_202A_202C_202B_206F_202C_200F_200D_202B_202E_206B_200E_200E_206A_206E_200F_206A_202C_202D_206B_202C_200F_206C_200D_200B_206B_202A_206A_206D_200D_200C_202D_206B_206D_202E(); num = ((!ActionManager.Instance()->UseAction(ActionType.Action, 6u, 3758096384uL, 0u, ActionManager.UseActionMode.None, 0u, null)) ? 1620747031 : 1620747029); break; case 5: num = ((aetheryteId != _200E_202E_200F_206B_206A_206D_200D_206F_206F_206A_206B_206C_200E_202E_206D_200C_202C_206F_206E_200E_206B_206E_206A_200E_202E_200D_200C_200C_202B_200B_206D_206E_206D_200D_202B_206E_206C_200E_206B_202E_202E()) ? 1620747031 : 1620747030); break; case 0: num = ((ActionManager.Instance()->GetActionStatus(ActionType.Action, 6u, 3758096384uL, checkRecastActive: true, checkCastingActive: true, null) != 0) ? 1620747031 : 1620747024); break; case 2: num = 1620747027; break; case 1: num = ((ActionManager.Instance()->GetActionStatus(ActionType.Action, 5u, 3758096384uL, checkRecastActive: true, checkCastingActive: true, null) != 0) ? 1620747025 : 1620747026); break; case 4: _206F_202E_206E_206B_200E_202D_206B_200B_200E_206B_206C_202B_202D_206C_206A_202B_202A_202D_202D_206B_200C_200D_206F_202D_202A_206B_202A_202A_202D_200F_206A_206B_200B_206C_200F_202A_200B_202E_202A_202E_202E((ILogger)_logger, global::_003CModule_003E._200B_206B_206B_200E_200B_206A_206D_206B_206E_200F_206A_206F_206E_202B_200F_206C_202B_206D_206E_200F_200C_200E_206F_200D_200F_200B_202B_202B_202B_202B_206D_202C_206A_206D_200B_206E_200D_206A_206F_200F_202E(265904157), new object[1] { aetheryteId }); return Telepo.Instance()->Teleport(aetheryteId, subIndex); case 3: _206F_202E_206E_206B_200E_202D_206B_200B_200E_206B_206C_202B_202D_206C_206A_202B_202A_202D_202D_206B_200C_200D_206F_202D_202A_206B_202A_202A_202D_200F_206A_206B_200B_206C_200F_202A_200B_202E_202A_202E_202E((ILogger)_logger, global::_003CModule_003E._202D_206D_206A_206E_202C_202B_200C_206C_200E_206A_206D_200E_206A_202A_200C_202E_206E_202C_206F_200B_206D_206F_200C_202C_200B_202B_200F_200B_206A_206F_200F_202E_206B_200E_202B_202A_200F_200B_202A_200E_202E(1006691700), Array.Empty()); return true; } } } public bool TeleportAetheryte(EAetheryteLocation aetheryteLocation) { return TeleportAetheryte((uint)aetheryteLocation); } public static bool IsFreeAetheryte(EAetheryteLocation aetheryteLocation) { return _206B_200E_200D_202D_202C_202C_206F_200E_202E_202E_202D_206B_206E_200C_206B_206C_200B_200F_200B_206E_206F_206B_200B_202E_200C_206E_206A_206A_202C_202C_206E_202D_206B_206C_206A_206E_200E_206E_206E_202E_202E((uint)aetheryteLocation); } public AetheryteRegistrationResult CanRegisterFreeOrFavoriteAetheryte(EAetheryteLocation aetheryteLocation) { int num = ((_200F_200C_206E_206B_206C_202D_206B_206B_202E_202E_202D_202D_200C_202D_202C_206E_200E_206C_200F_202C_200C_206F_200F_200D_206A_200B_206C_206D_200B_200C_200D_206A_202B_200F_202A_202A_202E_200F_206B_202B_202E(_objectTable, 0) != null) ? (-303811700) : (-303811698)); bool flag = default(bool); while (true) { int num2 = num; int num3 = -303811697; int num4 = num2; switch ((num4 | num3) - (num4 & num3)) { case 5: num = (flag ? (-303811701) : (-303811697)); break; case 3: num = ((!IsFreeAetheryte(aetheryteLocation)) ? (-303811705) : (-303811699)); break; case 0: return AetheryteRegistrationResult.NotPossible; case 9: flag = _206F_206D_200D_202C_206D_202D_202C_202E_206F_202B_200E_200C_202A_206E_200E_206F_200F_206C_206B_200E_206C_200D_202B_202E_202C_202D_200C_202E_206D_200F_202B_200D_206D_200D_206B_200F_200E_200C_206F_200F_202E(); num = ((!_202C_200B_200C_200B_202E_202D_202B_200D_202B_200E_200E_206F_200F_200D_206B_202B_202A_202A_202C_206C_206A_202E_202B_206D_206D_206C_206E_200E_202C_200F_206B_202A_202A_200F_206A_206E_200B_206F_202C_206B_202E(PlayerStateFlag.IsLoginSecurityToken)) ? (-303811702) : (-303811707)); break; case 10: num = ((_206A_202A_200E_202D_200D_206E_206F_206D_206F_200E_202D_200B_206E_202D_200B_206B_206D_202A_200B_206A_202B_206F_202D_200F_206D_206A_200E_202C_200E_202B_200C_202C_200B_200C_202C_202E_202B_206A_206E_200D_202E() != 0) ? (-303811702) : (-303811703)); break; case 4: return AetheryteRegistrationResult.FavoredDestinationAvailable; case 7: num = -303811698; break; case 2: return AetheryteRegistrationResult.NotPossible; case 6: return AetheryteRegistrationResult.SecurityTokenFreeDestinationAvailable; case 8: num = ((!_202E_206F_200B_206A_202D_206D_200F_206F_202B_206F_202C_202D_200E_206C_206D_206B_200D_202C_206F_202C_200B_206A_206B_202A_202B_206A_202C_206A_202A_202B_202C_202A_200C_206F_202C_202D_202B_202E_206D_202E((uint)aetheryteLocation)) ? (-303811706) : (-303811708)); break; case 1: return AetheryteRegistrationResult.NotPossible; case 11: return AetheryteRegistrationResult.NotPossible; } } } static bool _206E_206D_200F_200B_200E_202C_206B_206B_202E_200C_200B_200E_206B_206D_206C_200B_200C_206C_202C_202B_202C_206D_206C_200E_200B_202B_206E_206D_202B_206E_200B_206F_200B_206E_202E_206B_200B_200F_202D_202B_202E(EAetheryteLocation P_0) { return P_0.IsFirmamentAetheryte(); } static QuestId _206B_206E_206B_206B_206D_200D_200E_200B_202B_206D_202E_202C_200B_202D_202A_206D_206C_206E_200D_206C_200C_206A_200C_206E_202D_200C_200D_200F_202A_202D_200F_206D_202A_206D_206E_200B_206F_206F_202D_202E_202E(ushort P_0) { return new QuestId(P_0); } static uint _200E_202E_200F_206B_206A_206D_200D_206F_206F_206A_206B_206C_200E_202E_206D_200C_202C_206F_206E_200E_206B_206E_206A_200E_202E_200D_200C_200C_202B_200B_206D_206E_206D_200D_202B_206E_206C_200E_206B_202E_202E() { return PlayerStateHelper.GetHomeAetheryteId(); } static void _202A_206C_206B_200C_200F_202D_206A_200D_200C_202A_200D_206E_206B_206B_202D_202D_200C_206A_202C_206B_206D_206B_202A_202C_200E_200C_206B_200E_206D_206C_200C_202A_206F_200E_200B_202E_206B_202B_200B_202D_202E(ILogger P_0, string P_1, object[] P_2) { P_0.LogDebug(P_1, P_2); } static long _206C_200F_206F_206E_206C_200D_206F_202A_202C_202B_206F_202C_200F_200D_202B_202E_206B_200E_200E_206A_206E_200F_206A_202C_202D_206B_202C_200F_206C_200D_200B_206B_202A_206A_206D_200D_200C_202D_206B_206D_202E() { return Environment.TickCount64; } static void _206F_202E_206E_206B_200E_202D_206B_200B_200E_206B_206C_202B_202D_206C_206A_202B_202A_202D_202D_206B_200C_200D_206F_202D_202A_206B_202A_202A_202D_200F_206A_206B_200B_206C_200F_202A_200B_202E_202A_202E_202E(ILogger P_0, string P_1, object[] P_2) { P_0.LogInformation(P_1, P_2); } static bool _206B_200E_200D_202D_202C_202C_206F_200E_202E_202E_202D_206B_206E_200C_206B_206C_200B_200F_200B_206E_206F_206B_200B_202E_200C_206E_206A_206A_202C_202C_206E_202D_206B_206C_206A_206E_200E_206E_206E_202E_202E(uint P_0) { return PlayerStateHelper.IsFreeAetheryte(P_0); } static IGameObject _200F_200C_206E_206B_206C_202D_206B_206B_202E_202E_202D_202D_200C_202D_202C_206E_200E_206C_200F_202C_200C_206F_200F_200D_206A_200B_206C_206D_200B_200C_200D_206A_202B_200F_202A_202A_202E_200F_206B_202B_202E(IObjectTable P_0, int P_1) { return P_0[P_1]; } static bool _202E_206F_200B_206A_202D_206D_200F_206F_202B_206F_202C_202D_200E_206C_206D_206B_200D_202C_206F_202C_200B_206A_206B_202A_202B_206A_202C_206A_202A_202B_202C_202A_200C_206F_202C_202D_202B_202E_206D_202E(uint P_0) { return PlayerStateHelper.IsFavouriteAetheryte(P_0); } static bool _206F_206D_200D_202C_206D_202D_202C_202E_206F_202B_200E_200C_202A_206E_200E_206F_200F_206C_206B_200E_206C_200D_202B_202E_202C_202D_200C_202E_206D_200F_202B_200D_206D_200D_206B_200F_200E_200C_206F_200F_202E() { return PlayerStateHelper.HasFavouriteSlotAvailable(); } static bool _202C_200B_200C_200B_202E_202D_202B_200D_202B_200E_200E_206F_200F_200D_206B_202B_202A_202A_202C_206C_206A_202E_202B_206D_206D_206C_206E_200E_202C_200F_206B_202A_202A_200F_206A_206E_200B_206F_202C_206B_202E(PlayerStateFlag P_0) { return PlayerStateHelper.IsPlayerStateFlagSet(P_0); } static uint _206A_202A_200E_202D_200D_206E_206F_206D_206F_200E_202D_200B_206E_202D_200B_206B_206D_202A_200B_206A_202B_206F_202D_200F_206D_206A_200E_202C_200E_202B_200C_202C_200B_200C_202C_202E_202B_206A_206E_200D_202E() { return PlayerStateHelper.GetFreeAetheryteId(); } }