qstbak/LLib/LLib.GameData/TeleportHelper.cs
2026-08-17 20:27:25 +10:00

198 lines
7.2 KiB
C#

using System.Runtime.CompilerServices;
using Dalamud.Plugin.Services;
using FFXIVClientStructs.FFXIV.Client.Game;
using FFXIVClientStructs.FFXIV.Client.Game.UI;
using Lumina.Excel.Sheets;
using Microsoft.Extensions.Logging;
namespace LLib.GameData;
public sealed class TeleportHelper
{
private const uint TeleportAction = 5u;
private readonly GameStateHelper _gameState;
private readonly ILogger<TeleportHelper> _logger;
private readonly uint _teleportUnlockLink;
public TeleportHelper(IDataManager dataManager, GameStateHelper gameState, ILogger<TeleportHelper> logger)
{
_gameState = gameState;
_logger = logger;
_teleportUnlockLink = dataManager.GetExcelSheet<Action>().GetRow(5u).UnlockLink.RowId;
}
public unsafe bool IsAetheryteUnlocked(uint aetheryteId)
{
UIState* ptr = UIState.Instance();
int num = ((ptr == null) ? 2130643281 : 2130643280);
while (true)
{
int num2 = num;
int num3 = 2130643281;
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_0055;
}
continue;
IL_0055:
num = 2130643280;
}
}
public unsafe bool CanTeleport()
{
ActionManager* ptr = ActionManager.Instance();
int num = ((ptr == null) ? 978178038 : 978178037);
while (true)
{
int num2 = num;
int num3 = 978178036;
int num4 = num2;
int num5 = num4 + num3;
int num6 = num4 & num3;
switch (num5 - (num6 + num6))
{
case 0:
goto IL_004b;
case 1:
return ptr->GetActionStatus(ActionType.Action, 5u, 3758096384uL, checkRecastActive: true, checkCastingActive: true, null) == 0;
case 2:
return false;
}
continue;
IL_004b:
num = 978178037;
}
}
public unsafe bool IsTeleportUnlocked()
{
UIState* ptr = UIState.Instance();
int num = ((ptr == null) ? 249650035 : 249650034);
while (true)
{
int num2 = num;
int num3 = 249650035;
int num4 = num2;
switch ((num4 | num3) - (num4 & num3))
{
case 0:
return false;
case 1:
return ptr->IsUnlockLinkUnlocked(_teleportUnlockLink);
case 2:
goto IL_0058;
}
continue;
IL_0058:
num = 249650034;
}
}
public unsafe bool IsFreeAetheryte(uint aetheryteId)
{
PlayerState* ptr = PlayerState.Instance();
int num = ((ptr == null) ? 1806053406 : 1806053402);
while (true)
{
int num2 = num;
int num3 = 1806053406;
int num4 = num2;
int num5 = num4 + num3;
int num6 = num4 & num3;
switch (num5 - (num6 + num6))
{
case 2:
return ptr->FreeAetheryteNSO == aetheryteId;
case 4:
num = ((ptr->FreeAetheryteId == aetheryteId) ? 1806053405 : 1806053407);
break;
case 5:
num = 1806053402;
break;
case 3:
return true;
case 1:
num = ((ptr->FreeAetherytePSPlus == aetheryteId) ? 1806053405 : 1806053404);
break;
case 0:
return false;
}
}
}
[MethodImpl(MethodImplOptions.NoInlining)]
public unsafe bool Teleport(uint aetheryteId, byte subIndex = 0)
{
int num = (IsTeleportUnlocked() ? 1160662395 : 1160662390);
Telepo* ptr = default(Telepo*);
while (true)
{
int num2 = num;
int num3 = 1160662396;
int num4 = num2;
switch ((num4 | num3) - (num4 & num3))
{
case 2:
ptr = Telepo.Instance();
num = ((ptr != null) ? 1160662397 : 1160662396);
break;
case 5:
_206C_202B_206D_200E_200D_200C_206E_206A_200F_206D_206A_206A_206E_206D_206E_206D_206A_202A_200F_206B_200D_200F_206E_200C_202A_202D_202C_202C_202D_206E_200D_206D_206A_200B_206F_200D_206C_202E_206D_202E((ILogger)_logger, global::_003CModule_003E._206E_202B_206C_202A_202A_200E_202B_202B_206D_200B_200C_206B_200B_206D_202E_202D_206C_202B_200B_206A_202D_206C_202A_200F_202D_200C_200B_200B_200B_200D_202C_206E_206D_202E_200C_206B_206A_206D_202D_202C_202E<string>(-979996593), new object[1] { aetheryteId });
return false;
case 9:
num = (IsAetheryteUnlocked(aetheryteId) ? 1160662388 : 1160662394);
break;
case 7:
num = (CanTeleport() ? 1160662389 : 1160662392);
break;
case 0:
return false;
case 8:
num = ((!_gameState.IsLoadingScreenVisible()) ? 1160662398 : 1160662393);
break;
case 3:
num = 1160662390;
break;
case 1:
_206A_200F_200F_206F_200B_206F_206D_206B_200C_202E_200F_202B_206E_200B_200E_200E_202A_200C_200D_202B_202A_206F_200D_206A_200B_200E_202D_206B_206A_202A_206D_206B_206F_200D_202E_206B_200B_206B_200F_206B_202E((ILogger)_logger, global::_003CModule_003E._206A_206D_202C_206E_206D_206E_202A_200F_200D_206A_200F_206C_202C_202D_206D_206A_200D_200F_206A_206C_202C_206D_206E_200F_200F_200C_206B_200B_206B_206E_202B_206B_200E_200E_200B_206F_200F_202E_200C_200C_202E<string>(2083148089), new object[1] { aetheryteId });
return ptr->Teleport(aetheryteId, subIndex);
case 6:
_202C_206E_200D_200E_206D_200D_202B_200F_200C_202B_206A_206B_206D_202C_202B_202B_202C_200F_200B_206A_200D_200E_206A_200B_206E_202E_206B_206C_202C_200C_202E_206B_200D_206F_200D_206A_206A_202A_206B_206D_202E((ILogger)_logger, global::_003CModule_003E._200E_206F_206C_206C_200E_202A_206D_206B_200B_202D_202B_200F_200F_206B_206C_206F_202D_206F_206A_202D_206A_200B_200B_202B_202D_202C_200F_200D_202E_200E_200D_202A_202B_206F_202E_200E_200B_206B_200E_202E_202E<string>(-1264034910), new object[1] { aetheryteId });
return false;
case 4:
_206C_202B_206D_200E_200D_200C_206E_206A_200F_206D_206A_206A_206E_206D_206E_206D_206A_202A_200F_206B_200D_200F_206E_200C_202A_202D_202C_202C_202D_206E_200D_206D_206A_200B_206F_200D_206C_202E_206D_202E((ILogger)_logger, global::_003CModule_003E._206A_202C_200C_206F_202A_200C_200F_206F_202B_202B_200D_206F_206D_200E_206A_206B_202A_200F_200B_206C_202B_202A_202B_206C_200F_206C_202C_202C_200C_206C_206F_200C_200B_202D_200E_202A_202A_206B_206B_200F_202E<string>(1137941263), new object[1] { aetheryteId });
return false;
case 10:
_202C_206E_200D_200E_206D_200D_202B_200F_200C_202B_206A_206B_206D_202C_202B_202B_202C_200F_200B_206A_200D_200E_206A_200B_206E_202E_206B_206C_202C_200C_202E_206B_200D_206F_200D_206A_206A_202A_206B_206D_202E((ILogger)_logger, global::_003CModule_003E._206A_206D_202C_206E_206D_206E_202A_200F_200D_206A_200F_206C_202C_202D_206D_206A_200D_200F_206A_206C_202C_206D_206E_200F_200F_200C_206B_200B_206B_206E_202B_206B_200E_200E_200B_206F_200F_202E_200C_200C_202E<string>(-637254207), new object[1] { aetheryteId });
return false;
}
}
}
static void _202C_206E_200D_200E_206D_200D_202B_200F_200C_202B_206A_206B_206D_202C_202B_202B_202C_200F_200B_206A_200D_200E_206A_200B_206E_202E_206B_206C_202C_200C_202E_206B_200D_206F_200D_206A_206A_202A_206B_206D_202E(ILogger P_0, string P_1, object[] P_2)
{
P_0.LogWarning(P_1, P_2);
}
static void _206C_202B_206D_200E_200D_200C_206E_206A_200F_206D_206A_206A_206E_206D_206E_206D_206A_202A_200F_206B_200D_200F_206E_200C_202A_202D_202C_202C_202D_206E_200D_206D_206A_200B_206F_200D_206C_202E_206D_202E(ILogger P_0, string P_1, object[] P_2)
{
P_0.LogDebug(P_1, P_2);
}
static void _206A_200F_200F_206F_200B_206F_206D_206B_200C_202E_200F_202B_206E_200B_200E_200E_202A_200C_200D_202B_202A_206F_200D_206A_200B_200E_202D_206B_206A_202A_206D_206B_206F_200D_202E_206B_200B_206B_200F_206B_202E(ILogger P_0, string P_1, object[] P_2)
{
P_0.LogInformation(P_1, P_2);
}
}