Move to aethernet shards using a mount if mounts are allowed in the zone

This commit is contained in:
Liza 2024-08-12 16:23:03 +02:00
parent 53c49d6718
commit 28d50dfc81
Signed by: liza
GPG Key ID: 7199F8D727D55F67

View File

@ -2,6 +2,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Numerics; using System.Numerics;
using Dalamud.Game.ClientState.Conditions;
using Dalamud.Plugin.Services; using Dalamud.Plugin.Services;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
@ -33,13 +34,18 @@ internal static class AethernetShortcut
internal sealed class UseAethernetShortcut( internal sealed class UseAethernetShortcut(
ILogger<UseAethernetShortcut> logger, ILogger<UseAethernetShortcut> logger,
AetheryteFunctions aetheryteFunctions, AetheryteFunctions aetheryteFunctions,
GameFunctions gameFunctions,
IClientState clientState, IClientState clientState,
AetheryteData aetheryteData, AetheryteData aetheryteData,
TerritoryData territoryData,
LifestreamIpc lifestreamIpc, LifestreamIpc lifestreamIpc,
MovementController movementController) : ISkippableTask MovementController movementController,
ICondition condition) : ISkippableTask
{ {
private bool _moving; private bool _moving;
private bool _teleported; private bool _teleported;
private bool _triedMounting;
private DateTime _continueAt = DateTime.MinValue;
public EAetheryteLocation From { get; set; } public EAetheryteLocation From { get; set; }
public EAetheryteLocation To { get; set; } public EAetheryteLocation To { get; set; }
@ -123,11 +129,19 @@ internal static class AethernetShortcut
} }
else else
{ {
logger.LogInformation("Moving to aethernet shortcut"); if (territoryData.CanUseMount(territoryType) &&
_moving = true; aetheryteData.CalculateDistance(playerPosition, territoryType, From) > 30 &&
movementController.NavigateTo(EMovementType.Quest, (uint)From, aetheryteData.Locations[From], !gameFunctions.HasStatusPreventingMount())
false, true, {
AetheryteConverter.IsLargeAetheryte(From) ? 10.9f : 6.9f); _triedMounting = gameFunctions.Mount();
if (_triedMounting)
{
_continueAt = DateTime.Now.AddSeconds(0.5);
return true;
}
}
MoveTo(From);
return true; return true;
} }
} }
@ -140,8 +154,32 @@ internal static class AethernetShortcut
return false; return false;
} }
private void MoveTo(EAetheryteLocation from)
{
logger.LogInformation("Moving to aethernet shortcut");
_moving = true;
movementController.NavigateTo(EMovementType.Quest, (uint)From, aetheryteData.Locations[From],
false, true,
AetheryteConverter.IsLargeAetheryte(From) ? 10.9f : 6.9f);
}
public ETaskResult Update() public ETaskResult Update()
{ {
if (DateTime.Now < _continueAt)
return ETaskResult.StillRunning;
if (_triedMounting)
{
if (condition[ConditionFlag.Mounted])
{
_triedMounting = false;
MoveTo(From);
return ETaskResult.StillRunning;
}
else
return ETaskResult.StillRunning;
}
if (_moving) if (_moving)
{ {
var movementStartedAt = movementController.MovementStartedAt; var movementStartedAt = movementController.MovementStartedAt;