master #3

Open
cacahuetes wants to merge 640 commits from liza/Questionable:master into cacahuetes-ShB-Healer
11 changed files with 47 additions and 19 deletions
Showing only changes of commit e4b5ccec36 - Show all commits

View File

@ -50,7 +50,8 @@
},
"TerritoryId": 613,
"InteractionType": "WalkTo",
"$": "Sui-no-Sato, NE inside"
"$": "Sui-no-Sato, NE inside",
"RestartNavigationIfCancelled": false
},
{
"Position": {
@ -122,7 +123,8 @@
},
"TerritoryId": 613,
"InteractionType": "WalkTo",
"$": "Sui-no-Sato, NE outside"
"$": "Sui-no-Sato, NE outside",
"RestartNavigationIfCancelled": false
},
{
"DataId": 1023280,

View File

@ -23,7 +23,8 @@
},
"TerritoryId": 613,
"InteractionType": "WalkTo",
"$": "Sui-no-Sato, NE outside"
"$": "Sui-no-Sato, NE outside",
"RestartNavigationIfCancelled": false
},
{
"DataId": 1023280,

View File

@ -85,7 +85,8 @@
},
"TerritoryId": 613,
"InteractionType": "WalkTo",
"$": "Sui-no-Sato, NE outside"
"$": "Sui-no-Sato, NE outside",
"RestartNavigationIfCancelled": false
},
{
"DataId": 1023280,

View File

@ -91,6 +91,7 @@
"TerritoryId": 613,
"InteractionType": "WalkTo",
"$": "Exile, outside",
"RestartNavigationIfCancelled": false,
"Fly": true
},
{
@ -164,6 +165,7 @@
"TerritoryId": 613,
"InteractionType": "WalkTo",
"$": "Sui-no-Sato, SW outside",
"RestartNavigationIfCancelled": false,
"Fly": true
},
{

View File

@ -49,7 +49,8 @@
},
"TerritoryId": 613,
"InteractionType": "WalkTo",
"$": "Sui-no-Sato, NE outside"
"$": "Sui-no-Sato, NE outside",
"RestartNavigationIfCancelled": false
},
{
"DataId": 1019970,

View File

@ -28,7 +28,8 @@
},
"TerritoryId": 613,
"InteractionType": "WalkTo",
"$": "Sui-no-Sato, NE inside"
"$": "Sui-no-Sato, NE inside",
"RestartNavigationIfCancelled": false
},
{
"DataId": 1019978,

View File

@ -92,6 +92,10 @@
"type": "boolean",
"description": "Most interactions with objects are checked for a Y (height) difference of 2 in-game units. If set to true, the game won't attempt to get any closer if the height difference is larger than this."
},
"RestartNavigationIfCancelled": {
"type": "boolean",
"description": "For some specific loading screen transitions (e.g. when entering/leaving the water through the portals in the ruby sea), setting this to 'false' means it won't re-attempt to move to the portal after the loading animation"
},
"TerritoryId": {
"type": "integer",
"description": "The territory id associated with the location",

View File

@ -36,6 +36,7 @@ public sealed class QuestStep
public bool? Land { get; set; }
public bool? Sprint { get; set; }
public bool? IgnoreDistanceToObject { get; set; }
public bool? RestartNavigationIfCancelled { get; set; }
public string? Comment { get; set; }
/// <summary>

View File

@ -151,7 +151,7 @@ internal sealed class MovementController : IDisposable
if (IsPathRunning && Destination != null)
{
if (_gameFunctions.IsLoadingScreenVisible(false))
if (_gameFunctions.IsLoadingScreenVisible())
{
_logger.LogInformation("Stopping movement, loading screen visible");
Stop();

View File

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Numerics;
using Dalamud.Game.ClientState.Conditions;
@ -67,7 +68,7 @@ internal static class MoveTo
public ITask Move(MoveParams moveParams)
{
return new MoveInternal(moveParams, movementController, gameFunctions,
loggerFactory.CreateLogger<MoveInternal>(), condition, dataManager);
loggerFactory.CreateLogger<MoveInternal>(), condition, clientState, dataManager);
}
public ITask Land()
@ -163,20 +164,24 @@ internal static class MoveTo
private readonly MovementController _movementController;
private readonly ILogger<MoveInternal> _logger;
private readonly ICondition _condition;
private readonly IClientState _clientState;
private readonly Action _startAction;
private readonly Vector3 _destination;
private readonly MoveParams _moveParams;
public MoveInternal(MoveParams moveParams,
MovementController movementController,
GameFunctions gameFunctions,
ILogger<MoveInternal> logger,
ICondition condition,
IClientState clientState,
IDataManager dataManager)
{
_movementController = movementController;
_logger = logger;
_condition = condition;
_clientState = clientState;
_cannotExecuteAtThisTime = dataManager.GetString<LogMessage>(579, x => x.Text)!;
_destination = moveParams.Destination;
@ -206,6 +211,8 @@ internal static class MoveTo
ignoreDistanceToObject: moveParams.IgnoreDistanceToObject,
land: moveParams.Land);
}
_moveParams = moveParams;
}
public bool Start()
@ -224,6 +231,15 @@ internal static class MoveTo
if (movementStartedAt == DateTime.MaxValue || movementStartedAt.AddSeconds(2) >= DateTime.Now)
return ETaskResult.StillRunning;
if (_moveParams.RestartNavigation &&
Vector3.Distance(_clientState.LocalPlayer!.Position, _destination) >
(_moveParams.StopDistance ?? QuestStep.DefaultStopDistance) + 5f)
{
_logger.LogInformation("Looks like movement was interrupted, re-attempting to move");
_startAction();
return ETaskResult.StillRunning;
}
return ETaskResult.TaskComplete;
}
@ -248,7 +264,8 @@ internal static class MoveTo
bool Sprint = true,
bool Fly = false,
bool Land = false,
bool IgnoreDistanceToObject = false)
bool IgnoreDistanceToObject = false,
bool RestartNavigation = true)
{
public MoveParams(QuestStep step, Vector3 destination)
: this(step.TerritoryId,
@ -259,7 +276,8 @@ internal static class MoveTo
step.Sprint != false,
step.Fly == true,
step.Land == true,
step.IgnoreDistanceToObject == true)
step.IgnoreDistanceToObject == true,
step.RestartNavigationIfCancelled != false)
{
}
}

