b4638eb60b
Made-with: Cursor
42 lines
1.4 KiB
C#
42 lines
1.4 KiB
C#
using System;
|
|
using System.Linq;
|
|
using System.Numerics;
|
|
using Dalamud.Bindings.ImGui;
|
|
using Dalamud.Interface;
|
|
using FFXIVClientStructs.FFXIV.Client.UI.Agent;
|
|
using Mappy.Classes;
|
|
using Mappy.Data;
|
|
|
|
namespace Mappy.MapRenderer;
|
|
|
|
public partial class MapRenderer
|
|
{
|
|
private unsafe void DrawMovementTrail()
|
|
{
|
|
if (!System.SystemConfig.ShowMovementTrail) return;
|
|
|
|
var agent = AgentMap.Instance();
|
|
var territoryId = agent->SelectedTerritoryId;
|
|
var mapId = agent->SelectedMapId;
|
|
|
|
var now = DateTime.UtcNow.Subtract(DateTime.UnixEpoch).TotalSeconds;
|
|
var fadeTime = System.SystemConfig.MovementTrailFadeTimeSeconds;
|
|
|
|
foreach (var pt in System.MovementTrailConfig.GetVisiblePoints(territoryId, mapId).ToList()) {
|
|
var age = now - pt.TimeStamp;
|
|
var alpha = (float)((fadeTime - age) / fadeTime * 0.9);
|
|
if (alpha <= 0f) continue;
|
|
|
|
// Same coordinate space as map notes: world X,Z
|
|
var pos = new Vector2(pt.X, pt.Y) * Scale * DrawHelpers.GetMapScaleFactor() + DrawHelpers.GetCombinedOffsetVector() * Scale;
|
|
|
|
var size = Math.Clamp(4 * Scale, 3f, 25f);
|
|
var screenPos = ImGui.GetWindowPos() + DrawPosition + pos;
|
|
|
|
var color = System.MovementTrailConfig.TrailColor with { W = alpha };
|
|
var drawList = ImGui.GetWindowDrawList();
|
|
drawList.AddCircleFilled(screenPos, size, ImGui.GetColorU32(color));
|
|
}
|
|
}
|
|
}
|