61 lines
1.6 KiB
C#
61 lines
1.6 KiB
C#
using System;
|
|
using Dalamud.Game.ClientState.Conditions;
|
|
using Dalamud.Plugin.Services;
|
|
using FFXIVClientStructs.FFXIV.Client.Game;
|
|
using FFXIVClientStructs.FFXIV.Client.Game.Character;
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
namespace Questionable.Controller.Steps.Movement;
|
|
|
|
internal sealed class LandExecutor(IClientState clientState, ICondition condition, ILogger<LandExecutor> logger) : TaskExecutor<LandTask>()
|
|
{
|
|
private bool _landing;
|
|
|
|
private DateTime _continueAt;
|
|
|
|
protected override bool Start()
|
|
{
|
|
if (!condition[ConditionFlag.InFlight])
|
|
{
|
|
logger.LogInformation("Not flying, not attempting to land");
|
|
return false;
|
|
}
|
|
_landing = AttemptLanding();
|
|
_continueAt = DateTime.Now.AddSeconds(0.25);
|
|
return true;
|
|
}
|
|
|
|
public override ETaskResult Update()
|
|
{
|
|
if (DateTime.Now < _continueAt)
|
|
{
|
|
return ETaskResult.StillRunning;
|
|
}
|
|
if (condition[ConditionFlag.InFlight])
|
|
{
|
|
if (!_landing)
|
|
{
|
|
_landing = AttemptLanding();
|
|
_continueAt = DateTime.Now.AddSeconds(0.25);
|
|
}
|
|
return ETaskResult.StillRunning;
|
|
}
|
|
return ETaskResult.TaskComplete;
|
|
}
|
|
|
|
private unsafe bool AttemptLanding()
|
|
{
|
|
Character* ptr = (Character*)(clientState.LocalPlayer?.Address ?? 0);
|
|
if (ptr != null && ActionManager.Instance()->GetActionStatus(ActionType.GeneralAction, 23u, 3758096384uL, checkRecastActive: true, checkCastingActive: true, null) == 0)
|
|
{
|
|
logger.LogInformation("Attempting to land");
|
|
return ActionManager.Instance()->UseAction(ActionType.GeneralAction, 23u, 3758096384uL, 0u, ActionManager.UseActionMode.None, 0u, null);
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public override bool ShouldInterruptOnDamage()
|
|
{
|
|
return false;
|
|
}
|
|
}
|