From ba3818e6ccdd46538f937097d871c6b26534c2b5 Mon Sep 17 00:00:00 2001
From: "@Someone" <45270312+Someone-193@users.noreply.github.com>
Date: Mon, 9 Feb 2026 23:28:03 -0500
Subject: [PATCH 1/9] Update Draw.cs
---
EXILED/Exiled.API/Features/Draw.cs | 123 +++++++++++++++++++----------
1 file changed, 80 insertions(+), 43 deletions(-)
diff --git a/EXILED/Exiled.API/Features/Draw.cs b/EXILED/Exiled.API/Features/Draw.cs
index b53ef4320..f594a7029 100644
--- a/EXILED/Exiled.API/Features/Draw.cs
+++ b/EXILED/Exiled.API/Features/Draw.cs
@@ -8,10 +8,13 @@
namespace Exiled.API.Features
{
using System;
+ using System.Buffers;
using System.Collections.Generic;
using DrawableLine;
+ using Exiled.API.Features.Pools;
+
using Mirror;
using UnityEngine;
@@ -23,6 +26,9 @@ namespace Exiled.API.Features
///
public static class Draw
{
+ // smallest array that fits the largest default segment (17 for sphere)
+ private static readonly Vector3[] ArrayNonAlloc17 = new Vector3[5];
+
///
/// Draws a line between two specified points.
///
@@ -33,7 +39,10 @@ public static class Draw
/// A collection of s to show the line to.
public static void Line(Vector3 start, Vector3 end, Color color, float duration, IEnumerable players = null)
{
- Send(players, duration, color, start, end);
+ ArrayNonAlloc17[0] = start;
+ ArrayNonAlloc17[1] = end;
+
+ Send(players, duration, color, ArrayNonAlloc17, 2);
}
///
@@ -77,11 +86,15 @@ public static void Circle(Vector3 origin, Quaternion rotation, Vector3 scale, Co
/// The number of segments for the circles. Higher values result in a smoother sphere.
public static void Sphere(Vector3 origin, Quaternion rotation, Vector3 scale, Color color, float duration, IEnumerable players = null, int segments = 16)
{
+ List list = ListPool.Pool.Get(players);
+
Vector3[] horizontal = GetCirclePoints(origin, rotation, scale, segments, true);
- Send(players, duration, color, horizontal);
+ Send(list, duration, color, horizontal, segments);
Vector3[] vertical = GetCirclePoints(origin, rotation, scale, segments, false);
- Send(players, duration, color, vertical);
+ Send(list, duration, color, vertical, segments);
+
+ ListPool.Pool.Return(list);
}
///
@@ -199,24 +212,28 @@ public static void Capsule(Vector3 center, Quaternion rotation, float height, fl
Vector3 bottomCenter = center - (up * halfCylinderHeight);
Vector3 ringScale = new(radius * sX, 1f, radius * sZ);
- Circle(topCenter, rotation, ringScale, color, duration, players, horizontal: true);
- Circle(bottomCenter, rotation, ringScale, color, duration, players, horizontal: true);
+
+ List list = ListPool.Pool.Get(players);
+
+ Circle(topCenter, rotation, ringScale, color, duration, list);
+ Circle(bottomCenter, rotation, ringScale, color, duration, list);
float rX = radius * sX;
- Line(topCenter + (right * rX), bottomCenter + (right * rX), color, duration, players);
- Line(topCenter - (right * rX), bottomCenter - (right * rX), color, duration, players);
+ Line(topCenter + (right * rX), bottomCenter + (right * rX), color, duration, list);
+ Line(topCenter - (right * rX), bottomCenter - (right * rX), color, duration, list);
float rZ = radius * sZ;
- Line(topCenter + (forward * rZ), bottomCenter + (forward * rZ), color, duration, players);
- Line(topCenter - (forward * rZ), bottomCenter - (forward * rZ), color, duration, players);
+ Line(topCenter + (forward * rZ), bottomCenter + (forward * rZ), color, duration, list);
+ Line(topCenter - (forward * rZ), bottomCenter - (forward * rZ), color, duration, list);
Vector3 arcScaleSide = new(radius * sZ, radius * sY, 1f);
Vector3 arcScaleFront = new(radius * sX, radius * sY, 1f);
- Send(players, duration, color, GetArcPoints(topCenter, rotation, arcScaleSide, 180f));
- Send(players, duration, color, GetArcPoints(topCenter, rotation * Quaternion.Euler(0, 90, 0), arcScaleFront, 180f));
- Send(players, duration, color, GetArcPoints(bottomCenter, rotation * Quaternion.Euler(180, 0, 0), arcScaleSide, 180f));
- Send(players, duration, color, GetArcPoints(bottomCenter, rotation * Quaternion.Euler(180, 90, 0), arcScaleFront, 180f));
+ const int segments = 8;
+ Send(list, duration, color, GetArcPoints(topCenter, rotation, arcScaleSide, 180f, segments), segments);
+ Send(list, duration, color, GetArcPoints(topCenter, rotation * Quaternion.Euler(0, 90, 0), arcScaleFront, 180f, segments), segments);
+ Send(list, duration, color, GetArcPoints(bottomCenter, rotation * Quaternion.Euler(180, 0, 0), arcScaleSide, 180f, segments), segments);
+ Send(list, duration, color, GetArcPoints(bottomCenter, rotation * Quaternion.Euler(180, 90, 0), arcScaleFront, 180f, segments), segments);
}
///
@@ -232,14 +249,19 @@ public static void Mesh(Mesh mesh, Transform transform, Color color, float durat
int[] triangles = mesh.triangles;
Vector3[] vertices = mesh.vertices;
+ List list = ListPool.Pool.Get(players);
+
for (int i = 0; i < triangles.Length; i += 3)
{
- Vector3 p1 = transform.TransformPoint(vertices[triangles[i]]);
- Vector3 p2 = transform.TransformPoint(vertices[triangles[i + 1]]);
- Vector3 p3 = transform.TransformPoint(vertices[triangles[i + 2]]);
+ ArrayNonAlloc17[0] = transform.TransformPoint(vertices[triangles[i]]);
+ ArrayNonAlloc17[1] = transform.TransformPoint(vertices[triangles[i + 1]]);
+ ArrayNonAlloc17[2] = transform.TransformPoint(vertices[triangles[i + 2]]);
+ ArrayNonAlloc17[3] = ArrayNonAlloc17[0];
- Path([p1, p2, p3, p1], color, duration, players);
+ Send(list, duration, color, ArrayNonAlloc17, 4);
}
+
+ ListPool.Pool.Return(list);
}
///
@@ -259,28 +281,32 @@ public static void Box(Vector3 center, Vector3 size, Quaternion rotation, Color
float length = extents.z;
float height = extents.y;
- Vector3[] bottomRect = new Vector3[5];
- Vector3[] topRect = new Vector3[5];
+ ArrayNonAlloc17[0] = center + (rotation * new Vector3(-width, -height, -length));
+ ArrayNonAlloc17[1] = center + (rotation * new Vector3(width, -height, -length));
+ ArrayNonAlloc17[2] = center + (rotation * new Vector3(width, -height, length));
+ ArrayNonAlloc17[3] = center + (rotation * new Vector3(-width, -height, length));
+ ArrayNonAlloc17[4] = ArrayNonAlloc17[0];
- bottomRect[0] = center + (rotation * new Vector3(-width, -height, -length));
- bottomRect[1] = center + (rotation * new Vector3(width, -height, -length));
- bottomRect[2] = center + (rotation * new Vector3(width, -height, length));
- bottomRect[3] = center + (rotation * new Vector3(-width, -height, length));
- bottomRect[4] = bottomRect[0];
+ ArrayNonAlloc17[5] = center + (rotation * new Vector3(-width, height, -length));
+ ArrayNonAlloc17[6] = center + (rotation * new Vector3(width, height, -length));
+ ArrayNonAlloc17[7] = center + (rotation * new Vector3(width, height, length));
+ ArrayNonAlloc17[8] = center + (rotation * new Vector3(-width, height, length));
+ ArrayNonAlloc17[9] = ArrayNonAlloc17[5];
- topRect[0] = center + (rotation * new Vector3(-width, height, -length));
- topRect[1] = center + (rotation * new Vector3(width, height, -length));
- topRect[2] = center + (rotation * new Vector3(width, height, length));
- topRect[3] = center + (rotation * new Vector3(-width, height, length));
- topRect[4] = topRect[0];
+ // reduce enumeration
+ List list = ListPool.Pool.Get(players);
- Send(players, duration, color, bottomRect);
- Send(players, duration, color, topRect);
+ Send(list, duration, color, ArrayNonAlloc17, 5);
+ Send(list, duration, color, ArrayNonAlloc17, 5, 5);
for (int i = 0; i < 4; i++)
{
- Send(players, duration, color, bottomRect[i], topRect[i]);
+ ArrayNonAlloc17[10] = ArrayNonAlloc17[i];
+ ArrayNonAlloc17[11] = ArrayNonAlloc17[i + 5];
+ Send(list, duration, color, ArrayNonAlloc17, 2, 10);
}
+
+ ListPool.Pool.Return(list);
}
private static Vector3[] GetCirclePoints(Vector3 origin, Quaternion rotation, Vector3 scale, int segments, bool horizontal)
@@ -291,7 +317,7 @@ private static Vector3[] GetCirclePoints(Vector3 origin, Quaternion rotation, Ve
if (segments % 2 != 0)
segments++;
- Vector3[] array = new Vector3[segments + 1];
+ Vector3[] array = segments < 17 ? ArrayNonAlloc17 : new Vector3[segments + 1];
float num = MathF.PI * 2f / (float)segments;
for (int i = 0; i < segments; i++)
@@ -309,7 +335,7 @@ private static Vector3[] GetCirclePoints(Vector3 origin, Quaternion rotation, Ve
private static Vector3[] GetArcPoints(Vector3 origin, Quaternion rotation, Vector3 scale, float angle, int segments = 8)
{
- Vector3[] array = new Vector3[segments + 1];
+ Vector3[] array = segments < 17 ? ArrayNonAlloc17 : new Vector3[segments + 1];
float angleStep = (angle * Mathf.Deg2Rad) / segments;
for (int i = 0; i <= segments; i++)
@@ -324,27 +350,38 @@ private static Vector3[] GetArcPoints(Vector3 origin, Quaternion rotation, Vecto
return array;
}
- private static void Send(IEnumerable players, float duration, Color color, params Vector3[] points)
+ private static void Send(IEnumerable players, float duration, Color color, Vector3[] points, int? count = null, int offset = 0)
{
- if (points == null || points.Length < 2)
+ if (points == null || points.Length - offset < 2 || (count ??= points.Length) - offset < 2)
return;
- DrawableLineMessage msg = new(duration, color, points);
+ ArraySegment data;
+ using (NetworkWriterPooled writer = NetworkWriterPool.Get())
+ {
+ writer.WriteUShort((ushort)typeof(DrawableLineMessage).FullName.GetStableHashCode());
+ writer.WriteFloatNullable(duration);
+ writer.WriteColorNullable(color);
+ for (int i = offset; i < count + offset; i++)
+ writer.Write(points[i]);
+ data = writer.ToArraySegment();
+ }
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);
+ ply.Connection.Send(data);
}
}
else
{
- NetworkServer.SendToReady(msg);
+ foreach (NetworkConnectionToClient connectionToClient in NetworkServer.connections.Values)
+ {
+ if (connectionToClient.isReady)
+ {
+ connectionToClient.Send(data);
+ }
+ }
}
}
}
From a0b5eb5e0c40738e2c5977361756d84f65da75a5 Mon Sep 17 00:00:00 2001
From: "@Someone" <45270312+Someone-193@users.noreply.github.com>
Date: Mon, 9 Feb 2026 23:33:44 -0500
Subject: [PATCH 2/9] fix Sphere and Circle
---
EXILED/Exiled.API/Features/Draw.cs | 26 ++++++++++++++++----------
1 file changed, 16 insertions(+), 10 deletions(-)
diff --git a/EXILED/Exiled.API/Features/Draw.cs b/EXILED/Exiled.API/Features/Draw.cs
index f594a7029..bdda81529 100644
--- a/EXILED/Exiled.API/Features/Draw.cs
+++ b/EXILED/Exiled.API/Features/Draw.cs
@@ -54,7 +54,7 @@ public static void Line(Vector3 start, Vector3 end, Color color, float duration,
/// A collection of s to show the path to.
public static void Path(Vector3[] points, Color color, float duration, IEnumerable players = null)
{
- Send(players, duration, color, points);
+ Send(players, duration, color, points, points.Length);
}
///
@@ -70,8 +70,14 @@ public static void Path(Vector3[] points, Color color, float duration, IEnumerab
/// The number of line segments used to draw the circle. Higher values result in a smoother circle.
public static void Circle(Vector3 origin, Quaternion rotation, Vector3 scale, Color color, float duration, IEnumerable players = null, bool horizontal = true, int segments = 16)
{
+ if (segments <= 5)
+ segments = 8;
+
+ if (segments % 2 != 0)
+ segments++;
+
Vector3[] circlePoints = GetCirclePoints(origin, rotation, scale, segments, horizontal);
- Send(players, duration, color, circlePoints);
+ Send(players, duration, color, circlePoints, segments);
}
///
@@ -86,6 +92,12 @@ public static void Circle(Vector3 origin, Quaternion rotation, Vector3 scale, Co
/// The number of segments for the circles. Higher values result in a smoother sphere.
public static void Sphere(Vector3 origin, Quaternion rotation, Vector3 scale, Color color, float duration, IEnumerable players = null, int segments = 16)
{
+ if (segments <= 5)
+ segments = 8;
+
+ if (segments % 2 != 0)
+ segments++;
+
List list = ListPool.Pool.Get(players);
Vector3[] horizontal = GetCirclePoints(origin, rotation, scale, segments, true);
@@ -311,12 +323,6 @@ public static void Box(Vector3 center, Vector3 size, Quaternion rotation, Color
private static Vector3[] GetCirclePoints(Vector3 origin, Quaternion rotation, Vector3 scale, int segments, bool horizontal)
{
- if (segments <= 5)
- segments = 8;
-
- if (segments % 2 != 0)
- segments++;
-
Vector3[] array = segments < 17 ? ArrayNonAlloc17 : new Vector3[segments + 1];
float num = MathF.PI * 2f / (float)segments;
@@ -350,9 +356,9 @@ private static Vector3[] GetArcPoints(Vector3 origin, Quaternion rotation, Vecto
return array;
}
- private static void Send(IEnumerable players, float duration, Color color, Vector3[] points, int? count = null, int offset = 0)
+ private static void Send(IEnumerable players, float duration, Color color, Vector3[] points, int count, int offset = 0)
{
- if (points == null || points.Length - offset < 2 || (count ??= points.Length) - offset < 2)
+ if (points == null || points.Length - offset < 2 || count - offset < 2)
return;
ArraySegment data;
From 1163932a7498771950f01c12f5d91fc56ff2ea4f Mon Sep 17 00:00:00 2001
From: "@Someone" <45270312+Someone-193@users.noreply.github.com>
Date: Mon, 9 Feb 2026 23:34:43 -0500
Subject: [PATCH 3/9] I am a baguette
---
EXILED/Exiled.API/Features/Draw.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/EXILED/Exiled.API/Features/Draw.cs b/EXILED/Exiled.API/Features/Draw.cs
index bdda81529..779eb7890 100644
--- a/EXILED/Exiled.API/Features/Draw.cs
+++ b/EXILED/Exiled.API/Features/Draw.cs
@@ -27,7 +27,7 @@ namespace Exiled.API.Features
public static class Draw
{
// smallest array that fits the largest default segment (17 for sphere)
- private static readonly Vector3[] ArrayNonAlloc17 = new Vector3[5];
+ private static readonly Vector3[] ArrayNonAlloc17 = new Vector3[17];
///
/// Draws a line between two specified points.
From 99b0ce3ac9d2cd15182a500ffbda71c8b764a93b Mon Sep 17 00:00:00 2001
From: "@Someone" <45270312+Someone-193@users.noreply.github.com>
Date: Mon, 9 Feb 2026 23:35:48 -0500
Subject: [PATCH 4/9] keep old validation but use ref to update parameter
---
EXILED/Exiled.API/Features/Draw.cs | 26 ++++++++++----------------
1 file changed, 10 insertions(+), 16 deletions(-)
diff --git a/EXILED/Exiled.API/Features/Draw.cs b/EXILED/Exiled.API/Features/Draw.cs
index 779eb7890..660fa24d7 100644
--- a/EXILED/Exiled.API/Features/Draw.cs
+++ b/EXILED/Exiled.API/Features/Draw.cs
@@ -70,13 +70,7 @@ public static void Path(Vector3[] points, Color color, float duration, IEnumerab
/// The number of line segments used to draw the circle. Higher values result in a smoother circle.
public static void Circle(Vector3 origin, Quaternion rotation, Vector3 scale, Color color, float duration, IEnumerable players = null, bool horizontal = true, int segments = 16)
{
- if (segments <= 5)
- segments = 8;
-
- if (segments % 2 != 0)
- segments++;
-
- Vector3[] circlePoints = GetCirclePoints(origin, rotation, scale, segments, horizontal);
+ Vector3[] circlePoints = GetCirclePoints(origin, rotation, scale, ref segments, horizontal);
Send(players, duration, color, circlePoints, segments);
}
@@ -92,18 +86,12 @@ public static void Circle(Vector3 origin, Quaternion rotation, Vector3 scale, Co
/// The number of segments for the circles. Higher values result in a smoother sphere.
public static void Sphere(Vector3 origin, Quaternion rotation, Vector3 scale, Color color, float duration, IEnumerable players = null, int segments = 16)
{
- if (segments <= 5)
- segments = 8;
-
- if (segments % 2 != 0)
- segments++;
-
List list = ListPool.Pool.Get(players);
- Vector3[] horizontal = GetCirclePoints(origin, rotation, scale, segments, true);
+ Vector3[] horizontal = GetCirclePoints(origin, rotation, scale, ref segments, true);
Send(list, duration, color, horizontal, segments);
- Vector3[] vertical = GetCirclePoints(origin, rotation, scale, segments, false);
+ Vector3[] vertical = GetCirclePoints(origin, rotation, scale, ref segments, false);
Send(list, duration, color, vertical, segments);
ListPool.Pool.Return(list);
@@ -321,8 +309,14 @@ public static void Box(Vector3 center, Vector3 size, Quaternion rotation, Color
ListPool.Pool.Return(list);
}
- private static Vector3[] GetCirclePoints(Vector3 origin, Quaternion rotation, Vector3 scale, int segments, bool horizontal)
+ private static Vector3[] GetCirclePoints(Vector3 origin, Quaternion rotation, Vector3 scale, ref int segments, bool horizontal)
{
+ if (segments <= 5)
+ segments = 8;
+
+ if (segments % 2 != 0)
+ segments++;
+
Vector3[] array = segments < 17 ? ArrayNonAlloc17 : new Vector3[segments + 1];
float num = MathF.PI * 2f / (float)segments;
From 73dfe765b16b89a5f92f54a3b40e944b791a55ba Mon Sep 17 00:00:00 2001
From: "@Someone" <45270312+Someone-193@users.noreply.github.com>
Date: Mon, 9 Feb 2026 23:38:38 -0500
Subject: [PATCH 5/9] better name
---
EXILED/Exiled.API/Features/Draw.cs | 52 +++++++++++++++---------------
1 file changed, 26 insertions(+), 26 deletions(-)
diff --git a/EXILED/Exiled.API/Features/Draw.cs b/EXILED/Exiled.API/Features/Draw.cs
index 660fa24d7..7ab7649dd 100644
--- a/EXILED/Exiled.API/Features/Draw.cs
+++ b/EXILED/Exiled.API/Features/Draw.cs
@@ -27,7 +27,7 @@ namespace Exiled.API.Features
public static class Draw
{
// smallest array that fits the largest default segment (17 for sphere)
- private static readonly Vector3[] ArrayNonAlloc17 = new Vector3[17];
+ private static readonly Vector3[] ArrayNonAlloc = new Vector3[17];
///
/// Draws a line between two specified points.
@@ -39,10 +39,10 @@ public static class Draw
/// A collection of s to show the line to.
public static void Line(Vector3 start, Vector3 end, Color color, float duration, IEnumerable players = null)
{
- ArrayNonAlloc17[0] = start;
- ArrayNonAlloc17[1] = end;
+ ArrayNonAlloc[0] = start;
+ ArrayNonAlloc[1] = end;
- Send(players, duration, color, ArrayNonAlloc17, 2);
+ Send(players, duration, color, ArrayNonAlloc, 2);
}
///
@@ -253,12 +253,12 @@ public static void Mesh(Mesh mesh, Transform transform, Color color, float durat
for (int i = 0; i < triangles.Length; i += 3)
{
- ArrayNonAlloc17[0] = transform.TransformPoint(vertices[triangles[i]]);
- ArrayNonAlloc17[1] = transform.TransformPoint(vertices[triangles[i + 1]]);
- ArrayNonAlloc17[2] = transform.TransformPoint(vertices[triangles[i + 2]]);
- ArrayNonAlloc17[3] = ArrayNonAlloc17[0];
+ ArrayNonAlloc[0] = transform.TransformPoint(vertices[triangles[i]]);
+ ArrayNonAlloc[1] = transform.TransformPoint(vertices[triangles[i + 1]]);
+ ArrayNonAlloc[2] = transform.TransformPoint(vertices[triangles[i + 2]]);
+ ArrayNonAlloc[3] = ArrayNonAlloc[0];
- Send(list, duration, color, ArrayNonAlloc17, 4);
+ Send(list, duration, color, ArrayNonAlloc, 4);
}
ListPool.Pool.Return(list);
@@ -281,29 +281,29 @@ public static void Box(Vector3 center, Vector3 size, Quaternion rotation, Color
float length = extents.z;
float height = extents.y;
- ArrayNonAlloc17[0] = center + (rotation * new Vector3(-width, -height, -length));
- ArrayNonAlloc17[1] = center + (rotation * new Vector3(width, -height, -length));
- ArrayNonAlloc17[2] = center + (rotation * new Vector3(width, -height, length));
- ArrayNonAlloc17[3] = center + (rotation * new Vector3(-width, -height, length));
- ArrayNonAlloc17[4] = ArrayNonAlloc17[0];
+ ArrayNonAlloc[0] = center + (rotation * new Vector3(-width, -height, -length));
+ ArrayNonAlloc[1] = center + (rotation * new Vector3(width, -height, -length));
+ ArrayNonAlloc[2] = center + (rotation * new Vector3(width, -height, length));
+ ArrayNonAlloc[3] = center + (rotation * new Vector3(-width, -height, length));
+ ArrayNonAlloc[4] = ArrayNonAlloc[0];
- ArrayNonAlloc17[5] = center + (rotation * new Vector3(-width, height, -length));
- ArrayNonAlloc17[6] = center + (rotation * new Vector3(width, height, -length));
- ArrayNonAlloc17[7] = center + (rotation * new Vector3(width, height, length));
- ArrayNonAlloc17[8] = center + (rotation * new Vector3(-width, height, length));
- ArrayNonAlloc17[9] = ArrayNonAlloc17[5];
+ ArrayNonAlloc[5] = center + (rotation * new Vector3(-width, height, -length));
+ ArrayNonAlloc[6] = center + (rotation * new Vector3(width, height, -length));
+ ArrayNonAlloc[7] = center + (rotation * new Vector3(width, height, length));
+ ArrayNonAlloc[8] = center + (rotation * new Vector3(-width, height, length));
+ ArrayNonAlloc[9] = ArrayNonAlloc[5];
// reduce enumeration
List list = ListPool.Pool.Get(players);
- Send(list, duration, color, ArrayNonAlloc17, 5);
- Send(list, duration, color, ArrayNonAlloc17, 5, 5);
+ Send(list, duration, color, ArrayNonAlloc, 5);
+ Send(list, duration, color, ArrayNonAlloc, 5, 5);
for (int i = 0; i < 4; i++)
{
- ArrayNonAlloc17[10] = ArrayNonAlloc17[i];
- ArrayNonAlloc17[11] = ArrayNonAlloc17[i + 5];
- Send(list, duration, color, ArrayNonAlloc17, 2, 10);
+ ArrayNonAlloc[10] = ArrayNonAlloc[i];
+ ArrayNonAlloc[11] = ArrayNonAlloc[i + 5];
+ Send(list, duration, color, ArrayNonAlloc, 2, 10);
}
ListPool.Pool.Return(list);
@@ -317,7 +317,7 @@ private static Vector3[] GetCirclePoints(Vector3 origin, Quaternion rotation, Ve
if (segments % 2 != 0)
segments++;
- Vector3[] array = segments < 17 ? ArrayNonAlloc17 : new Vector3[segments + 1];
+ Vector3[] array = segments < 17 ? ArrayNonAlloc : new Vector3[segments + 1];
float num = MathF.PI * 2f / (float)segments;
for (int i = 0; i < segments; i++)
@@ -335,7 +335,7 @@ private static Vector3[] GetCirclePoints(Vector3 origin, Quaternion rotation, Ve
private static Vector3[] GetArcPoints(Vector3 origin, Quaternion rotation, Vector3 scale, float angle, int segments = 8)
{
- Vector3[] array = segments < 17 ? ArrayNonAlloc17 : new Vector3[segments + 1];
+ Vector3[] array = segments < 17 ? ArrayNonAlloc : new Vector3[segments + 1];
float angleStep = (angle * Mathf.Deg2Rad) / segments;
for (int i = 0; i <= segments; i++)
From cd0b988f82e50b011a6975136e920ece94d88306 Mon Sep 17 00:00:00 2001
From: "@Someone" <45270312+Someone-193@users.noreply.github.com>
Date: Mon, 9 Feb 2026 23:56:28 -0500
Subject: [PATCH 6/9] remove extra locals
---
EXILED/Exiled.API/Features/Draw.cs | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/EXILED/Exiled.API/Features/Draw.cs b/EXILED/Exiled.API/Features/Draw.cs
index 7ab7649dd..0c6f09a64 100644
--- a/EXILED/Exiled.API/Features/Draw.cs
+++ b/EXILED/Exiled.API/Features/Draw.cs
@@ -70,8 +70,7 @@ public static void Path(Vector3[] points, Color color, float duration, IEnumerab
/// The number of line segments used to draw the circle. Higher values result in a smoother circle.
public static void Circle(Vector3 origin, Quaternion rotation, Vector3 scale, Color color, float duration, IEnumerable players = null, bool horizontal = true, int segments = 16)
{
- Vector3[] circlePoints = GetCirclePoints(origin, rotation, scale, ref segments, horizontal);
- Send(players, duration, color, circlePoints, segments);
+ Send(players, duration, color, GetCirclePoints(origin, rotation, scale, ref segments, horizontal), segments);
}
///
@@ -88,11 +87,11 @@ public static void Sphere(Vector3 origin, Quaternion rotation, Vector3 scale, Co
{
List list = ListPool.Pool.Get(players);
- Vector3[] horizontal = GetCirclePoints(origin, rotation, scale, ref segments, true);
- Send(list, duration, color, horizontal, segments);
+ Vector3[] array = GetCirclePoints(origin, rotation, scale, ref segments, true);
+ Send(list, duration, color, array, segments);
- Vector3[] vertical = GetCirclePoints(origin, rotation, scale, ref segments, false);
- Send(list, duration, color, vertical, segments);
+ array = GetCirclePoints(origin, rotation, scale, ref segments, false);
+ Send(list, duration, color, array, segments);
ListPool.Pool.Return(list);
}
From ff4a0e2f64758cb505ef5aacd998b3a563b16634 Mon Sep 17 00:00:00 2001
From: "@Someone" <45270312+Someone-193@users.noreply.github.com>
Date: Wed, 11 Feb 2026 13:29:24 -0500
Subject: [PATCH 7/9] Fix default value
---
EXILED/Exiled.API/Features/Draw.cs | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/EXILED/Exiled.API/Features/Draw.cs b/EXILED/Exiled.API/Features/Draw.cs
index 0c6f09a64..990e3f352 100644
--- a/EXILED/Exiled.API/Features/Draw.cs
+++ b/EXILED/Exiled.API/Features/Draw.cs
@@ -85,7 +85,7 @@ public static void Circle(Vector3 origin, Quaternion rotation, Vector3 scale, Co
/// The number of segments for the circles. Higher values result in a smoother sphere.
public static void Sphere(Vector3 origin, Quaternion rotation, Vector3 scale, Color color, float duration, IEnumerable players = null, int segments = 16)
{
- List list = ListPool.Pool.Get(players);
+ List list = players is null ? null : ListPool.Pool.Get(players);
Vector3[] array = GetCirclePoints(origin, rotation, scale, ref segments, true);
Send(list, duration, color, array, segments);
@@ -212,7 +212,7 @@ public static void Capsule(Vector3 center, Quaternion rotation, float height, fl
Vector3 ringScale = new(radius * sX, 1f, radius * sZ);
- List list = ListPool.Pool.Get(players);
+ List list = players is null ? null : ListPool.Pool.Get(players);
Circle(topCenter, rotation, ringScale, color, duration, list);
Circle(bottomCenter, rotation, ringScale, color, duration, list);
@@ -248,7 +248,7 @@ public static void Mesh(Mesh mesh, Transform transform, Color color, float durat
int[] triangles = mesh.triangles;
Vector3[] vertices = mesh.vertices;
- List list = ListPool.Pool.Get(players);
+ List list = players is null ? null : ListPool.Pool.Get(players);
for (int i = 0; i < triangles.Length; i += 3)
{
@@ -293,7 +293,7 @@ public static void Box(Vector3 center, Vector3 size, Quaternion rotation, Color
ArrayNonAlloc[9] = ArrayNonAlloc[5];
// reduce enumeration
- List list = ListPool.Pool.Get(players);
+ List list = players is null ? null : ListPool.Pool.Get(players);
Send(list, duration, color, ArrayNonAlloc, 5);
Send(list, duration, color, ArrayNonAlloc, 5, 5);
From d6c4beff55ed6a9850e76ee37e488e57877bf759 Mon Sep 17 00:00:00 2001
From: "@Someone" <45270312+Someone-193@users.noreply.github.com>
Date: Wed, 11 Feb 2026 13:44:11 -0500
Subject: [PATCH 8/9] More fix
---
EXILED/Exiled.API/Features/Draw.cs | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/EXILED/Exiled.API/Features/Draw.cs b/EXILED/Exiled.API/Features/Draw.cs
index 990e3f352..08dad1d2e 100644
--- a/EXILED/Exiled.API/Features/Draw.cs
+++ b/EXILED/Exiled.API/Features/Draw.cs
@@ -93,7 +93,8 @@ public static void Sphere(Vector3 origin, Quaternion rotation, Vector3 scale, Co
array = GetCirclePoints(origin, rotation, scale, ref segments, false);
Send(list, duration, color, array, segments);
- ListPool.Pool.Return(list);
+ if (list != null)
+ ListPool.Pool.Return(list);
}
///
@@ -233,6 +234,9 @@ public static void Capsule(Vector3 center, Quaternion rotation, float height, fl
Send(list, duration, color, GetArcPoints(topCenter, rotation * Quaternion.Euler(0, 90, 0), arcScaleFront, 180f, segments), segments);
Send(list, duration, color, GetArcPoints(bottomCenter, rotation * Quaternion.Euler(180, 0, 0), arcScaleSide, 180f, segments), segments);
Send(list, duration, color, GetArcPoints(bottomCenter, rotation * Quaternion.Euler(180, 90, 0), arcScaleFront, 180f, segments), segments);
+
+ if (list != null)
+ ListPool.Pool.Return(list);
}
///
@@ -260,7 +264,8 @@ public static void Mesh(Mesh mesh, Transform transform, Color color, float durat
Send(list, duration, color, ArrayNonAlloc, 4);
}
- ListPool.Pool.Return(list);
+ if (list != null)
+ ListPool.Pool.Return(list);
}
///
@@ -305,7 +310,8 @@ public static void Box(Vector3 center, Vector3 size, Quaternion rotation, Color
Send(list, duration, color, ArrayNonAlloc, 2, 10);
}
- ListPool.Pool.Return(list);
+ if (list != null)
+ ListPool.Pool.Return(list);
}
private static Vector3[] GetCirclePoints(Vector3 origin, Quaternion rotation, Vector3 scale, ref int segments, bool horizontal)
From 9f6f65415b282c5c61fcf920bd34aeca8550a724 Mon Sep 17 00:00:00 2001
From: "@Someone" <45270312+Someone-193@users.noreply.github.com>
Date: Wed, 11 Feb 2026 14:08:03 -0500
Subject: [PATCH 9/9] another fix
---
EXILED/Exiled.API/Features/Draw.cs | 1 +
1 file changed, 1 insertion(+)
diff --git a/EXILED/Exiled.API/Features/Draw.cs b/EXILED/Exiled.API/Features/Draw.cs
index 08dad1d2e..5eb7361b9 100644
--- a/EXILED/Exiled.API/Features/Draw.cs
+++ b/EXILED/Exiled.API/Features/Draw.cs
@@ -366,6 +366,7 @@ private static void Send(IEnumerable players, float duration, Color colo
writer.WriteUShort((ushort)typeof(DrawableLineMessage).FullName.GetStableHashCode());
writer.WriteFloatNullable(duration);
writer.WriteColorNullable(color);
+ writer.WriteInt(count);
for (int i = offset; i < count + offset; i++)
writer.Write(points[i]);
data = writer.ToArraySegment();