private IEnumerable <TeleportLocation> GetAetheryteList() { if (AetheryteListAddress == IntPtr.Zero || !_plugin.IsLoggedIn) { yield break; } var ptr = _getAvalibleLocationList?.Invoke(AetheryteListAddress, 0) ?? IntPtr.Zero; if (ptr == IntPtr.Zero) { yield break; } var start = Marshal.ReadIntPtr(ptr, 0); var end = Marshal.ReadIntPtr(ptr, 8); var size = Marshal.SizeOf <TeleportLocationStruct>(); var count = (int)((end.ToInt64() - start.ToInt64()) / size); var language = _plugin.Language; for (var i = 0; i < count; i++) { var data = Marshal.PtrToStructure <TeleportLocationStruct>(start + i * size); var name = AetheryteDataManager.GetAetheryteName(data.AetheryteId, data.SubIndex, language); yield return(new TeleportLocation(data, name)); } }
public void Teleport(string aetheryteName, bool matchPartial, bool useMapName = false) { try { if (useMapName) { var name = AetheryteDataManager.GetAetheryteLocationsByTerritoryName(aetheryteName, _plugin.Language, matchPartial).FirstOrDefault()?.Name; if (name == null) { _plugin.LogError($"No Aetheryte found for Map '{aetheryteName}'."); return; } aetheryteName = name; } var location = GetLocationByName(aetheryteName, matchPartial); if (location == null) { _plugin.LogError($"No attuned Aetheryte found for '{aetheryteName}'."); if (!_plugin.IsInHomeWorld && aetheryteName.Contains('(')) { _plugin.Log("Note: Estate Teleports not available while visiting other Worlds."); } return; } _plugin.Log($"Teleporting to '{location.Name}'."); _sendCommand?.Invoke(0xCA, location.AetheryteId, false, location.SubIndex, 0); } catch { _plugin.LogError("Error in Teleport(string,bool)"); } }
public void TeleportTicket(string aetheryteName, bool skipPopup, bool matchPartial, bool useMapName = false) { try { _tpTicketHook?.Disable(); if (useMapName) { var name = AetheryteDataManager.GetAetheryteLocationsByTerritoryName(aetheryteName, _plugin.Language, matchPartial).FirstOrDefault()?.Name; if (name == null) { _plugin.LogError($"No Aetheryte found for Map '{aetheryteName}'."); return; } aetheryteName = name; } var location = GetLocationByName(aetheryteName, matchPartial); if (location == null) { _plugin.LogError($"No attuned Aetheryte found for '{aetheryteName}'."); if (!_plugin.IsInHomeWorld && aetheryteName.Contains('(')) { _plugin.Log("Note: Estate Teleports not available while visiting other Worlds."); } return; } if (skipPopup) { var tickets = GetAetheryteTicketCount(); if (tickets > 0) { _plugin.Log($"Teleporting to '{location.Name}'. (Tickets: {tickets})"); _sendCommand?.Invoke(0xCA, location.AetheryteId, true, location.SubIndex, 0); return; } } else { bool?result = false; if (TeleportStatusAddress != IntPtr.Zero) { result = _tryTeleportWithTicket?.Invoke(TeleportStatusAddress, location.AetheryteId, location.SubIndex); } if (result == true) { _plugin.Log($"Teleporting to '{location.Name}'."); return; } } _plugin.Log($"Teleporting to '{location.Name}'. (Not using Tickets)"); _sendCommand?.Invoke(0xCA, location.AetheryteId, false, location.SubIndex, 0); } catch { _plugin.LogError("Error in TeleportTicket(string,bool,bool)"); } finally { _tpTicketHook?.Enable(); } }