using Godot; namespace Chessistics.Scripts.Pieces; public partial class TrajectView : Line2D { public int PieceId { get; private set; } private Polygon2D? _arrow; public void Setup(int pieceId, Vector2 from, Vector2 to, Color color) { PieceId = pieceId; Width = 2.5f; DefaultColor = new Color(color, 0.35f); Antialiased = true; ClearPoints(); AddPoint(from); AddPoint(to); ZIndex = -1; // Arrowhead at the end point var dir = (to - from).Normalized(); var perp = new Vector2(-dir.Y, dir.X); float arrowSize = 8f; var tip = to - dir * 4f; // slightly inset from end var baseL = tip - dir * arrowSize + perp * arrowSize * 0.5f; var baseR = tip - dir * arrowSize - perp * arrowSize * 0.5f; _arrow = new Polygon2D { Polygon = [tip - Position, baseL - Position, baseR - Position], Color = new Color(color, 0.4f), Position = Vector2.Zero }; // Position relative to parent, not this Line2D AddChild(_arrow); } }