View File

@ -398,7 +398,7 @@ internal sealed unsafe class GameFunctions
if (!_clientState.IsLoggedIn || _clientState.LocalPlayer == null)
return true;
if (IsLoadingScreenVisible(true))
if (IsLoadingScreenVisible())
return true;
if (_condition[ConditionFlag.Crafting])
@ -438,19 +438,16 @@ internal sealed unsafe class GameFunctions
flags.Contains(ConditionFlag.OccupiedInQuestEvent);
}
public bool IsLoadingScreenVisible(bool all)
public bool IsLoadingScreenVisible()
{
if (_gameGui.TryGetAddonByName("FadeMiddle", out AtkUnitBase* fade) && LAddon.IsAddonReady(fade) && fade->IsVisible)
return true;
if (all)
{
if (_gameGui.TryGetAddonByName("FadeBack", out fade) && LAddon.IsAddonReady(fade) && fade->IsVisible)
return true;
if (_gameGui.TryGetAddonByName("FadeBack", out fade) && LAddon.IsAddonReady(fade) && fade->IsVisible)
return true;
if (_gameGui.TryGetAddonByName("NowLoading", out fade) && LAddon.IsAddonReady(fade) && fade->IsVisible)
return true;
}
if (_gameGui.TryGetAddonByName("NowLoading", out fade) && LAddon.IsAddonReady(fade) && fade->IsVisible)
return true;
return false;
}