From 1a6fc3860ee49ca0236408090bf16189e03fa59a Mon Sep 17 00:00:00 2001 From: MS-crew <100300664+MS-crew@users.noreply.github.com> Date: Fri, 23 Jan 2026 15:12:33 +0300 Subject: [PATCH 1/3] Added Draw class --- EXILED/Exiled.API/Features/Draw.cs | 129 +++++++++++++++++++++++++++++ 1 file changed, 129 insertions(+) create mode 100644 EXILED/Exiled.API/Features/Draw.cs diff --git a/EXILED/Exiled.API/Features/Draw.cs b/EXILED/Exiled.API/Features/Draw.cs new file mode 100644 index 000000000..2bc1175bb --- /dev/null +++ b/EXILED/Exiled.API/Features/Draw.cs @@ -0,0 +1,129 @@ +// ----------------------------------------------------------------------- +// +// Copyright (c) ExMod Team. All rights reserved. +// Licensed under the CC BY-SA 3.0 license. +// +// ----------------------------------------------------------------------- + +namespace Exiled.API.Features +{ + using DrawableLine; + + using Mirror; + + using UnityEngine; + + /// + /// A utility class for drawing debug lines, shapes, and bounds for players or globally. + /// + public static class Draw + { + private const float DefaultDuration = 5f; + + /// + /// Draws a line between two specified points. + /// + /// The starting position of the line. + /// The ending position of the line. + /// The color of the lines. + /// The to show the line to. If , it is shown to all players. + /// How long the line should remain visible. + public static void Line(Vector3 start, Vector3 end, Color color, Player player = null, float duration = DefaultDuration) + { + Send(player, duration, color, start, end); + } + + /// + /// Draws a connected path through a series of points. + /// + /// An array of points to connect sequentially. + /// The color of the lines. + /// The to show the path to. If , it is shown to all players. + /// How long the path should remain visible. + public static void Path(Vector3[] points, Color color, Player player = null, float duration = DefaultDuration) + { + Send(player, duration, color, points); + } + + /// + /// Draws a circle at a specific position. + /// + /// The center point of the circle. + /// The radius of the circle. + /// The color of the lines. + /// The to show the circle to. If , it is shown to all players. + /// Indicates whether the circle should be drawn on the horizontal plane (XZ) or vertical plane (XY). + /// The number of line segments used to draw the circle. Higher values result in a smoother circle. + /// How long the circle should remain visible. + public static void Circle(Vector3 origin, float radius, Color color, Player player = null, bool horizontal = true, int segments = 16, float duration = DefaultDuration) + { + Vector3[] circlePoints = DrawableLines.GetCircle(origin, radius, horizontal, segments); + Send(player, duration, color, circlePoints); + } + + /// + /// Draws a wireframe sphere composed of two circles (horizontal and vertical). + /// + /// The center point of the sphere. + /// The radius of the sphere. + /// The color of the lines. + /// The to show the sphere to. If , it is shown to all players. + /// The number of segments for the circles. Higher values result in a smoother sphere. + /// How long the sphere should remain visible. + public static void Sphere(Vector3 origin, float radius, Color color, Player player = null, int segments = 16, float duration = DefaultDuration) + { + Vector3[] horizontal = DrawableLines.GetCircle(origin, radius, true, segments); + Send(player, duration, color, horizontal); + + Vector3[] vertical = DrawableLines.GetCircle(origin, radius, false, segments); + Send(player, duration, color, vertical); + } + + /// + /// Draws the edges of a object. + /// + /// The object to visualize. + /// The color of the lines. + /// The to show the bounds to. If , it is shown to all players. + /// How long the bounds should remain visible. + public static void Bounds(Bounds bounds, Color color, Player player = null, float duration = DefaultDuration) + { + Vector3 center = bounds.center; + Vector3 extents = bounds.extents; + + Vector3[] array = new Vector3[5]; + Vector3[] array2 = new Vector3[5]; + + array[0] = center + new Vector3(-extents.x, -extents.y, -extents.z); + array[1] = center + new Vector3(extents.x, -extents.y, -extents.z); + array[2] = center + new Vector3(extents.x, -extents.y, extents.z); + array[3] = center + new Vector3(-extents.x, -extents.y, extents.z); + array[4] = array[0]; + + array2[0] = center + new Vector3(-extents.x, extents.y, -extents.z); + array2[1] = center + new Vector3(extents.x, extents.y, -extents.z); + array2[2] = center + new Vector3(extents.x, extents.y, extents.z); + array2[3] = center + new Vector3(-extents.x, extents.y, extents.z); + array2[4] = array2[0]; + + Send(player, duration, color, array); + Send(player, duration, color, array2); + + for (int i = 0; i < 4; i++) + { + Send(player, duration, color, array[i], array2[i]); + } + } + + private static void Send(Player player, float duration, Color color, params Vector3[] points) + { + if (points == null || points.Length < 2) + return; + + if (player != null) + player.Connection.Send(new DrawableLineMessage(duration, color, points)); + else + NetworkServer.SendToReady(new DrawableLineMessage(duration, color, points)); + } + } +} \ No newline at end of file From ce6d36f5da9a890cb0ade6c82820feffd140ff1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mustafa=20SAVA=C5=9E?= Date: Tue, 27 Jan 2026 14:09:40 +0300 Subject: [PATCH 2/3] update --- EXILED/Exiled.API/Features/Draw.cs | 93 +++++++++++++++++++----------- 1 file changed, 59 insertions(+), 34 deletions(-) diff --git a/EXILED/Exiled.API/Features/Draw.cs b/EXILED/Exiled.API/Features/Draw.cs index 2bc1175bb..c67762c1d 100644 --- a/EXILED/Exiled.API/Features/Draw.cs +++ b/EXILED/Exiled.API/Features/Draw.cs @@ -7,6 +7,9 @@ namespace Exiled.API.Features { + using System; + using System.Collections.Generic; + using DrawableLine; using Mirror; @@ -26,11 +29,12 @@ public static class Draw /// The starting position of the line. /// The ending position of the line. /// The color of the lines. - /// The to show the line to. If , it is shown to all players. + /// The single to show the line to. + /// A collection of s to show the line to. /// How long the line should remain visible. - public static void Line(Vector3 start, Vector3 end, Color color, Player player = null, float duration = DefaultDuration) + public static void Line(Vector3 start, Vector3 end, Color color, Player player = null, IEnumerable players = null, float duration = DefaultDuration) { - Send(player, duration, color, start, end); + Send(player, players, duration, color, start, end); } /// @@ -38,11 +42,12 @@ public static void Line(Vector3 start, Vector3 end, Color color, Player player = /// /// An array of points to connect sequentially. /// The color of the lines. - /// The to show the path to. If , it is shown to all players. + /// The single to show the path to. + /// A collection of s to show the path to. /// How long the path should remain visible. - public static void Path(Vector3[] points, Color color, Player player = null, float duration = DefaultDuration) + public static void Path(Vector3[] points, Color color, Player player = null, IEnumerable players = null, float duration = DefaultDuration) { - Send(player, duration, color, points); + Send(player, players, duration, color, points); } /// @@ -51,14 +56,15 @@ public static void Path(Vector3[] points, Color color, Player player = null, flo /// The center point of the circle. /// The radius of the circle. /// The color of the lines. - /// The to show the circle to. If , it is shown to all players. + /// The single to show the circle to. + /// A collection of s to show the circle to. /// Indicates whether the circle should be drawn on the horizontal plane (XZ) or vertical plane (XY). /// The number of line segments used to draw the circle. Higher values result in a smoother circle. /// How long the circle should remain visible. - public static void Circle(Vector3 origin, float radius, Color color, Player player = null, bool horizontal = true, int segments = 16, float duration = DefaultDuration) + public static void Circle(Vector3 origin, float radius, Color color, Player player = null, IEnumerable players = null, bool horizontal = true, int segments = 16, float duration = DefaultDuration) { Vector3[] circlePoints = DrawableLines.GetCircle(origin, radius, horizontal, segments); - Send(player, duration, color, circlePoints); + Send(player, players, duration, color, circlePoints); } /// @@ -67,16 +73,17 @@ public static void Circle(Vector3 origin, float radius, Color color, Player play /// The center point of the sphere. /// The radius of the sphere. /// The color of the lines. - /// The to show the sphere to. If , it is shown to all players. + /// The single to show the sphere to. + /// A collection of s to show the sphere to. /// The number of segments for the circles. Higher values result in a smoother sphere. /// How long the sphere should remain visible. - public static void Sphere(Vector3 origin, float radius, Color color, Player player = null, int segments = 16, float duration = DefaultDuration) + public static void Sphere(Vector3 origin, float radius, Color color, Player player = null, IEnumerable players = null, int segments = 16, float duration = DefaultDuration) { Vector3[] horizontal = DrawableLines.GetCircle(origin, radius, true, segments); - Send(player, duration, color, horizontal); + Send(player, players, duration, color, horizontal); Vector3[] vertical = DrawableLines.GetCircle(origin, radius, false, segments); - Send(player, duration, color, vertical); + Send(player, players, duration, color, vertical); } /// @@ -84,46 +91,64 @@ public static void Sphere(Vector3 origin, float radius, Color color, Player play /// /// The object to visualize. /// The color of the lines. - /// The to show the bounds to. If , it is shown to all players. + /// The single to show the bounds to. + /// A collection of s to show the bounds to. /// How long the bounds should remain visible. - public static void Bounds(Bounds bounds, Color color, Player player = null, float duration = DefaultDuration) + public static void Bounds(Bounds bounds, Color color, Player player = null, IEnumerable players = null, float duration = DefaultDuration) { Vector3 center = bounds.center; Vector3 extents = bounds.extents; - Vector3[] array = new Vector3[5]; - Vector3[] array2 = new Vector3[5]; + Vector3[] bottomRect = new Vector3[5]; + Vector3[] topRect = new Vector3[5]; - array[0] = center + new Vector3(-extents.x, -extents.y, -extents.z); - array[1] = center + new Vector3(extents.x, -extents.y, -extents.z); - array[2] = center + new Vector3(extents.x, -extents.y, extents.z); - array[3] = center + new Vector3(-extents.x, -extents.y, extents.z); - array[4] = array[0]; + bottomRect[0] = center + new Vector3(-extents.x, -extents.y, -extents.z); + bottomRect[1] = center + new Vector3(extents.x, -extents.y, -extents.z); + bottomRect[2] = center + new Vector3(extents.x, -extents.y, extents.z); + bottomRect[3] = center + new Vector3(-extents.x, -extents.y, extents.z); + bottomRect[4] = bottomRect[0]; - array2[0] = center + new Vector3(-extents.x, extents.y, -extents.z); - array2[1] = center + new Vector3(extents.x, extents.y, -extents.z); - array2[2] = center + new Vector3(extents.x, extents.y, extents.z); - array2[3] = center + new Vector3(-extents.x, extents.y, extents.z); - array2[4] = array2[0]; + topRect[0] = center + new Vector3(-extents.x, extents.y, -extents.z); + topRect[1] = center + new Vector3(extents.x, extents.y, -extents.z); + topRect[2] = center + new Vector3(extents.x, extents.y, extents.z); + topRect[3] = center + new Vector3(-extents.x, extents.y, extents.z); + topRect[4] = topRect[0]; - Send(player, duration, color, array); - Send(player, duration, color, array2); + Send(player, players, duration, color, bottomRect); + Send(player, players, duration, color, topRect); for (int i = 0; i < 4; i++) { - Send(player, duration, color, array[i], array2[i]); + Send(player, players, duration, color, bottomRect[i], topRect[i]); } } - private static void Send(Player player, float duration, Color color, params Vector3[] points) + private static void Send(Player player, IEnumerable players, float duration, Color color, params Vector3[] points) { if (points == null || points.Length < 2) return; - if (player != null) - player.Connection.Send(new DrawableLineMessage(duration, color, points)); + DrawableLineMessage msg = new(duration, color, points); + + if (players != null) + { + using NetworkWriterPooled writer = NetworkWriterPool.Get(); + NetworkMessages.Pack(msg, writer); + ArraySegment segment = writer.ToArraySegment(); + + foreach (Player ply in players) + { + ply?.Connection.Send(segment); + } + } + else if (player != null) + { + player.Connection.Send(msg); + } else - NetworkServer.SendToReady(new DrawableLineMessage(duration, color, points)); + { + NetworkServer.SendToReady(msg); + } } } } \ No newline at end of file From 661375253652173e109fb9a33a2a2d6defeb977a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mustafa=20SAVA=C5=9E?= Date: Tue, 27 Jan 2026 14:53:58 +0300 Subject: [PATCH 3/3] Yamato update --- EXILED/Exiled.API/Features/Draw.cs | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/EXILED/Exiled.API/Features/Draw.cs b/EXILED/Exiled.API/Features/Draw.cs index c67762c1d..b6bb32776 100644 --- a/EXILED/Exiled.API/Features/Draw.cs +++ b/EXILED/Exiled.API/Features/Draw.cs @@ -21,18 +21,16 @@ namespace Exiled.API.Features /// public static class Draw { - private const float DefaultDuration = 5f; - /// /// Draws a line between two specified points. /// /// The starting position of the line. /// The ending position of the line. /// The color of the lines. + /// How long the line should remain visible.Warning: Avoid using or extremely large values, as these lines cannot be removed from the client once sent. /// The single to show the line to. /// A collection of s to show the line to. - /// How long the line should remain visible. - public static void Line(Vector3 start, Vector3 end, Color color, Player player = null, IEnumerable players = null, float duration = DefaultDuration) + public static void Line(Vector3 start, Vector3 end, Color color, float duration, Player player = null, IEnumerable players = null) { Send(player, players, duration, color, start, end); } @@ -42,10 +40,10 @@ public static void Line(Vector3 start, Vector3 end, Color color, Player player = /// /// An array of points to connect sequentially. /// The color of the lines. + /// How long the line should remain visible.Warning: Avoid using or extremely large values, as these lines cannot be removed from the client once sent. /// The single to show the path to. /// A collection of s to show the path to. - /// How long the path should remain visible. - public static void Path(Vector3[] points, Color color, Player player = null, IEnumerable players = null, float duration = DefaultDuration) + public static void Path(Vector3[] points, Color color, float duration, Player player = null, IEnumerable players = null) { Send(player, players, duration, color, points); } @@ -56,12 +54,12 @@ public static void Path(Vector3[] points, Color color, Player player = null, IEn /// The center point of the circle. /// The radius of the circle. /// The color of the lines. + /// How long the line should remain visible.Warning: Avoid using or extremely large values, as these lines cannot be removed from the client once sent. /// The single to show the circle to. /// A collection of s to show the circle to. /// Indicates whether the circle should be drawn on the horizontal plane (XZ) or vertical plane (XY). /// The number of line segments used to draw the circle. Higher values result in a smoother circle. - /// How long the circle should remain visible. - public static void Circle(Vector3 origin, float radius, Color color, Player player = null, IEnumerable players = null, bool horizontal = true, int segments = 16, float duration = DefaultDuration) + public static void Circle(Vector3 origin, float radius, Color color, float duration, Player player = null, IEnumerable players = null, bool horizontal = true, int segments = 16) { Vector3[] circlePoints = DrawableLines.GetCircle(origin, radius, horizontal, segments); Send(player, players, duration, color, circlePoints); @@ -73,11 +71,11 @@ public static void Circle(Vector3 origin, float radius, Color color, Player play /// The center point of the sphere. /// The radius of the sphere. /// The color of the lines. + /// How long the line should remain visible.Warning: Avoid using or extremely large values, as these lines cannot be removed from the client once sent. /// The single to show the sphere to. /// A collection of s to show the sphere to. /// The number of segments for the circles. Higher values result in a smoother sphere. - /// How long the sphere should remain visible. - public static void Sphere(Vector3 origin, float radius, Color color, Player player = null, IEnumerable players = null, int segments = 16, float duration = DefaultDuration) + public static void Sphere(Vector3 origin, float radius, Color color, float duration, Player player = null, IEnumerable players = null, int segments = 16) { Vector3[] horizontal = DrawableLines.GetCircle(origin, radius, true, segments); Send(player, players, duration, color, horizontal); @@ -91,10 +89,10 @@ public static void Sphere(Vector3 origin, float radius, Color color, Player play /// /// The object to visualize. /// The color of the lines. + /// How long the line should remain visible.Warning: Avoid using or extremely large values, as these lines cannot be removed from the client once sent. /// The single to show the bounds to. /// A collection of s to show the bounds to. - /// How long the bounds should remain visible. - public static void Bounds(Bounds bounds, Color color, Player player = null, IEnumerable players = null, float duration = DefaultDuration) + public static void Bounds(Bounds bounds, Color color, float duration, Player player = null, IEnumerable players = null) { Vector3 center = bounds.center; Vector3 extents = bounds.extents;