121 lines
5.9 KiB
C#
121 lines
5.9 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Globalization;
|
|
using System.Linq;
|
|
using System.Numerics;
|
|
using System.Runtime.InteropServices;
|
|
using Dalamud.Plugin.Services;
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
namespace Questionable.Controller.NavigationOverrides;
|
|
|
|
internal sealed class MovementOverrideController
|
|
{
|
|
private static readonly List<IBlacklistedLocation> BlacklistedLocations;
|
|
|
|
private readonly IClientState _clientState;
|
|
|
|
private readonly ILogger<MovementOverrideController> _logger;
|
|
|
|
public MovementOverrideController(IClientState clientState, ILogger<MovementOverrideController> logger)
|
|
{
|
|
_clientState = clientState;
|
|
_logger = logger;
|
|
}
|
|
|
|
public (List<Vector3>, bool) AdjustPath(List<Vector3> navPoints)
|
|
{
|
|
foreach (IBlacklistedLocation blacklistedLocation in BlacklistedLocations)
|
|
{
|
|
if (_clientState.TerritoryType != blacklistedLocation.TerritoryId)
|
|
{
|
|
continue;
|
|
}
|
|
for (int i = 0; i < navPoints.Count; i++)
|
|
{
|
|
AlternateLocation alternateLocation = blacklistedLocation.AdjustPoint(navPoints[i]);
|
|
if (alternateLocation != null)
|
|
{
|
|
_logger.LogInformation("Fudging navmesh point from {Original} to {Replacement} in blacklisted area", navPoints[i].ToString("G", CultureInfo.InvariantCulture), alternateLocation);
|
|
navPoints[i] = alternateLocation.Point;
|
|
if (alternateLocation.RecalculateNavmesh)
|
|
{
|
|
return (navPoints.Take(i + 1).ToList(), true);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return (navPoints, false);
|
|
}
|
|
|
|
static MovementOverrideController()
|
|
{
|
|
int num = 31;
|
|
List<IBlacklistedLocation> list = new List<IBlacklistedLocation>(num);
|
|
CollectionsMarshal.SetCount(list, num);
|
|
Span<IBlacklistedLocation> span = CollectionsMarshal.AsSpan(list);
|
|
int num2 = 0;
|
|
span[num2] = new BlacklistedArea(1191, new Vector3(-223.0412f, 31.937134f, -584.03906f), 5f, 7.75f);
|
|
num2++;
|
|
span[num2] = new BlacklistedPoint(128, new Vector3(2f, 40.25f, 36.5f), new Vector3(0.25f, 40.25f, 36.5f));
|
|
num2++;
|
|
span[num2] = new BlacklistedPoint(132, new Vector3(29f, -8f, 120.5f), new Vector3(28.265165f, -8.000001f, 120.149734f));
|
|
num2++;
|
|
span[num2] = new BlacklistedPoint(132, new Vector3(28.25f, -8f, 125f), new Vector3(27.372725f, -8.200001f, 125.55859f));
|
|
num2++;
|
|
span[num2] = new BlacklistedPoint(132, new Vector3(32.25f, -8f, 126.5f), new Vector3(32.022232f, -8.200011f, 126.86095f));
|
|
num2++;
|
|
span[num2] = new BlacklistedPoint(205, new Vector3(26.75f, 0.5f, 20.75f), new Vector3(27.179117f, 0.26728272f, 19.714373f));
|
|
num2++;
|
|
span[num2] = new BlacklistedPoint(130, new Vector3(59.5f, 4.25f, -118f), new Vector3(60.551353f, 4f, -119.76446f));
|
|
num2++;
|
|
span[num2] = new BlacklistedPoint(145, new Vector3(-139.75f, -32.25f, 75.25f), new Vector3(-139.57748f, -33.785175f, 77.87906f));
|
|
num2++;
|
|
span[num2] = new BlacklistedPoint(146, new Vector3(-201.75f, 10.5f, -265.5f), new Vector3(-203.75235f, 10.130764f, -265.15314f));
|
|
num2++;
|
|
span[num2] = new BlacklistedArea(135, new Vector3(156.11499f, 15.518433f, 673.21277f), 0.5f, 5f);
|
|
num2++;
|
|
span[num2] = new BlacklistedPoint(139, new Vector3(366f, -2.5f, 95.5f), new Vector3(362.65973f, -3.4f, 96.6896f), 2f);
|
|
num2++;
|
|
span[num2] = new BlacklistedPoint(155, new Vector3(-478.75f, 149.25f, -305.75f), new Vector3(-476.1802f, 149.06573f, -304.7811f));
|
|
num2++;
|
|
span[num2] = new BlacklistedPoint(351, new Vector3(3.25f, 0.75f, 8.5f), new Vector3(4f, 0f, 9.5f));
|
|
num2++;
|
|
span[num2] = new BlacklistedPoint(418, new Vector3(-136.75f, 2.75f, 9f), new Vector3(-138.66408f, 2.0333426f, 8.860787f), 1f);
|
|
num2++;
|
|
span[num2] = new BlacklistedPoint(401, new Vector3(-14.75f, -136.75f, 515.75f), new Vector3(-17.631899f, -137.39148f, 512.6676f), 2f);
|
|
num2++;
|
|
span[num2] = new BlacklistedPoint(397, new Vector3(-93.75f, 87.75f, -715.5f), new Vector3(-87.78183f, 87.188995f, -713.3343f), 2f);
|
|
num2++;
|
|
span[num2] = new BlacklistedPoint(400, new Vector3(384f, -74f, 648.75f), new Vector3(386.0543f, -72.409454f, 652.0184f), 3f);
|
|
num2++;
|
|
span[num2] = new BlacklistedPoint(399, new Vector3(-514.4851f, 149.63762f, -480.58087f), new Vector3(-528.78656f, 151.17374f, -473.07077f), 5f, RecalculateNavmesh: true);
|
|
num2++;
|
|
span[num2] = new BlacklistedPoint(399, new Vector3(-534.5f, 153f, -476.75f), new Vector3(-528.78656f, 151.17374f, -473.07077f), 5f, RecalculateNavmesh: true);
|
|
num2++;
|
|
span[num2] = new BlacklistedPoint(478, new Vector3(14.5f, 215.25f, -101.5f), new Vector3(18.133032f, 215.44998f, -107.83075f), 5f);
|
|
num2++;
|
|
span[num2] = new BlacklistedPoint(478, new Vector3(11f, 215.5f, -104.5f), new Vector3(18.133032f, 215.44998f, -107.83075f), 5f);
|
|
num2++;
|
|
span[num2] = new BlacklistedPoint(1189, new Vector3(574f, -142.25f, 504.25f), new Vector3(574.44183f, -142.12766f, 507.60065f));
|
|
num2++;
|
|
span[num2] = new BlacklistedPoint(814, new Vector3(-324f, 348.75f, -181.75f), new Vector3(-322.75076f, 347.0529f, -177.69328f), 3f);
|
|
num2++;
|
|
span[num2] = new BlacklistedPoint(956, new Vector3(6.25f, -27.75f, -41.5f), new Vector3(5.0831127f, -28.213453f, -42.239136f));
|
|
num2++;
|
|
span[num2] = new BlacklistedPoint(1189, new Vector3(-115.75f, -213.75f, 336.5f), new Vector3(-112.40265f, -215.01514f, 339.0067f), 2f);
|
|
num2++;
|
|
span[num2] = new BlacklistedPoint(1190, new Vector3(-292.29004f, 18.598045f, -133.83907f), new Vector3(-288.20895f, 18.652182f, -132.67445f), 4f);
|
|
num2++;
|
|
span[num2] = new BlacklistedPoint(1191, new Vector3(-108f, 29.25f, -350.75f), new Vector3(-107.56289f, 29.008266f, -348.80087f));
|
|
num2++;
|
|
span[num2] = new BlacklistedPoint(1191, new Vector3(-105.75f, 29.75f, -351f), new Vector3(-105.335304f, 29.017048f, -348.85077f));
|
|
num2++;
|
|
span[num2] = new BlacklistedPoint(1186, new Vector3(284.25f, 50.75f, 171.25f), new Vector3(284.25f, 50.75f, 166.25f));
|
|
num2++;
|
|
span[num2] = new BlacklistedPoint(1186, new Vector3(283.75f, 50.75f, 167.25f), new Vector3(284.25f, 50.75f, 166.25f));
|
|
num2++;
|
|
span[num2] = new BlacklistedPoint(1186, new Vector3(287.75f, 51.25f, 172f), new Vector3(288.875f, 50.75f, 166.25f));
|
|
BlacklistedLocations = list;
|
|
}
|
|
}
|