From f1c8b6e39facb9c5c58ff5f6a7cadfbc446cc9c8 Mon Sep 17 00:00:00 2001 From: Mikhail <99481254+DCFApixels@users.noreply.github.com> Date: Sun, 17 Mar 2024 05:22:33 +0800 Subject: [PATCH] Create UncheckedCoreUtility.cs --- src/Utils/UncheckedCoreUtility.cs | 42 +++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 src/Utils/UncheckedCoreUtility.cs diff --git a/src/Utils/UncheckedCoreUtility.cs b/src/Utils/UncheckedCoreUtility.cs new file mode 100644 index 0000000..4112dfe --- /dev/null +++ b/src/Utils/UncheckedCoreUtility.cs @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using System.Runtime.CompilerServices; + +namespace DCFApixels.DragonECS.UncheckedCore +{ + public static class UncheckedCoreUtility + { + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static EcsSpan CreateSpan(short worldID, int[] entitesArray, int startIndex, int length) + { + return new EcsSpan(worldID, entitesArray, startIndex, length); + } + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static EcsSpan CreateSpan(short worldID, int[] entitesArray, int length) + { + return new EcsSpan(worldID, entitesArray, length); + } + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static EcsSpan CreateSpan(short worldID, int[] entitesArray) + { + return new EcsSpan(worldID, entitesArray); + } + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static EcsSpan CreateEmptySpan(short worldID) + { + return new EcsSpan(worldID, Array.Empty()); + } + public static bool CheckSpanValideDebug(EcsSpan span) + { + HashSet set = new HashSet(span.Count); + foreach (var e in span) + { + if (set.Add(e) == false) + { + return false; + } + } + return true; + } + } +}