77 lines
2.2 KiB
C#
77 lines
2.2 KiB
C#
using System.Globalization;
|
|
using System.Numerics;
|
|
using Questionable.Model.Questing;
|
|
|
|
namespace Questionable.Controller.Steps.Movement;
|
|
|
|
internal sealed record MoveTask(ushort TerritoryId, Vector3 Destination, bool? Mount = null, bool MountRequired = false, bool DismountRequired = false, float? StopDistance = null, uint? DataId = null, bool DisableNavmesh = false, bool? Sprint = null, bool Fly = false, bool Land = false, bool IgnoreDistanceToObject = false, bool RestartNavigation = true, EInteractionType InteractionType = EInteractionType.None, bool SmartNavRouted = false, bool AllowZoneTransition = false, string? RouteTargetNodeId = null, string? RouteApproachNodeId = null) : ITask
|
|
{
|
|
public MoveTask(QuestStep step, Vector3 destination)
|
|
: this(step.TerritoryId, destination, ResolveMount(step), step.MountRequired, step.DismountRequired, step.CalculateActualStopDistance(), step.DataId, step.DisableNavmesh, step.Sprint, ResolveFly(step), ResolveLand(step), step.IgnoreDistanceToObject == true, step.RestartNavigationIfCancelled != false, step.InteractionType)
|
|
{
|
|
}
|
|
|
|
private static bool? ResolveMount(QuestStep step)
|
|
{
|
|
if (step.MountRequired)
|
|
{
|
|
return true;
|
|
}
|
|
if (step.DismountRequired)
|
|
{
|
|
return false;
|
|
}
|
|
switch (step.TravelMode)
|
|
{
|
|
case ETravelMode.OnFoot:
|
|
return false;
|
|
case ETravelMode.GroundMount:
|
|
case ETravelMode.Flying:
|
|
return true;
|
|
default:
|
|
return step.Mount;
|
|
}
|
|
}
|
|
|
|
private static bool ResolveFly(QuestStep step)
|
|
{
|
|
if (step.DismountRequired)
|
|
{
|
|
return false;
|
|
}
|
|
switch (step.TravelMode)
|
|
{
|
|
case ETravelMode.OnFoot:
|
|
case ETravelMode.GroundMount:
|
|
return false;
|
|
case ETravelMode.Flying:
|
|
return true;
|
|
default:
|
|
return step.Fly == true;
|
|
}
|
|
}
|
|
|
|
private static bool ResolveLand(QuestStep step)
|
|
{
|
|
ETravelMode travelMode = step.TravelMode;
|
|
bool flag = (uint)(travelMode - 1) <= 1u;
|
|
bool flag2 = !flag;
|
|
if (flag2)
|
|
{
|
|
EArrivalMode arrivalMode = step.ArrivalMode;
|
|
bool flag3 = (uint)(arrivalMode - 2) <= 1u;
|
|
flag2 = flag3 || step.Land == true;
|
|
}
|
|
return flag2;
|
|
}
|
|
|
|
public bool ShouldRedoOnInterrupt()
|
|
{
|
|
return true;
|
|
}
|
|
|
|
public override string ToString()
|
|
{
|
|
return "MoveTo(" + Destination.ToString("G", CultureInfo.InvariantCulture) + ")";
|
|
}
|
|
}
|